Words Fail Posted February 5, 2023 Share Posted February 5, 2023 (edited) So I've made a speed up routine.. there will be 4 speeds scoring 50, 60, 70, 80, and 100 points. Starts off as speed=1. My joystick checks if you're pressing fire and direction and goes to a routine to increase speed or if you're not pressing fire then decrease speed. Routine if you're pressing fire button and if not.. joycheck if joy0fire && joy0up then gosub shipup bank4: dir=1: goto speedcheckfire bank3 if joy0fire && joy0right then gosub shipright bank4: dir=2: goto speedcheckfire bank3 if joy0fire && joy0down then gosub shipdown bank4: dir=3: goto speedcheckfire bank3 if joy0fire && joy0left then gosub shipleft bank4: dir=4: goto speedcheckfire bank3 if !joy0fire && joy0up then gosub shipup bank4: dir=1: goto speedchecknofire bank3 if !joy0fire && joy0right then gosub shipright bank4: dir=2: goto speedchecknofire bank3 if !joy0fire && joy0down then gosub shipdown bank4: dir=3: goto speedchecknofire bank3 if !joy0fire && joy0left then gosub shipleft bank4: dir=4: goto speedchecknofire bank3 So basically draws shipleft image, let's program know which direction you're moving, then goes to one of the routines: speedcheckfire speed=speed+1 if speed>50 then speed=50 goto joycheck2 bank2 speedchecknofire speed=speed-10 if speed<1 then speed=1 goto joycheck2 bank2 Not pressing the button decreases speed by 10 because you brake faster than accelerate. joycheck2 goes to the routine that actually moves your ship (and some other routines like collision detection). All of the four routines are the same (one for each direction): moveshipup if speed<=19 then p0y=p0y-1.0: goto moveshipup2 if speed<=29 then p0y=p0y-1.2: goto moveshipup2 if speed<=39 then p0y=p0y-1.4: goto moveshipup2 if speed<=49 then p0y=p0y-1.6: goto moveshipup2 if speed>=50 then p0y=p0y-2.0: goto moveshipup2 Only differences are + in one and p0x=p0x. Somehow the ship does not respond to my fire button (it used to work before I added all this stuff) any more and only flies/scores at top speed. Well it starts off slow and then only goes top speed. I know I didn't show all my game code, but what am I missing? Edited February 5, 2023 by Words Fail Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 5, 2023 Share Posted February 5, 2023 Why do you have "goto joycheck2" in one spot and "goto joycheck2 bank2" in another? is the one chunk of code in bank 2 or did you forget? Quote Link to comment Share on other sites More sharing options...
Words Fail Posted February 5, 2023 Author Share Posted February 5, 2023 33 minutes ago, Random Terrain said: Why do you have "goto joycheck2" in one spot and "goto joycheck2 bank2" in another? is the one chunk of code in bank 2 or did you forget? My mistake copying and pasting here. bank2 is there in both locations. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 5, 2023 Share Posted February 5, 2023 Maybe it's this part: speedchecknofire speed=speed-10 if speed<1 then speed=1 goto joycheck2 bank2 Maybe it should be something this instead: speedchecknofire speed=speed-10 if speed<1 || speed > 200 then speed=1 goto joycheck2 bank2 Quote Link to comment Share on other sites More sharing options...
Words Fail Posted February 5, 2023 Author Share Posted February 5, 2023 (edited) 25 minutes ago, Random Terrain said: Maybe it's this part: speedchecknofire speed=speed-10 if speed<1 then speed=1 goto joycheck2 bank2 Maybe it should be something this instead: speedchecknofire speed=speed-10 if speed<1 || speed > 200 then speed=1 goto joycheck2 bank2 I don't know why speed would ever go over 50. In another thing I have if speed>50 then speed=50. I am also wondering what specific the number 200 has to do with anything. None of code has the number 200 in it.. well except positioning of objects off the screen. Anyway, I inserted it and it doesn't do a thing. Is it because -10 may go into negatives? Edited February 5, 2023 by Words Fail Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 5, 2023 Share Posted February 5, 2023 3 minutes ago, Words Fail said: I don't know why speed would ever go over 50. In another thing I have if speed>50 then speed=50. If speed is less than 10 and you subtract 10, the number is going to wrap over into the 200s. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 5, 2023 Share Posted February 5, 2023 30 minutes ago, Words Fail said: Anyway, I inserted it and it doesn't do a thing. You're going to need it once you fix the other problem. The other problem you have is that it's moving at the speed of light. You're zapping up to 50 in the blink of an eye. You'll have to add a counter to slow it down. Quote Link to comment Share on other sites More sharing options...
Words Fail Posted February 6, 2023 Author Share Posted February 6, 2023 2 hours ago, Random Terrain said: You're going to need it once you fix the other problem. The other problem you have is that it's moving at the speed of light. You're zapping up to 50 in the blink of an eye. You'll have to add a counter to slow it down. I thought that was my counter lol. 0-19 speed slow, 20-29, 30-39, etc Quote Link to comment Share on other sites More sharing options...
Words Fail Posted February 6, 2023 Author Share Posted February 6, 2023 (edited) 2 hours ago, Random Terrain said: You're going to need it once you fix the other problem. The other problem you have is that it's moving at the speed of light. You're zapping up to 50 in the blink of an eye. You'll have to add a counter to slow it down. So I changed it.. I'm doing speed=speed-2 and if speed is less than 10 it = 10. I tried the >200 thing also.. no matter what I do it only makes the ship go faster and I'm not even pressing fire. I also changed the duration.. so it now counts up to 160.. just takes it a slower amount of time for ship to gain speed, but it always gains speed and never slows down. Previously I had 2 speeds.. fast or slow and it worked. Edited February 6, 2023 by Words Fail Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 6, 2023 Share Posted February 6, 2023 You'd try something like this: speedchecknofire counter = counter + 1 if counter > 250 then speed=speed-10 : counter = 0 if speed<1 || speed > 200 then speed=1 goto joycheck2 bank2 That may still be too fast or it may be too slow. You have to play around and see. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 6, 2023 Share Posted February 6, 2023 And your speed if-thens need to be in ranges. Instead of this: moveshipup if speed<=19 then p0y=p0y-1.0: goto moveshipup2 if speed<=29 then p0y=p0y-1.2: goto moveshipup2 if speed<=39 then p0y=p0y-1.4: goto moveshipup2 if speed<=49 then p0y=p0y-1.6: goto moveshipup2 if speed>=50 then p0y=p0y-2.0: goto moveshipup2 It should probably be something like this: moveshipup if speed < 20 then p0y=p0y-1.0: goto moveshipup2 if speed > 19 && speed < 30 then p0y=p0y-1.2: goto moveshipup2 if speed > 29 && speed < 40 then p0y=p0y-1.4: goto moveshipup2 if speed > 39 && speed < 50 then p0y=p0y-1.6: goto moveshipup2 if speed > 49 then p0y=p0y-2.0: goto moveshipup2 1 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.