I need help with types. I know how to set then up but I can not get it to make more than one image with a type. For example make a bullet with the type function and every time I hit say shift a new bullet will shot, so I do not have to make a image for every shot. If some one can help me I would be very happy.
bullets
Blitz3D Forums/Blitz3D Beginners Area/bullets Your question is very unclear...
To create another instance of a type, use the New command.
To create another instance of a type, use the New command.
Sorry it was not clear I will try again. Ok I need to make a type for a bullet (im using blitz plus by the way). I can set it up but how do I make it so when I hit shift a new bullet shots across the screen.
Basically WolRon has already answered to your question.
Consider your type structure as a dynamic container, like for example:
When you create a new bullet with the New command:
You have a brand new bullet in your bullet type collection. You don't see it unless you display an image for it:
Now, each time you press your fire key, just create a new bullet as before, and you're done.
You should take care of bullet expiration too; for example, you may want to delete the bullets which have gone out of the screen.
So, in the updategame function, you can check for the bullet x and y position, and if they are outside, then delete the bullet.
Hope this helps,
Sergio.
Consider your type structure as a dynamic container, like for example:
type t_bullet field x,y field speedx,speedy end type Global bullet.t_bullet
When you create a new bullet with the New command:
bullet.t_bullet = New t_bullet ;create the bullet at the mouse x,y position bullet\x = mousex() bullet\y = mousey() bullet\speedx = 2 bullet\speedy = 1
You have a brand new bullet in your bullet type collection. You don't see it unless you display an image for it:
while not keydown(1) cls ;move all bullets updategame() ;show all bullets rendergame() flip wend end ;=================================== function updategame() ;=================================== for bullet.t_bullet = each t_bullet bullet\x = bullet\x + bullet\speedx bullet\y = bullet\y + bullet\speedy next end function ;=================================== function rendergame() ;=================================== for bullet.t_bullet = each t_bullet ;the bullet image is a global image called image_bullet drawimage image_bullet,bullet\x,bullet\y next end function
Now, each time you press your fire key, just create a new bullet as before, and you're done.
You should take care of bullet expiration too; for example, you may want to delete the bullets which have gone out of the screen.
So, in the updategame function, you can check for the bullet x and y position, and if they are outside, then delete the bullet.
Hope this helps,
Sergio.
Or you could just go to the TUTORIALS section where this has been shown in completeness!!!
@pyro821,
were our answers of any help for you ?
Sergio.
were our answers of any help for you ?
Sergio.