Sonic-esque H vel-dependent state

lecapitaine

New member
So in the end, I rolled up my sleeves and dove arse-first into assembly. Thus far I've got this:

Code:
 ; WalkOrRun.asm
   LDX player1_object
   LDA Object_movement,x
   CMP #$00
   BEQ standCheck
   LDA Object_movement,x
   CMP #$01
   BCS runCheck
   RTS
runCheck:
   GetCurrentActionType player1_object
   CMP #$02
   BEQ cancel
   ChangeObjectState #$02, #$04
   RTS
walkCheck:
   GetCurrentActionType player1_object
   CMP #$05
   BEQ cancel
   ChangeObjectState #$05, #$04
   RTS
standCheck:
   GetCurrentActionType player1_object
   CMP #$01
   BEQ cancel
   ChangeObjectState #$01, #$04
   RTS
cancel:
   RTS

linked (I believe) to my player character like so:
sauce3.png

Doesn't work. What I'm trying to achieve is a stand/walk/run cycle that depends on horizontal velocity, and I'm quite certain I'm missing something.
 

dale_coop

Moderator
Staff member
Hmmm... your code is correct, synthaxically (je ne suis pas sûr que ce mot existe en anglais).

But, I am not sure to understand what you want to do, here. You want that the player does things by himself (stand/walk/run) like for using on a cutscene maybe? or when you re touching the controller buttons maybe?

Because, usually, the Player doesn't use any "Action" on it actions steps.
The Action Steps are here used just for animations purpose. By default with the Basic modules:
- Action Step 0 to play the "Idle" animation
- Action Step 1 to play the "walking" animation
- Action Step 2 to play the "jumping" animation
- Action Step 3 to play the "attack" animation
- Action Step 4 to play the "climbing" animation
- Action Step 5 to play the "crouching" animation
And the next Action Steps are free for any other purpose

The engine and the input scripts, will changeObjectState depending of situations... When you assign the moving "hold" input scripts, it moves the player object and change its state to 1. When you "release" the button, it change back to "0". The jump input script make the player object moving up and set the action step 2... etc
(also several extra and physics scripts manages to sates of the player, like when the player does nothing it automatically set to action step 0... when he falls using gravity, it's automatically set to 2, when he's on a ladder tile, it will makes sure to keep it on action step 4,...)


The "Actions" script assigned to action step are mainly used for all the other objects, their AI (for example: Action step 0, move left and go to next action, action step 1 stop and wait, action step 2, shoot on the player and go back to action step 0).


If you haven't watched ALL the tutorial videos (the Let's Getting Started ones for the basis), I would suggest to it, before start working on NESmaker.
 

lecapitaine

New member
I'd like to do it Sonic-style, where the velocity controls the animation state rather than the input directly (the opposite of, say, Prince of Persia). I've already commented out the part in StartMovingLeft/Right that changes state, and now I'm getting just the stand animation while moving.

I'll have a look at engine scripts to look for state changes. What would really solve my issue is some kind of update cycle like you can get in Unity.

e: Found my update cycle, in ExtraControllReadCode. I'm moving, barely. Either always in walk state or always in stand state, I think the part I'm not getting correctly is the Object_movement variable.
 

dale_coop

Moderator
Staff member
The Object_movement variable is used for movement and direction
The first 3 bit for the facing direction (=animation) and the other ones used for the movements.
(Check at the contain of the FaceDirections.asm and StartMoving.asm macros)
 

lecapitaine

New member
Thanks. Turned out Object_movement wasn't the variable I was looking for. I'm still stumped as to where to access horizontal velocity.

e: Think I found it, it's Object_h_speed_lo and Object_h_speed_hi. I assume it's a 16-bit value that needs to be combined before comparing its absolute to my speed thresholds, but now to find out how to do any of that.
 
Top Bottom