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

Post Reply
User avatar
cargo
Posts: 131
Joined: Mon Sep 03, 2018 4:34 am

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

Post by cargo » Thu Dec 06, 2018 1:43 am

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.
User avatar
dale_coop
Posts: 3489
Joined: Fri Feb 16, 2018 7:05 am
Location: France

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

Post by dale_coop » Thu Dec 06, 2018 8:58 am

In the "BreakableBlock.asm" script, at line 26, change the:

Code: Select all

	ChangeTileAtCollision #$00, underStomp
for:

Code: Select all

	ChangeTileAtCollision #$02, underStomp
Your broken block should now be a warp tile
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
chronosv2
Posts: 254
Joined: Wed Aug 08, 2018 9:30 pm
Location: KY, USA
Contact:

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

Post by chronosv2 » Thu Dec 06, 2018 3:41 pm

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.
ASM/C# Coder -- Computer + Coffee = Code
ASM Tutorial Series
My NES development projects have, for the time being, stagnated. I apologize for the inconvenience.
User avatar
dale_coop
Posts: 3489
Joined: Fri Feb 16, 2018 7:05 am
Location: France

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

Post by dale_coop » Thu Dec 06, 2018 4:27 pm

chronosv2 wrote:
Thu Dec 06, 2018 3:41 pm
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: Select all

	ChangeTileAtCollision #$02, underSecret
would be better.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
cargo
Posts: 131
Joined: Mon Sep 03, 2018 4:34 am

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

Post by cargo » Thu Dec 06, 2018 4:59 pm

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:



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?
Last edited by cargo on Sat Dec 29, 2018 3:12 am, edited 1 time in total.
User avatar
chronosv2
Posts: 254
Joined: Wed Aug 08, 2018 9:30 pm
Location: KY, USA
Contact:

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

Post by chronosv2 » Thu Dec 06, 2018 6:45 pm

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.
ASM/C# Coder -- Computer + Coffee = Code
ASM Tutorial Series
My NES development projects have, for the time being, stagnated. I apologize for the inconvenience.
User avatar
cargo
Posts: 131
Joined: Mon Sep 03, 2018 4:34 am

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

Post by cargo » Thu Dec 06, 2018 7:20 pm

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.
User avatar
chronosv2
Posts: 254
Joined: Wed Aug 08, 2018 9:30 pm
Location: KY, USA
Contact:

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

Post by chronosv2 » Fri Dec 07, 2018 2:32 am

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.
ASM/C# Coder -- Computer + Coffee = Code
ASM Tutorial Series
My NES development projects have, for the time being, stagnated. I apologize for the inconvenience.
User avatar
cargo
Posts: 131
Joined: Mon Sep 03, 2018 4:34 am

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

Post by cargo » Sat Dec 29, 2018 8:39 am

Hey Dale you think you could fix this problem?
The feature is broken if the code can't place the undertile correctly.
User avatar
dale_coop
Posts: 3489
Joined: Fri Feb 16, 2018 7:05 am
Location: France

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

Post by dale_coop » Sat Dec 29, 2018 1:16 pm

cargo wrote:
Sat Dec 29, 2018 8:39 am
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: Select all

;; 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:
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
Post Reply