A few advanced ASM questions.

Hey!
In my game I wanted to have a 'Jump' Object state, in an attempt for a 2.5D overhead kinda setup. In ObjectBytesRam.asm I added two values:
Code:
Object_jump_speed	.dsb 12
Object_jump_z		.dsb 12
Jump speed being how far it displaces the object every time the Jump Action is called, and Jump Z being how far it is from its normal X/Y.
I wanted it to check if the jumpspeed is not equal to zero, then it would make the object invincible, due to it being in air.
To do this, I need some way to displace the sprites drawing location, but not its hitbox location.
Problem is, I don't know where to do that :p. I looked around in Adventuregame_Base\Adventure_Drawing.asm, but had no luck.
If anybody knows how to do this, let me know.
Unrelated other thing:
I wanted to change the sprite palette 1 when the player dies, but if I add it, it makes the jump to not hurt the player too long. Any ideas on how to work around this?
 

jorotroid

Member
Let me see if I understand, you want something like the roc's feather from the gameboy zelda games where the player can jump, but can be hurt because everything that could hurt it is on the ground plane, but you still want the collision box "on the ground" to handle collisions with the environment? My best guess is to go to the drawing script and find where Object_y_hi comes up. Insert this right after it:
Code:
SEC
SBC Object_jump_z,x

I think that should displace the y drawing position by your z value.


For your unrealated question, I am confused by what you meant by "it makes the jump to not hurt the player too long." Could you elaborate a bit?
 

jorotroid

Member
Oh, I forgot about the invincibility portion. I would just go to the player hurt script and if the jump speed is not zero, have it skip the script.
 
jorotroid said:
Let me see if I understand, you want something like the roc's feather from the gameboy zelda games where the player can jump, but can be hurt because everything that could hurt it is on the ground plane, but you still want the collision box "on the ground" to handle collisions with the environment? My best guess is to go to the drawing script and find where Object_y_hi comes up. Insert this right after it:
Code:
SEC
SBC Object_jump_z,x

I think that should displace the y drawing position by your z value.


For your unrealated question, I am confused by what you meant by "it makes the jump to not hurt the player too long." Could you elaborate a bit?
By the jump being to long, i mean the compiler says that the place im trying to JMP in the code is too far away. :p
And, yeah that's precisely what i mean with the jumping
 
When trying to do it with the method you suggested, the player just stays in place and plays its jump animation. No clue as to why. Heres my jump code. (An AI Action)
Code:
LDA Object_jump_z
ADC #$01
STA Object_jump_z
This is of course, just test to see if it would move the sprite. No luck.
 

jorotroid

Member
Karakara | Karetro said:
By the jump being to long, i mean the compiler says that the place im trying to JMP in the code is too far away. :p

Ah, got it. Can you post some line of code around where the error is so I can get some context. Usually I can get around this error by sort of shuffling some logic around.
 
Code:
LDA Object_health,x
SEC
SBC #$01 ;; subtract other's strength
STA myHealth
CMP #$01
BCS notPlayerDeath
.include SCR_HANDLE_PLAYER_DEATH
JMP doneWithPlayerHurt
Heres where its called.
Code:
TXA
STA tempx
TYA 
STA tempy
;;;;;;;;;;;;;;;;;;;
LDX player1_object
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
DeactivateCurrentObject
PlaySong #song_GameOver
CreateObject temp, temp1, #$0C, #$00
	LDA #%00100000
        STA Object_movement,x
;;;;;;;;;;;;;;;;;;;
LDA #$FF
STA player1_object
LDX tempx
LDY tempy
And heres the death script.
I took out the loadspritepalette thing to let it compile
 

jorotroid

Member
Karakara | Karetro said:
When trying to do it with the method you suggested, the player just stays in place and plays its jump animation. No clue as to why. Heres my jump code. (An AI Action)
Code:
LDA Object_jump_z
ADC #$01
STA Object_jump_z
This is of course, just test to see if it would move the sprite. No luck.

What is the timer value on that action step? Also what is it's EndAction set to? My guess based on what you have told me so far is that the AI code get execute once and then the object goes to another state. I think it might be better to add some code in the Physics script and just have the Object_jump_z get modified by the Object_jump_speed variable. That way the Object_jump_z will get modified every frame.
 
jorotroid said:
Karakara | Karetro said:
When trying to do it with the method you suggested, the player just stays in place and plays its jump animation. No clue as to why. Heres my jump code. (An AI Action)
Code:
LDA Object_jump_z
ADC #$01
STA Object_jump_z
This is of course, just test to see if it would move the sprite. No luck.

What is the timer value on that action step? Also what is it's EndAction set to? My guess based on what you have told me so far is that the AI code get execute once and then the object goes to another state. I think it might be better to add some code in the Physics script and just have the Object_jump_z get modified by the Object_jump_speed variable. That way the Object_jump_z will get modified every frame.
Timer is zero. I had the end action set to gotofirst. i changed it to no effect. I'll go try physics script change.
 

jorotroid

Member
Karakara | Karetro said:
Code:
LDA Object_health,x
SEC
SBC #$01 ;; subtract other's strength
STA myHealth
CMP #$01
BCS notPlayerDeath
.include SCR_HANDLE_PLAYER_DEATH
JMP doneWithPlayerHurt
Heres where its called.
Code:
TXA
STA tempx
TYA 
STA tempy
;;;;;;;;;;;;;;;;;;;
LDX player1_object
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
DeactivateCurrentObject
PlaySong #song_GameOver
CreateObject temp, temp1, #$0C, #$00
	LDA #%00100000
        STA Object_movement,x
;;;;;;;;;;;;;;;;;;;
LDA #$FF
STA player1_object
LDX tempx
LDY tempy
And heres the death script.
I took out the loadspritepalette thing to let it compile

Ok. The error happens on the BCS notPlayerDeath line, right? This is what I would change it to to get around the error:

Code:
LDA Object_health,x
SEC
SBC #$01 ;; subtract other's strength
STA myHealth
CMP #$01
BCC playerDeath 		;\
JMP notPlayerDeath		;    These are the lines I changed/added
playerDeath:			;/
.include SCR_HANDLE_PLAYER_DEATH
JMP doneWithPlayerHurt
Basically, I flipped the logic, so that the Branch will go to the nearby default code, but put JMP to go to the farther away notPlayerDeath code.



Karakara | Karetro said:
Timer is zero. I had the end action set to gotofirst. i changed it to no effect. I'll go try physics script change.
So how the Action Steps work is that they activate the AI code once, then wait for the amount of time the timer is set to. When it reaches that amount of time, it will do what the EndAction is set to, so the only way to get AI code to run multiple times in succession is by setting the EndAction to Repeat or Loop (tbh, I'm not completely sure what the difference is). Also setting the timer to zero actually make it a random timer instead of an instant timer.
 
Top Bottom