The Daily Click ::. Forums ::. Klik Coding Help ::. Big Help Needed! Take the time... )
 

Post Reply  Post Oekaki 
 

Posted By Message

Tim*



Registered
  26/01/2005
Points
  77
1st April, 2005 at 17:48:11 -

Ok...need help, blah blah blah.

I'm making a space type trader game.
Imagine a screen with a planet on it. A galaxy. Only smaller (3000x3000).
Every time the frame restarts, like if you jump into the system, a random number of ships appear (e.g 1-10). I've done this, and it's good.
---BUT!
I want to make it that you can select a ship, to lock on missles to it and such.
Ok, so we can click on the ship to do that. Easy. Set it's selected flag on or something like that.
---BUT!
I want to make it that you can cycle through the ships with the tab button.
---FOR EXAMPLE! (This i would like help with to make)
There are 5 shuttles in the frame. The ship description sidebar (which shows what ship you have selected) starts off as "None". This means that you are currently NOT selecting any ships.
You Press Tab. One of the shuttles gets selected. (Arrows appear above it to show that)
You Press Tab...More Times. A different shuttle gets selected each time, until it's back to "None". See? If you still dont understand, i'll draw/type a diagram.
(imagine there are 5 ships, some different actives than others (like shuttles, or fighters)

Selected
Start Off 0 (None)
Pressed Tab 1 (A ship e.g shuttle)
Pressed Tab 2 (A ship e.g shuttle)
Pressed Tab 3 (A ship e.g shuttle)
Pressed Tab 4 (A ship e.g shuttle)
Pressed Tab 5 (A ship e.g shuttle)
Pressed Tab (and all the ships have been selected) - Goes back to 0 "None".

---OK!
Seems easy? I got as far as that.
---BUT!
What if a ship got destroyed? E.g Ship 2 (the ship that's number 2 on the tab cycle)?
If ship2 was selected, it wouldn't show up. You can get round this by respreading values, but it dosen't work as we will see below)
---
What if you were selecting a ship, and while it was blowing up, you changed your selected ship to another one? (If you respread the values every time a ship blew up, the ship would have a different value and not be seleced?)
-------------------------------------------------------------------------------------
---PHEW.
If anyone out there has the guts to read this, please think about it and HELP HELP HELP!!!

 
I have the ENTIRE C&C: Tiberian Dawn soundtrack. Extracted from the original game, in all it's succulent beauty. Oh baby, it's true. PM me for details on how to get it if you want.

Wicked Studios



Registered
  25/10/2004
Points
  460
1st April, 2005 at 18:07:29 -

If a ship is blown up you should add one to the currently selected ship then spread the values again, maybe that will work.

 
"Actually sir, we found a tiny unicorn in your exhaust. It was jumping around poking holes in your gas tank." "Oh thank you I did not know that. A tiny unicorn? Wow."

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
1st April, 2005 at 22:35:20 -

At the beginning of the level, spread a value (spread 1 in this case) throughout all of the ship objects. Have a counter or alterable value that keeps track of what ship number you'll be on. Make sure that counter/alterable value is 0 at the beginning.
Every time the player presses the tab key, do an event like
Upon pressing "Tab" | Alterable Value A("ship") = value("shipnumber") --> (code that selects the ship) | Add 1 to shipnumber

Then have another event, like
 value("shipnumber") > NObjects("ship") --> value("shipnumber") = 0 | (code the deselects ship)


 
http://www.klik-me.com

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
2nd April, 2005 at 09:18:28 -

hmm... sounds Escape Velocity-ish

 
n/a

clwe



Registered
  17/12/2002
Points
  702
2nd April, 2005 at 09:46:54 -

Hmm...while it's not the most resourceful technique, if you have MMF you could use an array and a fastloop. First, create a one-dimensional array of values, the same size as the number of ships there are. Each position in the array will represent the state of a ship - 0 means 'active' and 1 means 'destroyed'.

With that in mind, you could code the events like this to skip over ships that have been destroyed/removed:

Upon pressing 'Tab'
alterable Value A of ship = value 'ship selected'
position 'ship selected' in array has value of 0 (active)
• Add 1 to 'ship selected'
• (code for selecting the ship)


Upon pressing 'Tab'
Alterable Value A of ship = value 'ship selected'
Position 'ship selected' in array has value of 1 (destroyed)
• Add 1 to 'ship selected'
• start loop 1 for 50 loops


Loop trigger 1
Position 'ship selected' in array has value of 1
• Add 1 to 'ship selected'

Loop trigger 1
Position 'ship selected' in array has value of 0
• Stop loop 1
• (code for selecting the ship)


When Tab is pressed, one is added to the 'ship selected' counter, which will try and target the first or the next ship in sequence. If the current ship's status (using the array, as explained earlier) is 'active', it would be selected as noraml. If, however, its status is 'destroyed', A fastloop begins and MMF checks the status of the next ship. The process continues until it finds a ship that is 'active' (value 0), whereupon it selects it.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click