Objects/Pointers
Author |
Message |
Flikerator
|
Posted: 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
|
|
|
Andy
|
Posted: 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
|
Posted: 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. |
|
|
|
|
|
|
|