Hi NESDev! Here comes Andreasswf with some more stupid questions. Well, last time some of you helped me figure out what I did wrong with famitone2 and helped me learn exactly how it works. You are great teachers and I can't thank you enough! I hope these following questions are not too bad/stupid to ask.
I've been learning how to work with background collision and a movable player in 4 directions with a tutorial on Nintendoage by Mario's right nut(?). I've been modifying his code (which is a top down maze kind of-engine, into something that I would like to work as a platformer without scrolling (just screen changes, like battle kid).
Right now I'm studying the collision detection part of the code. I want to make my character be able to move left and right on the platform it is standing on and later on be able to jump and control directions in the air (like how most NES platformers work)
So these are a number of things that I'm trying to learn how to implement in order to make the code work as intended:
1. Make my character always move down. A sort of gravity/force. IMPLEMENTED
2. Make the character stop moving down on collision of a 'solid' block. IMPLEMENTED
3. (This is where the problems are starting to show up) Make the character be able to move left and right without current errors that I have not been able to figure out what's wrong :S When my character is currently moving left and right (moving up and down will be removed, it is a leftover from the original code. Maybe I should remove it right away?)
4. Make the character be able to jump (a much bigger step to learn in modifying this code)
I will attach my source code to this post so that you can study the whole thing.
Thank you for your help.
I've been learning how to work with background collision and a movable player in 4 directions with a tutorial on Nintendoage by Mario's right nut(?). I've been modifying his code (which is a top down maze kind of-engine, into something that I would like to work as a platformer without scrolling (just screen changes, like battle kid).
Right now I'm studying the collision detection part of the code. I want to make my character be able to move left and right on the platform it is standing on and later on be able to jump and control directions in the air (like how most NES platformers work)
So these are a number of things that I'm trying to learn how to implement in order to make the code work as intended:
1. Make my character always move down. A sort of gravity/force. IMPLEMENTED
2. Make the character stop moving down on collision of a 'solid' block. IMPLEMENTED
3. (This is where the problems are starting to show up) Make the character be able to move left and right without current errors that I have not been able to figure out what's wrong :S When my character is currently moving left and right (moving up and down will be removed, it is a leftover from the original code. Maybe I should remove it right away?)
4. Make the character be able to jump (a much bigger step to learn in modifying this code)
I will attach my source code to this post so that you can study the whole thing.
Thank you for your help.
Code:
Collision_Detection:
LDA #$00 ;clear out the indexes
STA collision_index
STA collision_index+1
STA collision_index+2
STA collision_index+3
STA collide_position
STA collide_position+1
STA collide_position+2
STA collide_position+3
JSR Find_Collision_Meta_Tiles ;find the collision data from the meta tiles
LDX enemy_number ;we only need to check the direction we are currently traveling
;;;;;;;;;;insert;;;;;;;;;;
LDA collide_data+2
AND #%00000100
BEQ .lolo1
LDA collide_position
STA sprite_vertical
JMP .continue_on2
.lolo1
LDA collide_data+3
AND #%00000100
BEQ .continue_on2
LDA collide_position
STA sprite_vertical
.continue_on2
;;;;;;;;;;end insert;;;;;;;;
LDA enemy_direction,x
BEQ .up
CMP #$01
BEQ .down
CMP #$02
BEQ .right
JMP .left
.right
LDA collide_data+1 ;load the data we found
AND #%00000010 ;check only the right direction data
BEQ .right1 ;no impact, check the bottom of the sprite
LDA collide_position+2 ;load the position setting we found
STA sprite_horizontal ;store it in the horizontal position of the sprite
JMP .continue_on ;jump to the next step
.right1
LDA collide_data+3 ;same thing on the bottom
AND #%00000010
BEQ .right2
LDA collide_position+2
STA sprite_horizontal
JMP .continue_on
.right2 ;no impact? Don't do shit!!
RTS
.left
LDA collide_data ;same as above.
AND #%00000001
BEQ .left1
LDA collide_position+3
STA sprite_horizontal
JMP .continue_on
.left1
LDA collide_data+2
AND #%00000001
BEQ .left2
LDA collide_position+3
STA sprite_horizontal
JMP .continue_on
.left2
RTS
.up
LDA collide_data
AND #%00001000
BEQ .up1
LDA collide_position+1
STA sprite_vertical
JMP .continue_on
.up1
LDA collide_data+1
AND #%00001000
BEQ .up2
LDA collide_position+1
STA sprite_vertical
JMP .continue_on
.up2
RTS
.down
LDA collide_data+2
AND #%00000100
BEQ .down1
LDA collide_position
STA sprite_vertical
JMP .continue_on
.down1
LDA collide_data+3
AND #%00000100
BEQ .down2
LDA collide_position
STA sprite_vertical
JMP .continue_on
.down2
RTS
.continue_on
LDA enemy_number
BEQ .done
JSR direction_change ;need to add this in here so that the enemies don't just sit there and run at the walls
.done ;errrr....helments!!
RTS
LDA #$00 ;clear out the indexes
STA collision_index
STA collision_index+1
STA collision_index+2
STA collision_index+3
STA collide_position
STA collide_position+1
STA collide_position+2
STA collide_position+3
JSR Find_Collision_Meta_Tiles ;find the collision data from the meta tiles
LDX enemy_number ;we only need to check the direction we are currently traveling
;;;;;;;;;;insert;;;;;;;;;;
LDA collide_data+2
AND #%00000100
BEQ .lolo1
LDA collide_position
STA sprite_vertical
JMP .continue_on2
.lolo1
LDA collide_data+3
AND #%00000100
BEQ .continue_on2
LDA collide_position
STA sprite_vertical
.continue_on2
;;;;;;;;;;end insert;;;;;;;;
LDA enemy_direction,x
BEQ .up
CMP #$01
BEQ .down
CMP #$02
BEQ .right
JMP .left
.right
LDA collide_data+1 ;load the data we found
AND #%00000010 ;check only the right direction data
BEQ .right1 ;no impact, check the bottom of the sprite
LDA collide_position+2 ;load the position setting we found
STA sprite_horizontal ;store it in the horizontal position of the sprite
JMP .continue_on ;jump to the next step
.right1
LDA collide_data+3 ;same thing on the bottom
AND #%00000010
BEQ .right2
LDA collide_position+2
STA sprite_horizontal
JMP .continue_on
.right2 ;no impact? Don't do shit!!
RTS
.left
LDA collide_data ;same as above.
AND #%00000001
BEQ .left1
LDA collide_position+3
STA sprite_horizontal
JMP .continue_on
.left1
LDA collide_data+2
AND #%00000001
BEQ .left2
LDA collide_position+3
STA sprite_horizontal
JMP .continue_on
.left2
RTS
.up
LDA collide_data
AND #%00001000
BEQ .up1
LDA collide_position+1
STA sprite_vertical
JMP .continue_on
.up1
LDA collide_data+1
AND #%00001000
BEQ .up2
LDA collide_position+1
STA sprite_vertical
JMP .continue_on
.up2
RTS
.down
LDA collide_data+2
AND #%00000100
BEQ .down1
LDA collide_position
STA sprite_vertical
JMP .continue_on
.down1
LDA collide_data+3
AND #%00000100
BEQ .down2
LDA collide_position
STA sprite_vertical
JMP .continue_on
.down2
RTS
.continue_on
LDA enemy_number
BEQ .done
JSR direction_change ;need to add this in here so that the enemies don't just sit there and run at the walls
.done ;errrr....helments!!
RTS