Retro Lord Posted June 26, 2015 Share Posted June 26, 2015 I'm having a bit of trouble with the ball movement in a pong game. I've set the ball movement up like this and it just gets stuck in the wall. There must be a better way? rem pushing the button starts the balls movement if a=0 && joy0fire then a=1 rem ball going up and left if a=1 then ballx=ballx-1 : bally=bally-1 rem ball going up and right if a=2 then ballx=ballx+1 : bally=bally-1 rem ball going down and left if a=3 then ballx=ballx-1 : bally=bally+1 rem ball going down and right if a=4 then ballx=ballx+1 : bally=bally+1 if collision(ball,playfield) && a=1 then a=3 if collision(ball,playfield) && a=2 then a=4 if collision(ball,playfield) && a=3 then a=4 if collision(ball,playfield) && a=4 then a=5 Entire code: set kernel_options no_blank_lines player1x=85 player1y=80 player0x=85 player0y=70 ballx=85 : bally=30 main playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X end player0: %11111111 %00000000 %00000000 %00000000 %00000000 %00000000 %00000000 %00000000 end player1: %11111111 %00000000 %00000000 %00000000 %00000000 %00000000 %00000000 %00000000 end COLUPF=$0E COLUP0=$0E COLUP1=$0E NUSIZ0=$30 NUSIZ1=$30 ballheight = 2 : rem * Ball 4 pixels high. CTRLPF = $21 : rem * Ball 4 pixels wide. drawscreen if a=0 && joy0fire then a=1 rem ball going up and left if a=1 then ballx=ballx-1 : bally=bally-1 rem ball going up and right if a=2 then ballx=ballx+1 : bally=bally-1 rem ball going down and left if a=3 then ballx=ballx-1 : bally=bally+1 rem ball going down and right if a=4 then ballx=ballx+1 : bally=bally+1 if collision(ball,playfield) && a=1 then a=3 if collision(ball,playfield) && a=2 then a=4 if collision(ball,playfield) && a=3 then a=4 if collision(ball,playfield) && a=4 then a=5 if joy0left then player0x=player0x-1 if joy0right then player0x=player0x+1 if joy1left then player1x=player1x-1 if joy1right then player1x=player1x+1 goto main Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted June 26, 2015 Author Share Posted June 26, 2015 Got it working with the playfield now but it's a bit wonky when it comes to hitting the paddles, any pointers or ideas? if a=0 && joy0fire then a=1 rem ball going up and left if a=1 then ballx=ballx-1 : bally=bally-1 rem ball going up and right if a=2 then ballx=ballx+1 : bally=bally-1 rem ball going down and left if a=3 then ballx=ballx-1 : bally=bally+1 rem ball going down and right if a=4 then ballx=ballx+1 : bally=bally+1 if bally=10 && a=1 then a=3 if bally=10 && a=2 then a=4 if ballx<20 && a=3 then a=4 if ballx<20 && a=1 then a=2 if ballx>120 && a=2 then a=1 if ballx>120 && a=4 then a=3 if collision(ball,player0) && a=3 then a=2 if collision(ball,player0) && a=4 then a=1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted June 26, 2015 Share Posted June 26, 2015 Have you looked at this program: atariage.com/forums/topic/211497-chipoff-breakout-style-example-program/ Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted June 27, 2015 Author Share Posted June 27, 2015 I'll check it out Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted June 27, 2015 Author Share Posted June 27, 2015 Okay! That cleared a lot of things up for me, I got ball movement and hit detection up and running perfectly. But I have yet another question about scoring with 2 players. I want 2 separate scores, one on the left side and one on the right side both starting at 0, and if respective player scores a point their score goes up. The only way I figured out how to do it is with sprite flicker and a counter, but that would take a little to much memory for my taste. Is there a better aproach to this? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted June 27, 2015 Share Posted June 27, 2015 See if this is helpful: randomterrain.com/atari-2600-memories-batari-basic-commands.html#playerscores_minikernel Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted June 27, 2015 Author Share Posted June 27, 2015 Thank you, that minikernel was a lifesaver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.