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

Username:   Password: 
 RegisterRegister   
 Objects/Pointers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flikerator




PostPosted: Thu Apr 06, 2006 12:00 pm   Post subject: Objects/Pointers

How do I make this;

code:

type Monster_Stats :
    record
        x, y : real
        temp_spd, base_spd, sprint_spd : real
        angle : real
        Rotate_spd_base, Rotate_spd_temp : real
        Move : boolean
    end record

var Monster : flexible array 1 .. 0 of Monster_Stats
for i : 1 .. 20
    new Monster, upper (Monster) + 1
    Monster (upper (Monster)).x := Rand.Int (200, maxx)
    Monster (upper (Monster)).y := Rand.Int (200, maxy)
    Monster (upper (Monster)).base_spd := 2 + Rand.Real + Rand.Real
    Monster (upper (Monster)).angle := Rand.Int (0, 5) + Rand.Real
    Monster (upper (Monster)).Rotate_spd_base := 0.2
end for


Into an object? I might be thinking about Class, so whichever one makes more sense ^^;
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Apr 06, 2006 12:01 pm   Post subject: (No subject)

why do you have to make it into a class? a type is also an object, just not an ADT. you can still point to it
Delos




PostPosted: Thu Apr 06, 2006 3:00 pm   Post subject: (No subject)

If you really want to make a Monster Class, simply read Cervantes 3-part Classes tutorial. Really, nothing simpler. Though keep in mind what dodge said, at times you may be better off using types instead of Classes. Though often you'll end up using records of pointers to said Classes anyway. Very Happy
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: