gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin
See the second demo in this thread (in the original post).
http://www.nintendoage.com/forum/messageview.cfm?catid=22&am...
This is my shiny thing, and if you try to take it off me, I may have to eat you.
Check out my dev blog.
I have this for all four directions, this is for the Up botton:
LDA $0200 ; load sprite Y position
SEC ; make sure the carry flag is clear
SBC #Speed ; A = A + the variable
STA $0200
JSR transfer_nightman_info ;transfers the $0200 and $0203 into the variables
JSR top_wall_collision ;checks to see if he has hit the top wall, then sends it to the various room detections
LDA #room_change ;for room changes skip the next part
BEQ AnimationupCounter
JSR update_nightman_sprites
top_wall_collision: ; This is for all four directions
LDY #$00
STY room_change
LDA sprite_vertical
CMP #top_wall ;check location
BCS .done ;jump to code for inside the L/R door frames
LDX door_status ;see if the doors are open
CPX #$01
BEQ .doorclosed ;either jump to the top wall collsion or enter the door
TAY
LDA banks_and_doors ;enter the door/active room switching
AND #%10000000 ;see if there is a door in this direction
BEQ .doorclosed
LDX sprite_horizontal ;see if he is in the door frame
CPX #vertical_door_right+2
BCS .doorclosed
CPX #vertical_door_left-2
BCC .doorclosed
LDX #vertical_door_left+2 ;this is so the dumb ass doesn't run into said door frame.
STX sprite_horizontal
TYA
CMP #top_exit ;see if he is at the top yet
BCS .done2
JSR exit_on_top
LDY #$01
STY room_change
RTS
.doorclosed:
LDA #top_wall ;if the door is closed or outside the frame, stay below the wall
STA sprite_vertical
JSR direction_change
JMP .done2
.done ;doors open routine
LDX door_status ;see if the doors are open
CPX #$01
BEQ .done1
CMP #horizontal_door_top ;this is for if he is in the door frame
BCS .done1 ;see if he is at the top of the door
LDX sprite_horizontal ;check left
CPX #left_wall
BCC .next
CPX #right_wall+1 ;check right
BCC .done1
.next
LDA #horizontal_door_top ;stay in the door frame
STA sprite_vertical
JMP .done2
.done1 ;load info for which direction to use
LDX #$00
STX collide_direction
JSR collision_detection ;indirect jump to collision detection
.done2
RTS
collision_detection: ;indirect jumping for collision detection
JMP [collideptr] ;the collideptr is set to collide0 in the room loading routine
collision0:
.word up_collide0,down_collide0,right_collide0,left_collide0
collide0:
LDX collide_direction ;$00=up, $02=down, $04=right, $06=left
LDY collision0,X
STY collideptr2
LDY collision0+1,X
STY collideptr2+1
JMP [collideptr2]
up_collide0:
LDA sprite_vertical
LDX sprite_horizontal ;top pipe on right side of the screen
CPX #$7F
BCC .done
CPX #$C8
BCS .done
CMP #$70
BCC .done
CMP #$78
BCS .done
LDA #$78
STA sprite_vertical
JSR direction_change
JMP .dones
.done
CPX #$68 ; bottom of the engine
BCS .done1
CMP #$AF
BCS .done1
CMP #$A0
BCC .done1
LDA #$AF
STA sprite_vertical
JSR direction_change
JMP .dones
.done1
CPX #$78 ;very top piece of pipe
BCS .done2
CMP #$67
BCS .done2
LDA #$67
STA sprite_vertical
JSR direction_change
JMP .dones
.done2
CPX #$7F ;bottom pipe on right side of the screen
BCC .done3
CPX #$C8
BCS .done3
CMP #$B0
BCC .done3
CMP #$B8
BCS .done3
LDA #$B8
STA sprite_vertical
JSR direction_change
JMP .dones
.done3
CPX #$68 ;get around the top corner of the engine
BCC .done4
CPX #$6E
BCS .done4
CMP #$A7
BCC .done4
CMP #$AE
BCS .done4
INC sprite_horizontal
JMP .dones
.done4
CPX #$C8
BCC .done5
CPX #$CE
BCS .done5
CMP #$6D ;Get around the top pipe tip.
BCC .next
CMP #$78
BCC .next1
.next
CMP #$AD ;get around the bottom pipe tip
BCC .done5
CMP #$B8
BCS .done5
.next1
INC sprite_horizontal
JMP .dones
.done5
CMP #$68 ;move around the top elbow
BCC .done6
CMP #$78
BCS .done6
CPX #$74
BCC .done6
CPX #$80
BCS .done6
DEC sprite_horizontal
JMP .dones
.done6
.dones
RTS
This is my shiny thing, and if you try to take it off me, I may have to eat you.
Check out my dev blog.
See the second demo in this thread (in the original post).
http://www.nintendoage.com/forum/messageview.cfm?catid=22&am...
Here is an example of how to code the metasprite updates:
update_enemy1_sprites:
LDA sprite_vertical
STA $0214 ; save sprite Y position
STA $0218
CLC
ADC #$08
STA $021C
STA $0220
LDA sprite_horizontal
STA $0217 ; load sprite X position
STA $021F
CLC
ADC #$08
STA $021B
STA $0223
RTS
The way your doing it doesn't mean anything. What MetalSlime meant is that you transfer $0214 and $0217 to the variables above, then run your moving and collision detection ON the variables, then run something like above. You can't update them like you're doing there.
.db is for numbers, .word is for addresses. MetalSlime goes through this in his sound tutorials. i.e.
.db $01, $02, $09, $FF, etc.
.word $0217, $0218, $02FF, etc.
or you can use variables or constants defined in your zerospace in these tables or pretty much anything you want.
This is my shiny thing, and if you try to take it off me, I may have to eat you.
Check out my dev blog.