Thanks for the suggestions.
@baxslash That sounds like a great idea but...
How do I make my sprite move according to an angle?
at the moment my code looks like this....
REMSTART
**********
*BREAKOUT*
**********
REMEND
rem hide the mouse set up sync etc etc etc
backdrop off:autocam off:hide mouse:sync on:sync rate 0
rem simple start screen
menu:
cls
sync
center text 320,240,"BREAKOUT"
center text 318,260,"PRESS A KEY"
sync
suspend for key
null = make vector2(1)
start:
rem draw the bat
box 0,0,50,10
get image 1,0,0,50,10
sprite 1,0,0,1
offset sprite 1, sprite width(1)/2.0, sprite height(1)/2.0
rem position the bat
sprite 1,435,440,1
rem draw the ball
box 0,0,10,10
get image 2,0,0,10,10
cls
rem position the ball
sprite 2,320,240,2
offset sprite 2, sprite width(2)/2.0, sprite height(2)/2.0
REMSTART
this set a direction for the ball to move in
this gives the same bounce pattern every tine
I could make the x angle different every time
by varing the x speed for a different angle but this
would make the player struggle to hit the ball
on the first shot and besides it doesn't accomplish what
I want to do.
REMEND
nx# = 2 : ny# = 3
set vector2 1,nx#, ny# : normalize vector2 1, 1
nx# = x vector2(1) : ny# = y vector2(1)
bx# = 0 : by# = 0
x=435
rem main loop
do
rem turn on the background
backdrop on
rem sraw the screen
sync
rem check for keyboard input. check spritre is not at the edge of the screen if ok move bat
x = x + rightkey() - leftkey()
if x < 25 then x = 25
if x > screen width() - 25 then x = screen width() - 25
sprite 1,x,440,1
rem collision detection for the bat and ball
if sprite hit (2,1) then nx# = nx#*1:ny# = ny#*-1
rem collision detection fot the edge of the screen
if sprite x(2) < 10 or sprite x(2) > 630 then ny# = ny#*1:nx# = nx#*-1
if sprite y(2) < 10 then ny# = ny#*-1:nx# = nx#*1
rem the following line starts the game again if the ball goes past the bat.
if sprite y(2) > 480 then center text 320,240,"YOU LOST PRESS A KEY":sync:suspend for key:goto start:
rem move the ball
bx# = (bx# + nx#) : by# = (by# + ny#)
sprite 2, 320+bx#, 240+by#, 2
if sprite collision (2,1)
rem I will add some code here in future feature implementations
rem such as making the ball stick to the bat or triggering SFX etc.
rem or working out the new angle of the ball.....
endif
loop
As you can see the 'angle' of the ball is currently determined
by the x and y speed.
Would I be able to apply my new angle to this or would I be better off re writing the code?
Sorry to be asking such basic questions.
I don't want someone to write the code for me, if you could just point me in the right direction I'm sure I will learn more by figuring the rest of it out.
Thanks again,
Paul.