@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..)
Making a shooting game.
Root / Programming Questions / [.]
FinnowCreated:
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.
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 ENDis the function specifically used for updating the bullets' location.
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).