Jump to content
IGNORED

7800Basic Trouble...


ZippyRedPlumber

Recommended Posts

With 

21 hours ago, ZippyRedPlumber said:

It worked! Thanks @Muddyfunster

 

Now I want to make her jump here's my code sample;

Is this right?

 

i don't think the logic structure in that example would work because you are reducing heroy by 1 and then checking if heroy = heroy -55. 

 

If for example you wanted to have a fixed jump (up then down) you could use a jump counter. 

 

I think you wrote some jumping code into your Lyra game on the 2600.

 

7800Basic is quite similar to Batari Basic and many of those principles would work here, at least the bits for managing the jump. You would need different code to plot your sprite etc, 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

10 hours ago, Muddyfunster said:

With 

 

i don't think the logic structure in that example would work because you are reducing heroy by 1 and then checking if heroy = heroy -55. 

 

If for example you wanted to have a fixed jump (up then down) you could use a jump counter. 

 

I think you wrote some jumping code into your Lyra game on the 2600.

 

7800Basic is quite similar to Batari Basic and many of those principles would work here, at least the bits for managing the jump. You would need different code to plot your sprite etc, 

 

 

 

 

Like this, is this right?

 

Quote

dim _Bit0_Fall_in_Progress = l ;player is falling if on.
dim _Bit1_FireB_Restrainer = l ;player can't hold down fire button to jump.
dim _Jump_Gravity_Counter = m
dim _Fall_Gravity_Counter = n

 

   ; Skips this section if fire button is not pressed.
   if !joy0fire1 then _Jump_Gravity_Counter=0:_Bit3_FireB_Restrainer{3}=0:goto __Skip_Jump

   ;Used when player moves left/right while jumping or falling.
   if !_Bit3_FireB_Restrainer{3} then plotsprite gfx/fire_jump.png 160A 0 1 2 3 1
 
   ;sprite used if player isn't moving left or right.
   if !joy0left && !joy0right && !_Bit3_FireB_Restrainer{3} then plotsprite gfx/fire_jump.png 160A 0 1 2 3 1

   ;Skips jump if player is falling.
   if _Bit0_Fall_in_Progress{0} then goto __Skip_Jump

   ;Skips jump if fire button restrainer bit is on and jump and
   ;fall are not happening. Fixes it so the player can't hold
   ;down the fire button to jump repeatedly.
   if _Bit3_FireB_Restrainer{3} && !_Bit0_Fall_in_Progress{0} && !_Jump_Gravity_Counter then goto __Skip_Jump

   ;Turns on restrainer bit for fire button.
   _Bit3_FireB_Restrainer{3}=1

   ;Adds one to the jump counter.
   _Jump_Gravity_Counter=_Jump_Gravity_Counter+1

   ;Resets jump counter if limit is reached and starts a fall.
   if _Jump_Gravity_Counter>12 then _Jump_Gravity_Counter=0:_Bit0_Fall_in_Progress{0} = 1:goto __Skip_Jump

   ;Jump happens here.
   ;Skips jump if player1 sprite is at top edge of screen.
   if heroy<13 then goto __Skip_Jump

   ;Changes speed of jump over time depending on counter number.
   ;Slows down the higher it goes.
   if _Jump_Gravity_Counter<=7 then temp6=3
   if _Jump_Gravity_Counter>7 && _Jump_Gravity_Counter<=10 then temp6=2
   if _Jump_Gravity_Counter>10 then temp6=1

   ;Moves player1 sprite up the screen.
   heroy=heroy-temp6

   ;Converts player0 y position to playfield y position.
   temp5 = (heroy-5)/8

   ;```````````````````````````````````````````````````````````````
   ;  Checks to see if a pfpixel is in the way.
   ;
   if pfread(_Convert_X,temp5) then _Jump_Gravity_Counter=0:_Bit0_Fall_in_Progress{0} = 1:goto __Skip_Jump
__Skip_Jump

   ;Converts sprite y position to playfield y position.
   temp5 = (heroy+1)/8

   ;  Skips section if player is jumping or pfpixel is in the way.
   if _Jump_Gravity_Counter || pfread(temp5) then goto __Skip_Fall_01

   ;Used when player moves left/right while jumping or falling.
   plotsprite gfx/fire_jump.png 160A 0 1 2 3 1
   
   ;sprite used if player isn't moving left or right.
   if !joy0left&&!joy0right then then plotsprite gfx/fire_jump.png 160A 0 1 2 3 1

   ;Adds one to the gravity counter.
   _Fall_Gravity_Counter=_Fall_Gravity_Counter+1

   ;Fake gravity fall (speed keeps increasing during a fall).
   temp6=0
   if _Fall_Gravity_Counter>8 && _Jump_Gravity_Counter<=16 then temp6=1
   if _Fall_Gravity_Counter>16 && _Jump_Gravity_Counter<=24 then temp6=2
   if _Fall_Gravity_Counter>24 && _Jump_Gravity_Counter<=32 then temp6=3
   if _Fall_Gravity_Counter>32 then temp6=4

   ;Moves player down the screen.
   heroy=heroy+temp6

   ;  Lets the program know a fall is in progress.
   _Bit0_Fall_in_Progress{0}=1

   goto __Skip_Fall_02

__Skip_Fall_01

   ;  Not falling. Clears related variables.
   _Bit0_Fall_in_Progress{0} = 0:_Fall_Gravity_Counter=0

   ;  Moves sprite up one pixel if player sprite touches playfield.
   if pfread(_Convert_X,temp5) then player0y = player0y - 1

__Skip_Fall_02

 

 

Link to comment
Share on other sites

Hi mate i know you asked me about the jump code i used for Captain Comic and wanted advice. I have been a little busy and with that game it's kinda complicated as the jump routine is tied into the game engine physics.

 

Basically i use an constant artificial gravity which is very useful in the long run to prevent buggy physics. You will then need collision detection so the player doesn't fall through certain maptiles or platforms ect. From there you can add some jumping physics along the lines of a jump counter like Muddy mentioned previously.

 

If you don't tie all these physics together you will run into many bugs and headaches down the line. I know it's alot to take in and may not make any sense. I highly recommend creating some test programs and learn all these aspects of the physics individually before merging together. Start with gravity and the collision detection within the "ramcharmap" example program. The learn to counter the gravity on joyfire input and moving onto integrating restrainers for debounce along with timers ect.

 

ramcharmap.7z

 

I hope some of this makes sense and helps with your project.

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Alright, here's take number 3 & I think I managed to make the character jump. However there's a few issues, 1. Lyra can jump infinitely, a limit needs to be capped.

2. Pressing the jump button multiple times or hitting the top of the screen causes the screen to goe pink.

 

Roms, Bas file & Gfx folder attached below

rumchurjump_take3.bas.a78 rumchurjump_take3.bas.bin rumchurjump_take3.bas graphics.zip

Link to comment
Share on other sites

21 hours ago, ZippyRedPlumber said:

Alright, here's take number 3 & I think I managed to make the character jump. However there's a few issues, 1. Lyra can jump infinitely, a limit needs to be capped.

2. Pressing the jump button multiple times or hitting the top of the screen causes the screen to goe pink.

I see a couple of problems here. One is "jumping" is both the name of a variable, and the name of a label for a gosub target. You should rename one of these. Another issue is that you do a gosub to the "jumping" label, and there is no "return" statement. This causes a memory leak via the stack, and is likely the cause of your yellow screen of death. Finally, I noticed that the "jumping" routine is inside of the main function, so it looks like it will be hit eventually regardless of whether or not it is called. I didn't look at your code closely enough to tell if that was likely your intent or not.

 

Edit: Technically based on how 7800basic deals with labels, it's maybe okay to have the same name for a label and a variable name, but it's still probably a bad idea for readability, if nothing else.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Ecernosoft said:

When I said add 6 to the Xpos I meant in tiles for when you check the collision with the background… anyway, you got it figured out, and this is a moot topic now.

Maybe I'm being dumb, but I don't see how this remotely correlates with Karl's response which talks about subroutines without a return, causing code "drop through" and a crash.

 

  • Like 1
Link to comment
Share on other sites

4 hours ago, Muddyfunster said:

Maybe I'm being dumb, but I don't see how this remotely correlates with Karl's response which talks about subroutines without a return, causing code "drop through" and a crash.

 

I was talking about the jank collision, not the drop through thing.

 

Err: Sorry, the first time it didn't go through, so I tried again, and both went through. =/

Edited by Ecernosoft
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...