Page 1 of 1

Array programming

PostPosted: Wed Jul 21, 2004 2:08 pm
by VYTIS_KNIGHT
Can this be done in Game Editor?

Setup an array move all the Aliens left or right or up or down together. Then, do a distance check to see how close you are to the top, left, right and bottom bounds. If they are too close, move the opposite direction or down.

PostPosted: Wed Jul 21, 2004 3:28 pm
by jazz_e_bob
Yes. :)

(Your description is a solid basis for the code itself.)

The following PseudoCode outlines a possible solution...



Variables:

global_Invaders_Direction
global_Invaders_Speed

invadersWin


Routines:

init_Invaders
{
invadersWin = FALSE
global_Invaders_Direction = RIGHT
global_Invaders_Speed = SLOWEST

( create invaders in start up position here )

}


On Draw Invader
{
myDirection = global_Invaders_Direction
mySpeed = global_Invaders_Speed

If too close to right ( eg x > max )
drop global level and change global direction
else If too close to left (eg x < min )
drop global level and change global direction
if global level is ground level ( eg y > max )
invadersWin = TRUE

adjust global_Invaders_Speed according to population of invaders

}


I hope this helps! 8)

PostPosted: Thu Jul 22, 2004 1:38 pm
by makslane
You can make this too:

- Create a Wire Frame actor (actor Base)
- Create your alliens and make the Base actor your parent
- to move all alliens, just move the Base actor
- Create other four Wire Frame actors (will be our sensor actors: sensor_left, sensor_right, sensor_top, sensor bottom)
- Put one at right side of view, other on left, other on top, other on bottom

Now, in your Base actor:

- When collides with sensor_left, xvelocity = 1
- When collides with sensor_right, xvelocity = -1
- When collides with sensor_top, yvelocity = 1
- When collides with sensor_bottom, yvelocity = -1

PostPosted: Wed Jul 28, 2004 5:53 pm
by VYTIS_KNIGHT
makslane, Do you have an example of this?

PostPosted: Thu Jul 29, 2004 12:26 pm
by makslane
I will make a tutorial soon

PostPosted: Thu Jul 29, 2004 12:30 pm
by VYTIS_KNIGHT
What happens to the children of the parent dies? Say you have parent 1 and child1, child2, and child3 is connected to it.

PostPosted: Thu Jul 29, 2004 8:37 pm
by makslane
When the parent dies, the child stay live

PostPosted: Thu Jul 29, 2004 8:44 pm
by VYTIS_KNIGHT
Does it follow the same path or directions the parrent was programmed to do?

PostPosted: Fri Jul 30, 2004 10:53 pm
by makslane
Yes, All children moves will be relative to parent

PostPosted: Fri Jul 30, 2004 11:06 pm
by VYTIS_KNIGHT
So if the parent dies and the parent was set to move a certain direction, the children associated with the parent still move in the direction the parent was programmed to move. Is this correct?

PostPosted: Sun Aug 01, 2004 2:01 am
by makslane
If a parent die, your children has no more parents.
So, will stop

To see the Space Invaders tutorial, please
update your Game Editor to 1.2.2 version,
updaate your tutorials (Help -> Get Newest Tutorials),
and go to Help -> Demo Making Of -> Space Invaders