Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Why does this code not move the ball

Author
Message
sgalland
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 21st Nov 2002 08:24
I wrote code to move my ball (I keep changing it because using true vector code causes sprites to flash) and the ball won't move, but rather stay in the left corner and go left and right really fast. Any ideas are appreciated!

MoveBall:
REM Detect Paddle hitting the ball
IF SPRITE HIT(2,1) = 0
YDIRECTION = YDIRECTION * -1
ENDIF
REM Detect the ball leaving the screen over the x axis
IF BALLX > (SCREEN WIDTH() - BALLXBOTTOM) OR BALLX (SCREEN HEIGHT() - BALLYBOTTOM) OR BALLY
ToXic
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Australia
Posted: 21st Nov 2002 10:52
This will move your ball if no collision is detected.

REM Detect Paddle hitting the ball
IF SPRITE HIT(2,1) = 0

REM Should be something like.

S=SPRITE HIT(2,0)
If S=1 Then Whatever
If S=11 Then Whatever
If S=>0 and s<10 Then Whatever


Here is a simple pong game using sprites.

Hope this helps.

ToXic.

sgalland
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 21st Nov 2002 11:17
OK one more question, when my paddle moves it leaves trails of its image on the screen. How do you get rid of that, I have both the sync command and cls 0 there to rid the screen of junk and I have no idea why it wont go away.
Bogboy2000
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 21st Nov 2002 13:19
if your useing sprites which it looks like you are try useing the "set sprite" command

Login to post a reply

Server time is: 2024-03-28 10:18:56
Your offset time is: 2024-03-28 10:18:56