[4.5.9] Breakable blocks

9Panzer

Well-known member
@CutterCross helped alot to tune up my code on the discord server I figured I would share this because its really cool lol.
I wanted a monster to shoot at the player and destroy the blocks that the shot hits. This was the effect I was going for in this boss fight:


I added a bit of flare to the collision to make it look like a massive explosion but for this tutorial I will just show the basic parts.

Step 1: Setup a new .ASM with this as your code. I called this "Breakable Tile".

;;; SOLID FOR ALL OBJECTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LDA ObjectUpdateByte
ORA #%00000001
STA ObjectUpdateByte

LDA Object_type,x
CMP #9 ;;; Which Object do we want to use?
BEQ +
JMP +end
+
LDA Object_frame,x
LSR
LSR
LSR
AND #%00000111
CMP #6 ;;;;; ActionSTEP of the Weapon
BEQ +
JMP +end
+
ChangeTileAtCollision #78, #0
+end:
RTS

Step 2: Set this as a tile in your script settings. I used Tile #4 in this.

Step 3: create an object that will break these tiles. In my example I choose Object #9 and its action step #6 (Since the monster creates the object I wanted only action step 6 to break the tile)

Step 3: you have a breakable tile but its not solid. So you need to add a bit in your physics scripts. These lines are around 570 for me but my scripts have been heavily modified so you will probably just want to look for the line " ;;; CHECK FOR SOLID TILE, which is tile type 1 in this module." Just below that it starts checks for solid. You need to add a piece here for our tile #4 (Or whatever tile you picked).

;;; CHECK FOR SOLID TILE, which is tile type 1 in this module.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; In this module, we have
;; 1 = solid
;; 7 = one way platform
;; 9 = prize block, which behaves as a solid
;; 10 (0A) = ladder, whose top behaves like a solid.
;; Here is where we handle the "landing" scenario for all of those possibilities.

GetCollisionPoint temp, temp1, tempB ;; is it a solid?
BNE +check

GetCollisionPoint temp3, temp1, tempA ;; is it a solid?
+check
CMP #$01
BNE +isNotSolid
JMP +isSolid
+isNotSolid

;;;;; ADD THIS PART ;;;;;
CMP #$04
BNE +isNotSolid
JMP +isSolid
+isNotSolid

Add your tiles and smash away! Remember I choose a very specific object and action step to do this. So you will need to setup what works for you.
I hope someone finds this useful!
 
Top Bottom