I'm making a space invaders game. I have the enemies running from right to left and back.
I had to make a Global direction variable and integrate that in the movement of the enemy-objects to make it work because when i tried to change all individual direction variables some were left untouched and some were changed twice. So the global is a solution for this problem.
But now i have the problem of the y movement. I want to move all enemies 20 points down on the y-axle when a (whichever) enemy changes direction on the x-axle. I really don't want to make the y a global because it limits my options with the object.
I tried to do a single change of y for all enemy-objects with EachIn in the Update of the object itself but this means i do a Eachin on a Eachin for the same object so i tried to limited the calls to the number of enemies but it doesn't do what i expected: some objects move down 20 points, some move down 40 points and some dont move down.
I keep all objects in 1 list and call them by type, this works (to my suprise) but is this whats causing the inconsistent object-updates? I really want to keep all objects in the same list for the same reason that some people need to drink coffee after dinner or wash their hands every 30 minutes :)
Sorry for the lack of code but i'm at work and don't have the code here. I really hope to solve this tonight at home.
Anyone any suggestions on how to do a change on all objects of a certain type (in a big list of several types but all extends within same object-tree) as soon as a trigger (one of the objects hits the x margin) is set off?
*Will post the code tonight.
I had to make a Global direction variable and integrate that in the movement of the enemy-objects to make it work because when i tried to change all individual direction variables some were left untouched and some were changed twice. So the global is a solution for this problem.
But now i have the problem of the y movement. I want to move all enemies 20 points down on the y-axle when a (whichever) enemy changes direction on the x-axle. I really don't want to make the y a global because it limits my options with the object.
I tried to do a single change of y for all enemy-objects with EachIn in the Update of the object itself but this means i do a Eachin on a Eachin for the same object so i tried to limited the calls to the number of enemies but it doesn't do what i expected: some objects move down 20 points, some move down 40 points and some dont move down.
I keep all objects in 1 list and call them by type, this works (to my suprise) but is this whats causing the inconsistent object-updates? I really want to keep all objects in the same list for the same reason that some people need to drink coffee after dinner or wash their hands every 30 minutes :)
Sorry for the lack of code but i'm at work and don't have the code here. I really hope to solve this tonight at home.
Anyone any suggestions on how to do a change on all objects of a certain type (in a big list of several types but all extends within same object-tree) as soon as a trigger (one of the objects hits the x margin) is set off?
*Will post the code tonight.