Objects and Pointers

BlitzMax Forums/BlitzMax Beginners Area/Objects and Pointers

Ant(Posted 2006) [#1]
Hi quick question, in my current project I have a number of objects, each object contains the field

Field image:Timage.

which is the image data I use to draw the object. In the game each object uses 1 of 5 different images, so I am thinking rather than store the image data in each object I should be storing a pointer to the image data in each object?
Thanks


Who was John Galt?(Posted 2006) [#2]
What you are doing is effectively storing a pointer. All Blitz types are pointers to structures, so you only have to load an image once and you can have thousands of objects referencing it.


Ant(Posted 2006) [#3]
ok I see. Thanks for the help


Ant(Posted 2006) [#4]
On the same kind of topic. Just tried out this code to explain something to myself:



Am I right in thinking that square.test is a pointer to ball? As the line

square.test.one=6

changes the value of ball.one?


Diablo(Posted 2006) [#5]
yes

run this


Ant(Posted 2006) [#6]
Yip thought so. Cheers