+atari2600land Posted October 4, 2020 Share Posted October 4, 2020 I'm trying to make a game where Santa is moving down on a bunch of ice floes moving left and right. But sometimes if he lands on one, it acts as though he died. I tried everything and I can't find out why it's happening. If onland=1 that means he successfully landed on a floe and he can move on it left and right (depending on which one he's on). In the code part "ihatethis" (I named it that because I'm frustrated) is the code that happens when he dies, if onland=0. But even though if onland=1, it still does the death code sometimes. WHY IS THIS HAPPENING?! if movingtimer<movingspeed then goto ihatethis movingtimer=0 ice1x=ice1x-1 ice2x=ice2x+1 ice3x=ice3x-1 ice4x=ice4x+1 ice5x=ice5x-1 ice6x=ice6x+1 onland=0 if COL0 and HIT_SPRITE2 then santax=santax-1 : onland=1 if COL0 and HIT_SPRITE3 then santax=santax+1 : onland=1 if COL0 and HIT_SPRITE4 then santax=santax-1 : onland=1 if COL0 and HIT_SPRITE5 then santax=santax+1 : onland=1 if COL0 and HIT_SPRITE6 then santax=santax-1 : onland=1 if COL0 and HIT_SPRITE7 then santax=santax+1 : onland=1 ihatethis: if santay=80 then onland=1 : goto toporbottom if santay=17 then onland=1 : goto toporbottom if onland=0 then VOICE PLAY argh : goto new_life goto main niceice2.bas Quote Link to comment Share on other sites More sharing options...
intvnut Posted October 4, 2020 Share Posted October 4, 2020 Why isn't there an if-statement around this? if onland = 0 then if santay=80 then onland=1 : goto toporbottom if santay=17 then onland=1 : goto toporbottom end if Granted, you will need to move where you set onland = 0 up slightly. Also: Remember hardware collision detection has a one or two frame delay, depending on your perspective. Frame N-1: compute MOB positions for frame N. Frame N: MOBs are displayed, collisions computed. Frame N+1: game gets to see the collisions for positions it computed in frame N-1. I don't know if that factors into your issue as well, since you're combining your current notion of X/Y with the collision information from a previous frame. I haven't looked at the .bas file yet. I don't think my phone lets me do that easily. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted October 4, 2020 Share Posted October 4, 2020 if movingtimer<movingspeed then goto ihatethis This is skipping the collision detection branches entirely when you use the disc to move when the ice isn't moving. I think you meant, if movingtimer<movingspeed then movingtimer=0 ice1x=ice1x-1 ice2x=ice2x+1 ice3x=ice3x-1 ice4x=ice4x+1 ice5x=ice5x-1 ice6x=ice6x+1 end if Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted October 4, 2020 Author Share Posted October 4, 2020 No, once movingtimer equals movingspeed (which is set at 10), then move the ice. But either way it still won't work. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted October 5, 2020 Share Posted October 5, 2020 for line 126, you forgot to add if santay=71 then So the full statement for that line which is different than the quoted above is now, if santay=26 then if COL0 and HIT_SPRITE2 then santax=santax-1 : onland=1 if santay=35 then if COL0 and HIT_SPRITE3 then santax=santax+1 : onland=1 if santay=44 then if COL0 and HIT_SPRITE4 then santax=santax-1 : onland=1 if santay=53 then if COL0 and HIT_SPRITE5 then santax=santax+1 : onland=1 if santay=62 then if COL0 and HIT_SPRITE6 then santax=santax-1 : onland=1 if santay=71 then if COL0 and HIT_SPRITE7 then santax=santax+1 : onland=1 It should work better now. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted October 5, 2020 Author Share Posted October 5, 2020 That didn't help any. Quote Link to comment Share on other sites More sharing options...
Zendocon Posted November 3, 2020 Share Posted November 3, 2020 On 10/5/2020 at 1:33 PM, atari2600land said: That didn't help any. Are you still having trouble with this? I'm looking at this thread now, and I don't see that you've gotten your problem resolved. If you still need help, feel free to upload your recent code, and I'll check it out. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted November 4, 2020 Author Share Posted November 4, 2020 Here. niceice2b.bas Quote Link to comment Share on other sites More sharing options...
Zendocon Posted November 4, 2020 Share Posted November 4, 2020 Okay. I think I fixed the problem. The ice floes are sprites, and you were checking for sprite collision between Santa and the appropriate floe (based on the value of "santay") to decide whether "onland" should equal 0 or 1. The problem has to do with the way the Intellivision flags collision between sprites. @intvnut went into detail about how it works, but the thing to understand is that the Intellivision was originally built to utililze something called Executive ROM. The "Exec" ran in a loop 3 video frames in length. That is why early games had a framerate no greater than 20. It also meant that for the two video frames after a collision actually happened, the collision flags wouldn't always be accurate; but by the third frame (when it would matter), they would be. Since you retain variables for the x positions of Santa and the floes, and since the floes move horizontally, I replaced the hardware collision detection with a little math to find out whether the relative x positions were within what I called "tolerance". At the top of the code, in line 2, just before "VOICE INIT", I added this line: CONST TOLERANCE = 7 That way, you can easily lower the value of TOLERANCE if you want a greater challenge. The second thing I did was comment out the seven lines of code before your "ihatethis" label: 'onland=0 'if santay=26 then if COL0 and HIT_SPRITE2 then santax=santax-1 : onland=1 'if santay=35 then if COL0 and HIT_SPRITE3 then santax=santax+1 : onland=1 'if santay=44 then if COL0 and HIT_SPRITE4 then santax=santax-1 : onland=1 'if santay=53 then if COL0 and HIT_SPRITE5 then santax=santax+1 : onland=1 'if santay=62 then if COL0 and HIT_SPRITE6 then santax=santax-1 : onland=1 'if santay=71 then if COL0 and HIT_SPRITE7 then santax=santax+1 : onland=1 and I added this block of code to replace it, before "ihatethis": IF santay = 26 THEN santax = santax - 1 onland = (ABS(santax - ice1x) <= TOLERANCE) ELSEIF santay = 35 THEN santax = santax + 1 onland = (ABS(santax - ice2x) <= TOLERANCE) ELSEIF santay = 44 THEN santax = santax - 1 onland = (ABS(santax - ice3x) <= TOLERANCE) ELSEIF santay = 53 THEN santax = santax + 1 onland = (ABS(santax - ice4x) <= TOLERANCE) ELSEIF santay = 62 THEN santax = santax - 1 onland = (ABS(santax - ice5x) <= TOLERANCE) ELSEIF santay = 71 THEN santax = santax + 1 onland = (ABS(santax - ice6x) <= TOLERANCE) END IF To understand setting the value of "onland", note it's a Boolean (true or false) expression encapsulated in parentheses. If the expression evaluates to False, then onland will equal 0. If true, onland will be nonzero. Because you have a line of code within "ihatethis" that checks to see if onland = 0, this works just fine. The Boolean expression itself is a Math formula to get the absolute value of the difference between the x positions of Santa and the floe he should be standing on. If the difference is within tolerance, then you're standing on land. If you need more help, just let us know. 1 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted November 5, 2020 Author Share Posted November 5, 2020 That worked! Thank you so much. 2 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.