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.

2D All the way! / Sprite Collision Help

Author
Message
Cypher Hax0r
22
Years of Service
User Offline
Joined: 16th Dec 2003
Location: Toilet
Posted: 28th Apr 2004 23:33 Edited at: 28th Apr 2004 23:36
I am making a simple pong game but i do not know how to use the colission command to stop the user from going higher then the screen, i have put two white lines on both sides of the screen and thought that the code would be if sprite collision (1,3) then y=y but it doesnt seem to work, help would be appreciated.

Jaack
22
Years of Service
User Offline
Joined: 25th Apr 2004
Location: London
Posted: 28th Apr 2004 23:49
Your best bet is not to use sprite collisions, but a directional variable.

For example. Let the Ball's coords be x,y.

Then create two more variables like XX and YY to handle the direction of the ball. EG:

X=100 `X ball co-ord
Y=100 `Y ball co-ord
XX=1 `X ball direction
YY=1 `Y ball direction

do
cls

sprite 1,x,y,1 `your ball sprite
let x=x+xx `move ball in current direction
let y=y+yy

if x<1 then xx=1 `check ball at left of screen and move in opp dir
if x>799 then xx=-1 `check ball at right and move in opp dir
if y>599 then yy=-1 `check ball at bottom and move up
if y<1 then yy=1 ` check ball at top and move it down
loop

Is the kind of thing you're after.

Jack.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 28th Apr 2004 23:50 Edited at: 28th Apr 2004 23:51
You don't need any collision commands for this. Just check if Y < 1
and check if Y> screen height-1.

Cypher Hax0r
22
Years of Service
User Offline
Joined: 16th Dec 2003
Location: Toilet
Posted: 29th Apr 2004 00:04
it wont let me change the screen height saying theres a command error (DBPRO by the way) the screen height is 480 while Y=475
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 29th Apr 2004 02:45
You change the ball height during play.

If you want to change the screen height......

set display mode 800,600,16


It has to be a height that a monitor can display. But I think you missed the point that you check the ball height not the screen height.

Login to post a reply

Server time is: 2026-06-09 15:43:25
Your offset time is: 2026-06-09 15:43:25