DevBR Posted February 14 Share Posted February 14 (edited) I'm setting up a labyrinth where the player (ball) must travel through a labyrinth, respecting the Playfield limit.  It is working, however, when it touches the Playfield, it stops when it should actually slide against the Playfield. 😔  Attached is the full source code, just put it in Batari and run it to identify what I said.  Could anyone give me an idea of how to change the source code to make the BALL slide on the playfield?  Below is a brief explanation of the code: Depending on the movement of the Joystick, I will move the Ball to the desired destination and put 1 in a variable that moved to that side (for example, if it went DOWN, then d = 1). Then I will test the collision of the BALL with the PLAYFIELD, if it is true, I see which variable has the value 1 and return the BALL to the previous position.  loop if collision(playfield,ball) && d = 1 then bally = bally - 1: d = 0 if collision(playfield,ball) && r = 1 then ballx = ballx - 1: r = 0 if collision(playfield,ball) && l = 1 then ballx = ballx + 1: l = 0 if collision(playfield,ball) && u = 1 then bally = bally + 1: u = 0 if joy0down then bally = bally + 1: d = 1 if joy0right then ballx = ballx + 1: r = 1 if joy0left then ballx = ballx - 1: l = 1 if joy0up then bally = bally - 1: u = 1 drawscreen goto loop  lab_better.bas  Edited February 14 by DevBR Two uploaded files Quote Link to comment https://forums.atariage.com/topic/361318-moving-a-ball-respecting-collision-with-the-playfield/ Share on other sites More sharing options...
DevBR Posted February 15 Author Share Posted February 15 Hello, I discovered a way to make the movement I needed. I debugged the Adventure game and found that the movement occurred in 1 frame and the next two frames were collision tests. Thanks! Quote Link to comment https://forums.atariage.com/topic/361318-moving-a-ball-respecting-collision-with-the-playfield/#findComment-5410922 Share on other sites More sharing options...
+Random Terrain Posted February 15 Share Posted February 15 Remember that you can do just one "collision(playfield,ball)" check to save cycles. Â Something like if !collision(playfield,ball) then goto _Skip_Collision_PF_Ball" then have your other checks sandwiched in there. Quote Link to comment https://forums.atariage.com/topic/361318-moving-a-ball-respecting-collision-with-the-playfield/#findComment-5411010 Share on other sites More sharing options...
DevBR Posted February 15 Author Share Posted February 15 4 hours ago, Random Terrain said: Remember that you can do just one "collision(playfield,ball)" check to save cycles. Â Something like if !collision(playfield,ball) then goto _Skip_Collision_PF_Ball" then have your other checks sandwiched in there. Hi Random Terrain, Â Thank you very much for your tip. I did not know that. Â I discovered that the collision does not change the value in the same cycle (frame) only when I started the Debug on Adventure on Stella emulator. Â I appreciate your help! Â Best Regards. 1 Quote Link to comment https://forums.atariage.com/topic/361318-moving-a-ball-respecting-collision-with-the-playfield/#findComment-5411085 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.