shooting in 2d

Blitz3D Forums/Blitz3D Beginners Area/shooting in 2d

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

how about this:

let's say your gun, cannon or whatever can be rotated 360 degrees. Then at some angle the player may shoot.

Now do this:

if firebutton
 force_x#=sin(angle)*speed#
 force_y#=cos(angle)*speed#
 bullet_x#=gun_x#
 bullet_y#=gun_y#
endif

bullet_x#=bullet_x#+force_x#
bullet_y#=bullet_y#+force_y#

drawimage bullet, bullet_x#,bullet_y#