Siris Dracken
Member
Greetings, original post follows, but skip to the end for the fully working code.
Hello! I have been trying to get wall grab working for about a week now, and I have sort of accomplished that task...however I have to use a spawned game object, and that is quite inefficient and there has to be a better way.
There was a previous post for wall grab in a different version, however the commands used in there dont seem to exist anymore, so I have had to do alot of poking and prodding at other things to get to where I am. Despite having to use a game object I think the implementation itself works well, I just want to...optimize it as we are making a game that has lots of projectiles similar to a Mega Man style game, so I want to keep any unnecessary object spawning to a minimum.
I utilize the very last object in the Game Objects list, its pretty simple, a black tile, with a small collision bot in the center, its default action has a 1 timer on it, and the end of action...uh action is to DestroyItself. And an action step just for Wall Grab that is set to ignore gravity.
This is my current code for when the player is pressing and holding the Up Direction, I know I could make this you have to just press up right when you want to grab, but that feels terrible and janky so I refuse lol.
If anyone has an ideas as to what I am doing wrong here that would be much appreciated. If you comment out lines 43 and 52, everything stops working...which I dont quite understand why. Isn't CheckCollisionPoint telling me if the collision tile at that point is whatever collision type I pass it?
Am I just completely miss-understanding how CheckCollisionPoint works?
Hello! I have been trying to get wall grab working for about a week now, and I have sort of accomplished that task...however I have to use a spawned game object, and that is quite inefficient and there has to be a better way.
There was a previous post for wall grab in a different version, however the commands used in there dont seem to exist anymore, so I have had to do alot of poking and prodding at other things to get to where I am. Despite having to use a game object I think the implementation itself works well, I just want to...optimize it as we are making a game that has lots of projectiles similar to a Mega Man style game, so I want to keep any unnecessary object spawning to a minimum.
I utilize the very last object in the Game Objects list, its pretty simple, a black tile, with a small collision bot in the center, its default action has a 1 timer on it, and the end of action...uh action is to DestroyItself. And an action step just for Wall Grab that is set to ignore gravity.
This is my current code for when the player is pressing and holding the Up Direction, I know I could make this you have to just press up right when you want to grab, but that feels terrible and janky so I refuse lol.
Code:
TXA
STA temp
GetActionStep temp
CMP #$07 ;; is the player hurt?
BNE +notHurt
JMP +doNotWallGrab
+notHurt
CMP #$03 ;; player jumping?
BEQ +isJumping
JMP +doNotWallGrab
+isJumping
LDA Object_y_hi,x
CLC
ADC #$08 ;; middle of player, about where hand is
STA temp2
LDA Object_direction,x
AND #%00000111
CMP #%00000110 ;; is the player facing left?
BNE +notLeft
;; Facing Left so set temp variables for left
LDA Object_x_hi,x
CLC
SBC #$01 ;; 1 pixel to the left of the player to check.
STA temp1
JMP +tryWallGrab_Left
+notLeft
;; Facing Right
LDA Object_x_hi,x
CLC
adc #$0D ;; Right Side of Player
STA temp1
JMP +tryWallGrab_Right
+tryWallGrab_Left
CreateObjectOnScreen temp1, temp2, #$02, #$00, tempA
CheckCollisionPoint temp1, temp2, #$00, tempA ;; is it a solid?
BEQ +doNotWallGrab
JMP +doWallGrab
+tryWallGrab_Right
CreateObjectOnScreen temp1, temp2, #$02, #$00, tempA
CheckCollisionPoint temp1, temp2, #$00, tempA ;; is it a solid?
BEQ +doNotWallGrab
+doWallGrab
ChangeActionStep temp, #$04 ;; change action to WallGrab
StopMoving temp, #$FF, #$04
+doNotWallGrab
RTS
If anyone has an ideas as to what I am doing wrong here that would be much appreciated. If you comment out lines 43 and 52, everything stops working...which I dont quite understand why. Isn't CheckCollisionPoint telling me if the collision tile at that point is whatever collision type I pass it?
Am I just completely miss-understanding how CheckCollisionPoint works?