How do I make a breakable block reveal a warp tile?

cargo

spam bots yandex
Sorry if this has been asked before but does anyone have an example of how to make a breakable block reveal a warp tile? As in for adding a hidden room (or a shop) for the player to explore. I am guessing the command in question is the macro ChangeTileAtCollision at BreakableBlock.asm, but don't know what parameters to include.
 

dale_coop

Moderator
Staff member
In the "BreakableBlock.asm" script, at line 26, change the:
Code:
	ChangeTileAtCollision #$00, underStomp
for:
Code:
	ChangeTileAtCollision #$02, underStomp
Your broken block should now be a warp tile
 

chronosv2

New member
Dale's got the right answer there, but if you want breakable blocks to leave ground when you break them but have one reveal a warp you'll want to make a copy of the BreakableBlock script, make the change to the new script and make it a new tile type.
Modifying the code without making a copy first will make all breakable blocks reveal warp tiles.
Also you'll want to change underStomp to one of the other tile appearances you set up in the Assets sub-tree (like underSecret), or all breakable blocks will share the same destroyed appearance.
 

dale_coop

Moderator
Staff member
chronosv2 said:
Dale's got the right answer there, but if you want breakable blocks to leave ground when you break them but have one reveal a warp you'll want to make a copy of the BreakableBlock script, make the change to the new script and make it a new tile type.
Modifying the code without making a copy first will make all breakable blocks reveal warp tiles.
Also you'll want to change underStomp to one of the other tile appearances you set up in the Assets sub-tree (like underSecret), or all breakable blocks will share the same destroyed appearance.

Oh yes, you right, chronosv2.
Code:
	ChangeTileAtCollision #$02, underSecret
would be better.
 

cargo

spam bots yandex
Thanks for the help guys. Hex value #$02 is indeed the assigned ID for a warp tile in NESMaker's engine.

Now I have another problem:

+ The block only breaks when attacking horizontally from the left or the right.
+ The under tile appears at different locations (probably dependent on where the collision coordinates). I made a video about this as it is simpler to see it than to explain it:

[media]https://youtu.be/JQoiqxxic7Y[/media]

In the video I left the tile as null-walkable but if it were a warp tile the tile could potentially appear under the player and automatically change the screen. Is there a way to fix this? Better yet could we come up with a similar macro where we could pass the x, y coordinates of the specific tile on the screen?
 

chronosv2

New member
Unfortunately blocks not breaking properly is a known issue. I helped someone else create custom breakable block code and encountered the same problem. Hopefully 4.1.0 (which seems to be coming very soon) will fix this.
 

cargo

spam bots yandex
I don't mind being unable to break a block vertically but the incorrect pop up location of the under tile makes the feature unusable from my perspective. In my opinion the macro should use the coordinate of the breakable tile, not the location where it guessed the collision took place. It's not our fault of course but I find it interesting programming wise. Thanks again for the help.
 

chronosv2

New member
It's an unfortunate quirk of how the current collision code works. The one thing that I do know is that it checks the four corners one at a time, and if any of the corners triggers a collision it executes the code. It's particularly noticeable with longer weapon collision boxes.
 

cargo

spam bots yandex
Hey Dale you think you could fix this problem?
The feature is broken if the code can't place the undertile correctly.
 

dale_coop

Moderator
Staff member
cargo said:
Hey Dale you think you could fix this problem?
The feature is broken if the code can't place the undertile correctly.

Here's a temporary fix/workaround...
Replace your BreakableBlock.asm script with this one:
Code:
;; ASSUMES PROJECTILE or BREAKER OBJECT is #$03

;;; SOLID
;;;This is how to inform a solid collision.
;;; You can also add this to the end of
;;; any tile type if you want it to have an effect AND
;;; be treated like solid.
;;; You could also check to see if it is a non-player object,
;;; and only return solid if it's a not player.  This would
;;; cause monsters to treat things like spikes or ladder or fire
;;; as solid while the player is able to interract with it.


	LDA #TILE_SOLID
	STA tile_solidity
	
	;; if you want it solid, declare it at the end
	LDA Object_type,x
	CMP #$03 ;; is a projectile?  Change this is you want to use a different object #.
	BNE dontBreakThisBlock
	
checkWithCollisionTileTop:	
	LDA collisionPoint0
	ORA collisionPoint1
	BNE continueWithCollisionTileBottom
	;; collision with the tile from top
	LDA tileY
	ADC #$08
	STA tileY
	
continueWithCollisionTileBottom:
	LDA collisionPoint2
	ORA collisionPoint3
	BNE continueWithCollisionTileLeft
	;; collision with the tile from bottom :
	LDA tileY
	SBC #$08
	STA tileY

continueWithCollisionTileLeft:
	LDA collisionPoint0
	ORA collisionPoint3
	BNE continueWithCollisionTileRight
	;; collision with the tile from left
	LDA tileX
	ADC #$08
	STA tileX

continueWithCollisionTileRight:
	LDA collisionPoint1
	ORA collisionPoint2
	BNE continueBreakingThisBlock
	;; collision with the tile from right
	LDA tileX
	SBC #$08
	STA tileX

	
continueBreakingThisBlock:	
	;;ChangeTileAtCollision #$00, underStomp
	ChangeTileAtCollision #$02, underSecret
	PlaySound #SFX_BREAKABLE_BLOCK
	
dontBreakThisBlock:
 
Top Bottom