Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Space Invaders... Using an array for X and Y Of Enemies :?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Flame][Boy]




PostPosted: Thu Jan 19, 2006 10:03 am   Post subject: 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 Question Question
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: Thu Jan 19, 2006 11:09 am   Post subject: (No subject)

Use records.

code:

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


[mod:85b5970787="Delos"]
Just fixing a few typos in the code...
Carry on.
[/mod:85b5970787]
Drakain Zeil




PostPosted: Thu Jan 19, 2006 6:04 pm   Post subject: (No subject)

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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: