Jump to content
IGNORED

Someone see something wrong with this?


Words Fail

Recommended Posts

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 by Words Fail
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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 by Words Fail
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Words Fail
Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

 

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...