Jump/Fall? + Extras

gogreyhound

New member
Ok - so i got over feeling defeated with NESMaker and started diving into some coding and trying to get my game working.
Right now, I'm trying to get all of my player animations working in a demo area and I have some things that I need help with (as I have no idea how to code).

Jumping vs Falling:

I would like jumping to have 1 frame and falling to have another. Essentially if the player sprite is moving UP I want a particular sprite to display. If the player sprite is moving DOWN/Falling I want it to display a different sprite. I set up 2 different animations and states in NESMaker, but I'm not sure where to modify the jump code to change the states based on ascent or descent.

"Dirt" on jump/land:

I would like to display a small animation on the "ground" when the player jumps or lands. No idea how to accomplish this - but I have been able to put a 3 or 4 frame animation into NESMaker and place it in the demo play area where it will loop. I'm sure this is pretty complicated to implement as it would need to play on the ground solid anytime the player jumps. I've seen this doable in games like Micro Mages, but I have no idea how complicated it might be.
 

Mugi

Member
i cant really throw you anything straight as i have no idea how your jumping code etc look like, but a simple way to differentiate between going up and going down is as simple as this:

LDA Object_v_speed_hi,x ; load player's vertical movement speed
BMI imGoingUpwards ; jump into this label when we're moving upwards.


this can be used to differentiate jump/fall and then used to set the player into a different action state.
i use this in my wall climbing code to prevent grabbing the wall unless the player is moving downwards.
 

gogreyhound

New member
This may be over my skill level.

Im using whatever the default jump script is that comes with 4.1.5 and the Scrolling Platformer Module.

So in your script example, where would I put these two lines of code? Just anywhere into the jump input asm?

Also what is BMI? and is "imGoingUpwards" a variable? I have so many questions because I have no idea what I'm doing.

If I'm understanding how this functions correctly, would it work like this:

LDA Object_v_speed_hi,x ; load that the player is moving vertical up(any number over 0)
BMI imGoingUpwards ; defines that the player is moving upwards as a variable?

So at this point, how do I define that I would need it to jump to action state 03 for example?

And could the same code be used for moving downwards like this:

LDA Object_v_speed_lo,x ; load that the player is moving vertical down? (any number less than 0)
BMI imGoingDownwards ; defines that the player is falling as a variable?

Sorry for the questions, I just don't understand any of this.
 

Mugi

Member
when the player moves upwards, the vertical speed is negative (in terms of hex values, the range is from 0 to FF, but when negative values come to play, positives are 0-7F and negatives are 80-FF)

BMI opcode checks if the value is negative and acts accordingly.

so when you do a BMI sometexthere it means that when the condition is true (you are moving upwards) the code moves into the label defined in "sometexthere"

you can then place the label further in the code and below the label what you want to happen (for example, change player's action state to jumping)
 

gogreyhound

New member
Mugi said:
when the player moves upwards, the vertical speed is negative (in terms of hex values, the range is from 0 to FF, but when negative values come to play, positives are 0-7F and negatives are 80-FF)

BMI opcode checks if the value is negative and acts accordingly.

so when you do a BMI sometexthere it means that when the condition is true (you are moving upwards) the code moves into the label defined in "sometexthere"

you can then place the label further in the code and below the label what you want to happen (for example, change player's action state to jumping)

So here is the code that I've come up with based on this information. It doesn't work, btw - but maybe you can point out where I don't understand.

This is the jump code included with 4.1.5 scrolling platformer module, found in Scripts > Input Scripts > simple_jump.asm
Code:
; a jumps
 
   LDX player1_object
   ;;; let's check for if we are standing on a jumpthrough platform,
   ;;; for which "down and jump" will jump downwards through
   ;;; comment this out if you do not want that functionality
    LDA screenFlags
    AND #%00100000 ;; does it use gravity?
    BEQ dontJump
    
   LDA Object_physics_byte,x
   AND #%00001000
   BEQ notStandingOnJumpThroughPlatform
   LDA gamepad
   AND #%00100000
   BEQ notStandingOnJumpThroughPlatform
   LDA Object_y_hi,x 
   CLC
   ADC #$09
   STA Object_y_hi,x
   JMP dontJump
notStandingOnJumpThroughPlatform:
   
   LDA Object_physics_byte,x
   AND #%00000001
   BNE canJump
   LDA Object_physics_byte,x
   AND #%00000100
   BEQ dontJump
    
canJump:
    ;;; TURN OFF "STANDING ON JUMPTHROUGH PLATFORM" if it is on
    LDA Object_physics_byte,x
    AND #%11110111
    STA Object_physics_byte,x
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    LDA #$00
    SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x
    GetCurrentActionType player1_object
    CMP #$03 ;; attack
    BEQ +
    ChangeObjectState #$02, #$00
   +
    PlaySound #SND_JUMP
dontJump:
    RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; myCode added below ;;;   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

checkFall: ; I assume this is how you make a label that you can call out in code and warp to this point in the code? 
    ;change state if falling
    LDA Object_v_speed_lo,x ; check player vertical speed
    BMI stFall ; falling state
stFall: ; I have no idea what this is.  I copied it from the above code in the canJump tag
    BEQ +
    ChangeObjectState #$02, #$03 ; change from jump to fall
    +
 

mongolianmisfit

New member
I am in the exact same boat. Trying to implement a falling animation to go display after the apex of the jump, right when the character begins to descend.
Curious if anyone else has solved this.
 

gogreyhound

New member
mongolianmisfit said:
I am in the exact same boat. Trying to implement a falling animation to go display after the apex of the jump, right when the character begins to descend.
Curious if anyone else has solved this.

Nothing yet.
I'm having to learn to code from scratch at this point to try to solve this.
I'm sure there are people out there who would be much quicker at it than me, but I assume they have their own projects to worry with.
 

mongolianmisfit

New member
Yeah, same here. At this point, feature/wishlist items like this are preventing me from nailing my 'vision' for my game, so I'm really having to dive into ASM. It's a tough nut to crack, and one or two "simple" lines can be the difference in adding a feature, or locking up your game with a new bug.

Be sure and chime in if you make a breakthrough with this, I've bookmarked this thread, so I'll do likewise. :)
 

AllDarnDavey

Active member
jump.gif
Slowed down 1/4 speed.

I kind of have a non-code version of this.
My jump animation is 8 frames, but it's 4 copies of the up frame and 4 frames of the down frame, and I just timed the playback speed to roughly switch at the apex of my maximum jump height. If you look at the second jump, I also start my run animation at the lowest point in the cycle so it acts as a transition from jump/fall if you're moving (I couldn't get a similar standing transition without messing up the idle, but it still works okay).

I've also got some simple dust VFX, but it's just baked into the run animation sprites. Even if I did want to code something better I don't know if I'd want to add another sprite for dust as I'm trying to use an economy of sprites to reduce flicker artifacts, especially since a lot of my enemy designs are quadrupeds which makes them more horizontal and makes the 8 sprite per scan-line limit show up quicker than vertically designed characters.
 
Top Bottom