+Random Terrain Posted July 30, 2017 Share Posted July 30, 2017 . . . although I'm still using the older BB, I think. Not 100% sure. There's a good way to know for sure: randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted July 30, 2017 Author Share Posted July 30, 2017 (edited) Looking at the dates of the executables, it seems I am. Got some headway with the collision code, here's the source so far. The new code is only in the red paddle. EDIT: Fixed the ball clipping thru the non-moving paddle, but the issue still persists where the ball will clip through the paddle and receive its impulse if the paddle is moving in the same direction as the ball. Attached the updated code. Here's the collsion part: rem ------------------------ rem collision rem ------------------------ rem ----RED PADDLE COLLISION---- if !collision(player0,ball) || bCollsn then goto _skip_P0_B_col AUDF1 = 4 - bvy AUDV1 = 15 bCollsn = 1 tmp = 0 if ballx > player0x - 3 && ballx < player0x + 7 then xClip = 1 if bally > player0y - 3 && bally < player0y + 7 then yClip = 1 if xClip && yClip then xyClip = 1 _skip_ball_knock_back rem if the player isnt moving, reverse movement, otherwise copy its direction if bMoveLf then bMoveRt = 1 : bMoveLf = 0 : goto _skip_to_b_p0_vmotn if bMoveRt then bMoveRt = 0 : bMoveLf = 1 _skip_to_b_p0_vmotn if bMoveUp then bMoveUp = 0 : bMoveDn = 1 : goto _skip_b_rev_p0 if bMoveDn then bMoveUp = 1 : bMoveDn = 0 _skip_b_rev_p0 if p0_x = 0 then goto _skip_to_p0_yCol if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt _skip_to_p0_yCol if p0_y = 0 then goto _skip_to_bVel_accumulation if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn ;if temp6 > 0 then goto _skip_b_rev_p0 _skip_to_bVel_accumulation bvx = bvx + p0_x + p0_x bvy = bvy + p0_y + p0_y airhockey.bas airhockey_7-30-2017.bas Edited July 31, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) I still can't figure out for the life of me why the ball still clips through the paddle when they're both moving the same direction, so somehow it's skipping the goto statements. Also for some reason, changing this: if p0_x = 0 then goto _skip_to_p0_yCol if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt _skip_to_p0_yCol if p0_y = 0 then goto _skip_to_bVel_accumulation if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn To this: if p0_mv_Lf = 0 && p0_mv_Rt = 0 then goto _skip_to_p0_yCol if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt _skip_to_p0_yCol if p0_mv_Up = 0 && p0_mv_Dn = 0 then goto _skip_to_bVel_accumulation if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn It won't compile due to some sort of syntax error.Wut? airhockey.bas Edited August 1, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 1, 2017 Share Posted August 1, 2017 If that is the exact code, looks like the first line isn't indented. Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 1, 2017 Author Share Posted August 1, 2017 If that is the exact code, looks like the first line isn't indented. It's actually indented in the code, I just copied it from the indent on. Updated the post and added source file. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 1, 2017 Share Posted August 1, 2017 I see one problem right away. You are using NOT with OR in the same if…then. I always use this chart because I can't remember what is and isn't allowed: randomterrain.com/atari-2600-memories-batari-basic-commands.html#if Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 1, 2017 Share Posted August 1, 2017 Found another problem. Since you are using def with bit operations without using names that point out that they are bits instead of regular variables, it's impossible to know what is going on. Here's an example: if p0_mv_Lf = 0 && p0_mv_Rt = 0 then goto _skip_to_p0_yCol People looking at your code won't know that p0_mv_Lf and p0_mv_Rt are using bits instead of variables without memorizing all of your DEFs and nobody is going to have the time to do that. Using something like _Bit_p0_mv_Lf and _Bit_p0_mv_Rt would let people know that they are bits. And knowing that, we could tell you that bit operations do not use an equal sign in if…then statements: randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit You should be doing this instead: if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) Found another problem. Since you are using def with bit operations without using names that point out that they are bits instead of regular variables, it's impossible to know what is going on. Here's an example: if p0_mv_Lf = 0 && p0_mv_Rt = 0 then goto _skip_to_p0_yCol People looking at your code won't know that p0_mv_Lf and p0_mv_Rt are using bits instead of variables without memorizing all of your DEFs and nobody is going to have the time to do that. Using something like _Bit_p0_mv_Lf and _Bit_p0_mv_Rt would let people know that they are bits. And knowing that, we could tell you that bit operations do not use an equal sign in if…then statements: randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit Good to know, I'll have to update that. You should be doing this instead: if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol Changed it to that, still won't compile Edited August 1, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 1, 2017 Share Posted August 1, 2017 Changed it to that, still won't compile See if this works: airhockey_2017y_08m_01d_0316t.bas Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) Yours seems to compile, but when I copy your collision code into mine, it doesn't, even after changing xy_Clip back to xyClip. What all did you change? Also I can keep the if lines as: if p0_x = 0 then... as p0_x would be zero if the joystick hasn't been moved left or right. Same for p0_y. I was just seeing if it made any difference with the clipping, but it doesn't :\ Could it be due to these lines? if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol and if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation Edited August 2, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 2, 2017 Share Posted August 2, 2017 I changed this: def xClip = boolean{0} def yClip = boolean{1} def xyClip = boolean{2} def bMoveRt = boolean{3} def bMoveLf = boolean{4} def bMoveUp = boolean{5} def bMoveDn = boolean{6} def bCollsn = boolean{7} p = 0 dim boolean1 = p def p0_mv_Lf = boolean1{0} def p0_mv_Rt = boolean1{1} def p0_mv_Up = boolean1{2} def p0_mv_Dn = boolean1{3} def p1_mv_Lf = boolean1{4} def p1_mv_Rt = boolean1{5} def p1_mv_Up = boolean1{6} def p1_mv_Dn = boolean1{7} to this: def xClip=boolean{0} def yClip=boolean{1} def xy_Clip=boolean{2} def bMoveRt=boolean{3} def bMoveLf=boolean{4} def bMoveUp=boolean{5} def bMoveDn=boolean{6} def bCollsn=boolean{7} p = 0 dim boolean1 = p def p0_mv_Lf=boolean1{0} def p0_mv_Rt=boolean1{1} def p0_mv_Up=boolean1{2} def p0_mv_Dn=boolean1{3} def p1_mv_Lf=boolean1{4} def p1_mv_Rt=boolean1{5} def p1_mv_Up=boolean1{6} def p1_mv_Dn=boolean1{7} You can't use yClip and xyClip since xyClip contains the string yClip. The program won't compile. I also got rid of the spaces around the equals sign since def won't work correctly with spaces around the equals sign for some strange reason.I changed this: if !collision(player0,ball) || bCollsn then goto _skip_P0_B_col to this: if !collision(player0,ball) then goto _skip_P0_B_col if bCollsn then goto _skip_P0_B_col You can't use NOT with OR.I changed this: if xClip && yClip then xyClip = 1 to this: if xClip && yClip then xy_Clip = 1 Strings used with def must be different from each other or you will get strange errors. For example, if you used _PullMyLeg, you couldn't use Pull or My or Leg as def strings. I changed this: if p0_mv_Lf = 0 && p0_mv_Rt = 0 then goto _skip_to_p0_yCol to this: if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol Bit operations do not use an equal sign in if…then statements.I changed this: if p0_mv_Up = 0 && p0_mv_Dn = 0 then goto _skip_to_bVel_accumulation to this: if !p0_mv_Up && !p0_mv_Dn then goto _skip_to_bVel_accumulation Bit operations do not use an equal sign in if…then statements.I changed this: if !collision(player1,ball) || bCollsn then goto _skip_P1_B_col to this: if !collision(player1,ball) then goto _skip_P1_B_col if bCollsn then goto _skip_P1_B_col You can't use NOT with OR. 1 Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 2, 2017 Author Share Posted August 2, 2017 Thanks for all your help so far, man! I'm learning a lot here. Quote Link to comment Share on other sites More sharing options...
Neuronic Posted August 3, 2017 Share Posted August 3, 2017 Thanks for all your help so far, man! I'm learning a lot here. Me too! Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 4, 2017 Author Share Posted August 4, 2017 (edited) So I have 540 bytes left for my program to not only fix the clipping issue, but also implement collisions that move the ball in more directions than just the reverse of what it was doing, not to mention copy that over to player1. I REALLY wanna fix the clipping issue as it's kind of a game-breaker in some regards. I think I'd be able to implement the other things though. EDIT: I started working on some code to move the ball back to where it would hit the paddle between its last position and current position, and I'm trying to figure out how to move it so that it's only touching the paddle, and I think this could not only prevent the clipping issue, but also aid in determining what direction to ricochet in. I need to figure out what formula I can use to determine where to put the ball based on: Ball's direction Ball's current position Ball's previous position Ball's size(4 by 4) Player's position Player's size(8 by 8 )Here's what I have so far, and no, it doesn't work right, but it's a start I guess.: ; BEGIN CONTEXT rem ----RED PADDLE COLLISION---- if !collision(player0,ball) then goto _skip_P0_B_col if bCollsn then goto _skip_P0_B_col AUDF1 = 4 - bvy AUDV1 = 15 bCollsn = 1 tmp = 0 if ballx > player0x - 3 && ballx < player0x + 7 then xClip = 1 if bally > player0y - 3 && bally < player0y + 7 then yClip = 1 if xClip && yClip then xy_Clip = 1 temp6 = 0 : temp5 = 0 ; END CONTEXT ; HERE'S THE KNOCKBACK CODE if !xClip then _skip_offset_horizontal temp6 = ballx - player0x if !bMoveRt then _skip_offset_lf temp5 = temp6 + 4 ballx = ballx - temp5 _skip_offset_lf if !bMoveLf then _skip_offset_horizontal temp5 = 8 - temp6 ballx = ballx + temp5 temp6 = 0 : temp5 = 0 _skip_offset_horizontal if !yClip then _skip_offset_vertical temp6 = ballx - player0y if !bMoveUp then _skip_offset_up temp5 = temp6 + 4 bally = bally - temp5 _skip_offset_up if !bMoveDn then _skip_offset_vertical temp5 = 8 - temp6 bally = bally + temp5 _skip_offset_vertical _skip_ball_knock_back I've included the game source as well. airhockey.bas Edited August 4, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 5, 2017 Share Posted August 5, 2017 Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that. Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 5, 2017 Author Share Posted August 5, 2017 (edited) Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that. It's cool dude, I was asking help from anyone who could and was not expecting you to feel obligated to helping me. Thanks for all your help so far and good luck with your pancreas. https://www.youtube.com/watch?v=tqDBB0no6dQ Edited August 5, 2017 by 8-bit_d-boy 1 Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted August 5, 2017 Share Posted August 5, 2017 Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that.Wow, I hope you feel better soon. 2 Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 6, 2017 Author Share Posted August 6, 2017 More compilation issues (yayyy). So in order to move the ball up until it collides with the paddle and no more, I modified this: if scoring <> 61 then _skip_ball_movment pbx = ballx if bMoveLf then ballx = ballx - bvx if bMoveRt then ballx = ballx + bvx pby = bally if bMoveUp then bally = bally - bvy if bMoveDn then bally = bally + bvy _skip_ball_movment to this: temp6 = bvx + bvy if bvx > bvy then temp5 = bvx / bvy : temp4 = bvy else temp5 = bvy / bvx : temp4 = bvx if scoring <> 61 then _skip_ball_movment pbx = ballx for temp3 = 0 to temp4 temp2 = temp3 // temp4 if temp2 = 0 then if bvx > bvy then bally = bally + 1 : if bvy > bvx then ballx = ballx + 1 if temp2 <> 0 then if bvx > bvy then ballx = ballx + 1 : if bvy > bvx then bally = bally + 1 if collision(player0, ball) || collision(player1, ball) then temp3 = temp4 next if bMoveLf then ballx = ballx - bvx if bMoveRt then ballx = ballx + bvx pby = bally if bMoveUp then bally = bally - bvy if bMoveDn then bally = bally + bvy _skip_ball_movment and it won't compile now, stating: --- Unresolved Symbol List div8 0000 ???? (R ) 425 bytes of ROM space left C:\Users\chris\atari\airHockey\air hockey\airhockey.bas.asm (3435): error: Branch out of range (138 bytes). Fatal assembly error: Source is not resolvable. Errors were encountered during assembly. Progress, I guess. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 6, 2017 Share Posted August 6, 2017 Why are you using // instead of /? http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#division Quote Link to comment Share on other sites More sharing options...
+Karl G Posted August 6, 2017 Share Posted August 6, 2017 For division operations involving anything other than powers of two, you will need to add a module to allow for this: "include div_mul.asm" Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 6, 2017 Author Share Posted August 6, 2017 (edited) I forgot to mention, I was trying to get the remainder with the // operator. EDIT: Attached current code. airhockey.bas Edited August 8, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
8-bit_d-boy Posted August 14, 2017 Author Share Posted August 14, 2017 (edited) Is it possible to do a modulus operation without the advanced math modules? I can't get them working in my code. Haven't touched it in a while. I'm trying to make it so that when the ball collides with the paddle, it stays outside of it to make determining the direction it reflects in easier. Edited August 14, 2017 by 8-bit_d-boy Quote Link to comment Share on other sites More sharing options...
+Karl G Posted August 14, 2017 Share Posted August 14, 2017 I didn't have much luck getting the modulus with the // operator, either, but I changed how I did it, and didn't look into it deeply at the time. Maybe it would be good to test it with a small test program that's easier to debug. Quote Link to comment Share on other sites More sharing options...
+5-11under Posted August 14, 2017 Share Posted August 14, 2017 Posting here to keep an eye on the thread. Looks interesting and you had me at "hockey" It looks like a classic Leafs versus Habs game. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted August 14, 2017 Share Posted August 14, 2017 For reflection code, I wonder if it would be helpful to keep track of the previous positions of both the ball and the paddle? That way if the ball hits the paddle and the paddle hasn't moved, then you could have the ball reflect on the opposite direction that it came from. Otherwise, if the paddle hits the ball, then have the ball jump back in the direction that the paddle is going. It's not perfect physics, but it may be a decent starting point? Maybe others will have better ideas on how to compute this in a more realistic way. 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.