
-----------------------------------
[Flame][Boy]
Thu Jan 19, 2006 10:03 am

Space Invaders... Using an array for X and Y Of Enemies  :?
-----------------------------------
Hey guys im making a copy of space invaders and i need to know how to set the x and y value of my enemies using an array like i have an array of 1..20 and i need to set different x and y values for all 20 is that possible  :?:  :?:

-----------------------------------
zylum
Thu Jan 19, 2006 11:09 am


-----------------------------------
Use records.


type Position:
    record
        x, y : int
    end record

var badies : array 1..20 of Position

for i : 1..20
    badies(i).x := i*100
    badies(i).y := maxy-200
end for


Just fixing a few typos in the code...
Carry on.


-----------------------------------
Drakain Zeil
Thu Jan 19, 2006 6:04 pm


-----------------------------------
Also, if you're looking to abuse the ability of poor programming, don't forget that arrays can have many dimentions...

var a:array 1..20, 1..2 of int
% 1..20 indicates unit, 1..2 is either the x or y axis.

But, you should use records instead, as already said.
