still trying to get this melee code right...

digit2600

Member
so I've tried multiple things to get my controls acting right but to little avail. ..
I'm not sure if I'm using the wrong variables or what....

my logic is basically as follows :

lda on Ground
CMP attacking
bne canmove
CMP walkState
beq canMove
CMP jumpstate
beq canMove

canMove
movePlayerForward
cantMove
face Direction

now this is the code I'm writing in my walk right/left scripts.

I'd assume in my jump script I'd have to add in a clause like :

cmp attacking
beq attack
change Object State #$02 (jump animation )
attack:
change Object State #$03 (attack animation )

thing is, his do I set the variable for attacking if no such variable exists ?

in the melee script it only has meleeCreated and canAttack...should I use one of those ?
am I still doing this totally wrong?

I'm just trying to get character to be able to move if it's attacking and jumping but stand still if it's on the ground...

sorry for the redundancy of this topic. ..
 

chronosv2

New member
I realize this is over two weeks old, but I may have figured out part of the problem for your inquiry here.
Working on my third ASM tutorial where I go over conditions, I took a look at your problem here to see if I could map it out.
Judging by the sounds of it you're on the Platformer module, because you're doing checks for airborne. If I'm wrong here then this will definitely not work.

Firstly, we don't need to check for Attacking -- that's an input button press. If you, say, assign it to the B input then it's implied that when the player hits B they want to attack.
So first we see if they can attack at all, using canAttack. If not we skip the entire script.

So next we check the player's ground state. In the Platformer module that seems to be done with this code:
Code:
    LDA Object_status,x
    AND #%00000100 ;; not on ground
    BEQ isAirborne

So now we know what our airborne state is. If we are, jump to isAirborne.
If not, then immediately after the BEQ statement we put in the code to stop movement, change to the attack state and then jump to the end of the script. That's basically how an "Else" statement works -- if we don't jump, then clearly the thing we were checking for wasn't true.
For the isAirborne label, we generate the attack, change to the airborne attack animation and then just step into the end of the script.
Since it's an Input script, remember to put
Code:
RTS
at the end though, else you're going to create bugs.

No idea if any of this is going to be relevant next week when 4.1.0 hits but I thought I'd answer this since it's on my mind and I thought it might make an interesting problem to cover in my tutorials.
 
Top Bottom