Attaching Graphics to Custom Types

Blitz3D Forums/Blitz3D Beginners Area/Attaching Graphics to Custom Types

Jellon(Posted 2004) [#1]
I am totally new to blitz, and for the most part programming in general. I am working on a very simple game. What happens is you can move your ship around (that part was simple), but these balls come flying at you. I created a custom type I called ball. It has fields X#, Y#, Z#. I can change the values of the coordinates easy too, but how do I get a picture of a ball to follow each of the balls I make from the type? (I have made graphics for all these already)


Paul "Taiphoz"(Posted 2004) [#2]
for ball.ball = each ball
drawimage someimage,ball\x,ball\y,ball\z
next

you could do this.

type ball
field x,y,z
field image
end type

ball.ball = new ball
ball\image=loadimage("ball.bmp")

then in the above loop it would be.

drawimage ball\image,ball\x,blah\y,blah\z

Hope it helps.

Just make sure you free your images once your done with them.


Jellon(Posted 2004) [#3]
Yeah, freeing the images was the problem. My balls became a trail of spheres! Having thousands of spheres on my screen at once wasn't good for my computer. I worked more on it and got it working.
Thank you for you help Yavin.