Advertisement
NovaYoshi

player.s collision

Jul 17th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; SAMPLE FOUR POINTS
  2.   ; top
  3.   lda PlayerPYL
  4.   add #<(8*16)
  5.   lda PlayerPYH
  6.   adc #>(8*16)
  7.   tay
  8.   lda #0
  9.   pha
  10.   add PlayerPXL            ; left side
  11.   lda PlayerPXH
  12.   adc #0
  13.   jsr GetLevelColumnPtr
  14.   sta BlockUL
  15.   tax
  16.   lda MetatileFlags,x
  17.   cmp #$80
  18.   rol FourCorners
  19.   pla
  20.   add #$70
  21.   add PlayerPXL            ; right side
  22.   lda PlayerPXH
  23.   adc #0
  24.   jsr GetLevelColumnPtr
  25.   sta BlockUR
  26.   tax
  27.   lda MetatileFlags,x
  28.   cmp #$80
  29.   rol FourCorners
  30.  
  31.   ;bottom
  32.   lda PlayerPYL
  33.   add #<(24*16)
  34.   lda PlayerPYH
  35.   adc #>(24*16)
  36.   tay
  37.   lda #0 ; left side
  38.   pha
  39.   add PlayerPXL            ; left side
  40.   lda PlayerPXH
  41.   adc #0
  42.   jsr GetLevelColumnPtr
  43.   sta BlockLL
  44.   tax
  45.   lda MetatileFlags,x
  46.   cmp BottomCMP
  47.   rol FourCorners
  48.   pla
  49.   add #$70
  50.   add PlayerPXL            ; right side
  51.   lda PlayerPXH
  52.   adc #0
  53.   jsr GetLevelColumnPtr
  54.   sta BlockLR
  55.   tax
  56.   lda MetatileFlags,x
  57.   cmp BottomCMP
  58.   rol FourCorners
  59.  
  60.   ; now call the right routine
  61.   ldx FourCorners
  62.   lda FourCornersH,x
  63.   pha
  64.   lda FourCornersL,x
  65.   pha
  66.   rts
  67.  
  68. FourCornersL: ; top left, top right, bottom left, bottom right
  69.   .byt <(FC_____ -1), <(FC____R -1)
  70.   .byt <(FC___L_ -1), <(FC___LR -1)
  71.   .byt <(FC__R__ -1), <(FC__R_R -1)
  72.   .byt <(FC__RL_ -1), <(FC__RLR -1)
  73.   .byt <(FC_L___ -1), <(FC_L__R -1)
  74.   .byt <(FC_L_L_ -1), <(FC_L_LR -1)
  75.   .byt <(FC_LR__ -1), <(FC_LR_R -1)
  76.   .byt <(FC_LRL_ -1), <(FC_LRLR -1)
  77. FourCornersH:
  78.   .byt >(FC_____ -1), >(FC____R -1)
  79.   .byt >(FC___L_ -1), >(FC___LR -1)
  80.   .byt >(FC__R__ -1), >(FC__R_R -1)
  81.   .byt >(FC__RL_ -1), >(FC__RLR -1)
  82.   .byt >(FC_L___ -1), >(FC_L__R -1)
  83.   .byt >(FC_L_L_ -1), >(FC_L_LR -1)
  84.   .byt >(FC_LR__ -1), >(FC_LR_R -1)
  85.   .byt >(FC_LRL_ -1), >(FC_LRLR -1)
  86.  
  87. FC_____:
  88. FC__RL_:
  89. FC_L__R:
  90.   rts
  91.  
  92. FC_LRLR:
  93.   lda PlayerPYL
  94.   sub #$a0
  95.   sta PlayerPYL
  96.   lda PlayerPYH
  97.   sbc #0
  98.   sta PlayerPYH
  99.   lda #0
  100.   sta PlayerVYL
  101.   sta PlayerVYH
  102.   rts
  103.  
  104. FC_LR_R:
  105.   rts
  106.  
  107. FC_LRL_:
  108.   rts
  109.  
  110. FC_L_LR:
  111.   jsr FC___LR
  112.   jmp FC_L_L_
  113. FC__RLR:
  114.   jsr FC___LR
  115.   jmp FC__R_R
  116.  
  117. FC__R_R:
  118.   lda #0
  119.   sta PlayerVXL
  120.   sta PlayerVXH
  121.   sta PlayerPXL
  122.   lda #$8f
  123.   sta PlayerPXL
  124.   lda BlockUR
  125.   cmp #Metatiles::GROUND_CLIMB_L
  126.   bne :+
  127. DoClimb:
  128.     lda #-1
  129.     sta PlayerVYH
  130.     lda #-$40
  131.     sta PlayerVYL
  132.     lda #10
  133.     sta PlayerJumpCancelLock
  134.     lsr
  135.     sta PlayerWalkLock
  136. : rts
  137.  
  138. FC_L_L_:
  139.   lda #0
  140.   sta PlayerVXL
  141.   sta PlayerVXH
  142.   sta PlayerPXL
  143.   inc PlayerPXH
  144.   lda BlockUL
  145.   cmp #Metatiles::GROUND_CLIMB_R
  146.   beq DoClimb
  147.   rts
  148.  
  149. FC_L___:
  150.   lda PlayerPXL
  151.   add #$40
  152.   sta PlayerPXL
  153.   lda PlayerPXH
  154.   adc #0
  155.   sta PlayerPXH
  156.   rts
  157.  
  158. FC__R__:
  159.   lda PlayerPXL
  160.   sub #$40
  161.   sta PlayerPXL
  162.   lda PlayerPXH
  163.   sbc #0
  164.   sta PlayerPXH
  165.   rts
  166.  
  167. FC_LR__:
  168.   lda #0
  169.   sta PlayerVYH
  170.   sta PlayerVYL
  171.  
  172.   ; check the block we bumped into
  173.   lda PlayerPYH
  174.   tay
  175.   lda #$40
  176.   add PlayerPXL
  177.   lda PlayerPXH
  178.   adc #0
  179.   jsr GetLevelColumnPtr
  180.   cmp #Metatiles::BRICKS
  181.   beq BreakBricks
  182.   cmp #Metatiles::PRIZE
  183.   beq OpenPrize
  184.   rts
  185.  
  186. OpenPrize: ; insert effects here
  187.   lda #Metatiles::USED_PRIZE
  188.   jsr ChangeBlock
  189.   lda #SFX::COIN
  190.   jsr PlaySound
  191.   jsr AddCoin
  192.   rts
  193. BreakBricks: ; insert effects here
  194.   lda #Metatiles::EMPTY
  195.   jsr ChangeBlock
  196.   lda #SFX::SMASH
  197.   jsr PlaySound
  198.   rts
  199.  
  200. FC___L_:
  201. FC____R:
  202. FC___LR:
  203.   ldx BlockLL
  204.   lda MetatileFlags,x
  205.   ldx BlockLR
  206.   cmp MetatileFlags,x
  207.   bne NotFallthrough
  208.     and #~M_POST_PROCESS
  209.     cmp #M_SOLID_TOP|M_FALLABLE_LEDGE
  210.     bne NotFallthrough
  211.       lda PlayerDownTimer
  212.       cmp #15
  213.       bcc NotFallthrough
  214.         rts
  215.   NotFallthrough:
  216.  
  217.   inc PlayerOnGround
  218.  
  219.   lda #0
  220.   sta PlayerVYH
  221.   sta PlayerVYL
  222.   lda #$80
  223.   sta PlayerPYL
  224.   lda keylast
  225.   and #KEY_A
  226.   bne :+
  227.   lda keydown
  228.   and #KEY_A
  229.   beq :+
  230.     lda #<(-$50)
  231.     sta PlayerVYL
  232.     lda #>(-$50)
  233.     sta PlayerVYH
  234.     inc PlayerJumping
  235.     lda #SFX::JUMP
  236.     jsr PlaySound
  237.   :
  238.   rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement