LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Making a shooting game.

Root / Programming Questions / [.]

FinnowCreated:
So I'm try to make a game where you shoot stuff, and I'm try to do 360 degree aiming. Like, you point somewhere and the bullet goes that direction.

@randomous's Simple Bullet Tutorial is probably what you're looking for EDIT: I just remembered that this tutorial only shows how to do shooting in 4 directions. Implementing shooting with the circle pad is fairly complicated to understand, but I know somebody here has already explained the concept on another thread (which I can't find..)

Sorry, I don't want to type it all up again, try this link. http://smilebasicsource.com/forum?fpid=25671#post_25671 If you read it and still have questions, or find type-os, please let me know.

I already know how to do most of it, I just need to know what code I use to make my bullets move properly.

Well, if that's all you need to know, in seggiepants' code, this
DEF UPDATE_SHOVEL
 VAR X# = SPVAR(CALLIDX, 0)
 VAR Y# = SPVAR(CALLIDX, 1)
 VAR HEADING# = SPVAR(CALLIDX, 2)
 VAR SPEED# = SPVAR(CALLIDX, 3)
 VAR STEP# = ((SPEED# * DT%) / 1000.0)
  X# = X# + (STEP# * COS(HEADING#))
  Y# = Y# + (STEP# * SIN(HEADING#))
 IF X# < 0 OR X# > SCREEN_W% OR Y# < 0 OR Y# > SCREEN_H% THEN
  SPCLR CALLIDX
 ELSE
  SPVAR CALLIDX, 0,  X#
  SPVAR CALLIDX, 1,  Y#
  SPOFS CALLIDX, X#, Y#
 ENDIF
END
is the function specifically used for updating the bullets' location.

So does this take a number between 0 and 360 and make it move the bullet accordingly? I am bad at math, so I do need a bit of help with this.

SIN() and COS() want radians (0.0 to 2 Pi ~6.28), and SPROT wants degrees (0 to 360). You can convert Radians to Degrees with DEG(radians) and Degrees to Radians with RAD(degrees). I have heading# in radians in the example code. The # is me saying that the number is a floating point number (it has a value after the decimal point).