Hello i have been reading things on forum and they have been helpful. And i managed to create this half done basic 2D game, and i need some help as i am now stuck. I is pong or what ever it is called, i am just stuck on how i would make the circle bounce around off things. Code is bellow, the arros and number pad keys control the moving bars. Kinda messy i think but i am new. If you got any tips then please share
Rem ***********************
Rem Game Created by Shane Rutter
Rem ***********************
Gosub Setup
Rem Bar One Start Positions
TopX = 28
TopY = 363
BottomX = 50
BottomY = 450
Rem Bar Two Start Positions
TopX2 = 974
TopY2 = 363
BottomX2 = 996
BottomY2 = 450
Rem Circle Start Positions
CircleX = 505
CircleY = 400
CircleSize = 20
Rem Speeds
CircleSpeed = 3
Bar1Speed = 3
Bar2Speed = 3
Do
Rem Screen Clear and Background Colour
CLS RGB(0,0,0)
Rem Coords
INK RGB(255,0,0),RGB(0,0,0)
Text 5,5,\"Mouse X: \"+Str$(MouseX())
Text 5,20,\"Mouse Y: \"+Str$(MouseY())
Text 250,5,\"Code: \"+str$(scancode())
Rem Far Backgound Square
INK RGB(100,0,0),RGB(0,0,0)
Box 5,40,1020,760
Rem Second Background Square
INK RGB(0,100,0),RGB(0,0,0)
Box 25,60,1000,740
Rem Table Markings
INK RGB(0,0,0),RGB(0,0,0)
Box 500,64,510,736
Rem Ball
INK RGB(255,0,0),RGB(0,0,0)
CIRCLE CircleX,CircleY,CircleSize
Rem Bar One
INK RGB(100,100,100),RGB(0,0,0)
Box TopX, TopY, BottomX, BottomY
Rem Bar Two
INK RGB(100,100,100),RGB(0,0,0)
Box TopX2, TopY2, BottomX2, BottomY2
Rem Bar One Movement Control
If UpKey() = 1 then TopY = TopY-Bar1Speed; BottomY = BottomY-Bar1Speed
If DownKey() = 1 then TopY = TopY+Bar1Speed; BottomY = BottomY+Bar1Speed
If RightKey() = 1 then TopX = TopX+Bar1Speed; BottomX = BottomX+Bar1Speed
If LeftKey() = 1 then TopX = TopX-Bar1Speed; BottomX = BottomX-Bar1Speed
Rem Bar Two Movement Control
If Keystate(72) = 1 then TopY2 = TopY2-Bar2Speed; BottomY2 = BottomY2-Bar2Speed
If Keystate(76) = 1 then TopY2 = TopY2+Bar2Speed; BottomY2 = BottomY2+Bar2Speed
If Keystate(75) = 1 then TopX2 = TopX2-Bar2Speed; BottomX2 = BottomX2-Bar2Speed
If Keystate(77) = 1 then TopX2 = TopX2+Bar2Speed; BottomX2 = BottomX2+Bar2Speed
Rem Bar One Checks
If TopY =< 64 then TopY = 64; BottomY = 151
If BottomY => 736 then BottomY = 736; TopY = 650
If TopX =< 29 then TopX = 29; BottomX = 50
If BottomX => 996 then BottomX = 996; TopX =974
If BottomX => 497 then BottomX = 497; TopX = 476
Rem Bar Two Checks
If TopY2 =< 64 then TopY2 = 64; BottomY2 = 151
If BottomY2 => 736 then BottomY2 = 736; TopY2 = 650
If TopX2 =< 29 then TopX2 = 29; BottomX2 = 50
If BottomX2 => 996 then BottomX2 = 996; TopX2 =974
If TopX2 =< 515 then TopX2 = 515; BottomX2 = 535
Loop
End
Rem ***********************
Rem List of subroutines start here
Rem ***********************
Setup:
Set Display Mode 1024,768,32
Sync Rate 60
Return
Rem *********************
Rem List of functions start here
Rem *********************
RapidZ - http://thecomputerhideout.com