Uber-Pong, a result of boredom!™
---------------------------------------------
I decided to do something productive yesterday, heres the end result. I don't often program but I opened bm and started screwing around with stuff. While there is no scoring and no way to win or lose its a great tease for those 40+'s - because the ai moves as fast as the ball making scoring impossible, but human reaction time makes it possible for the ai to score against you :P anyway I had fun making it so thats all I care...
Heres the code to comment on or to steal and claim as your own.
---------------------------------------------
I decided to do something productive yesterday, heres the end result. I don't often program but I opened bm and started screwing around with stuff. While there is no scoring and no way to win or lose its a great tease for those 40+'s - because the ai moves as fast as the ball making scoring impossible, but human reaction time makes it possible for the ai to score against you :P anyway I had fun making it so thats all I care...
Heres the code to comment on or to steal and claim as your own.
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' ' Uber-Pong, created by Uber-nerd, while trying to achieve nothing in particular. ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' Graphics 640,480,32,60,1 'set player 1's stuff and player 2's stuff (the a.i.) Global p1x=640/2-40/2,p1y=480-10,p2x=640/2-40/2,p2y=0,diff 'set ball stuff Global bx=640/2,by=50,bxs=Rand(-4,4),bys=Rand(1,4) #bobtwo bxs=Rand(-4,4) bys=Rand(1,4) bx=640/2 by=50 If bxs>-2 And bxs<2 bxs=Rand(-4,4) Goto bobtwo EndIf '???---------------------------------------------------------------------------------???' While Not KeyHit(key_escape) HideMouse SeedRnd MilliSecs() '---------------------------------------------------------------------------------------' 'draw stuff SetColor 0,255,0 DrawRect p1x,p1y,40,10 DrawRect p2x,p2y,40,10 SetColor 0,0,255 DrawOval bx,by,10,10 '---------------------------------------------------------------------------------------' 'move the ball bx=bx+bxs by=by+bys #bob 'check to see if the ball is lost If by>480 Or by<0-10 bxs=Rand(-4,4) bys=Rand(1,4) bx=640/2 by=50 SetColor 255,0,0 DrawText "BALL RESET",640/2-40,480/2-30 p1x=640/2-40/2 p1y=480-10 Flip Delay 2000 EndIf If bxs>-2 And bxs<2 bxs=Rand(-4,4) Goto bob EndIf '---------------------------------------------------------------------------------------' '---------------------------------------------------------------------------------------' 'do a.i. diff=p2x-bx If diff>-9 And diff<9 Goto skip If p2x<bx p2x=p2x+4 If p2x>bx p2x=p2x-4 #skip '---------------------------------------------------------------------------------------' '---------------------------------------------------------------------------------------' 'make walls deflect the ball If bx<0 bxs=4 If bx>640-10 bxs=-4 'get player input If KeyDown(key_left) p1x=p1x-4 If KeyDown(key_right) p1x=p1x+4 '---------------------------------------------------------------------------------------' If by>30 And by<480-30 Goto skipcollisions '---------------------------------------------------------------------------------------' CollideRect p1x,p1y,40,1,0,5 If CollideRect (bx,by,10,10,5,0) bys=-4 ResetCollisions(0) CollideRect p2x,p2y,40,p2y+9,0,6 If CollideRect (bx,by,40,10,6,0) bys=4 ResetCollisions(0) '---------------------------------------------------------------------------------------' #skipcollisions '---------------------------------------------------------------------------------------' Flip Cls Wend End