Changing background tiles when walking over them?

timkilgore

New member
Hello all,

I think the adventure module would probably be great to make kind of a pac-man type game where you collect items in a room to move to the next room. If I were going to handle this by using the object grab I wouldn't be able to place enough of them throughout the room without crazy amounts of flicker or wouldn't even be able to due to limitations. Any ideas on how I could change a background tile after walking over it?

Thanks everyone in advance for any help I can get :)
 

Bucket Mouse

Active member
Mihoshi is working on a game called Trial By Fire:

https://youtu.be/7_p_byf4UJk

One of the mechanics in the game is to walk over a tile, which changes a bunch of other tiles. He had to use some custom code from Dale_Coop to get that effect. With a little modification, it's possible that code could do what you're looking for. Ask either of 'em.
 

dale_coop

Moderator
Staff member
Yes of course...
For example, you could make a script like this:
Code:
;; CHANGE to a "0 - Walkable" special Tile "UnderSecret"

	CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedChangingTile
	
	ChangeTileAtCollision #$00, underSecret
	PlaySound #SFX_GET_COIN
	
finishedChangingTile:
	;;RTS
Save it as "ChangeToWalkableUndesecretTile.asm" in your "TileScripts" folder.
(if you want to use another special tile, just change undersecret to another one).

Then in "Project Settings > Scripts Settings", assign that script to the "Tile Collision XX" of your choice (an unused one) and rename the Tile Type in "Project Labels"

Voilà
 

Mihoshi20

Member
dale_coop said:
Yes of course...
For example, you could make a script like this:
Code:
;; CHANGE to a "0 - Walkable" special Tile "UnderSecret"

	CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedChangingTile
	
	ChangeTileAtCollision #$00, underSecret
	PlaySound #SFX_GET_COIN
	
finishedChangingTile:
	;;RTS
Save it as "ChangeToWalkableUndesecretTile.asm" in your "TileScripts" folder.
(if you want to use another special tile, just change undersecret to another one).

Then in "Project Settings > Scripts Settings", assign that script to the "Tile Collision XX" of your choice (an unused one) and rename the Tile Type in "Project Labels"

Voilà

This would be cool for like a footprints in the sand like effect.
 

Rob Burrito

New member
Awesome Dale! you're racking up some serious programming karma helping folks out. i wouldn't know how to write it but i think they would be looking to add a score to that tile as well. could do a bit with that tile you wrote, did you add it to the "code" section?
 

dale_coop

Moderator
Staff member
Rob burrito, no didn't made a post in the "code" section, because it's a small code :p

But if you want to increase one of your variable (myScore or myMoney)... it would add complexity, because tile script is executed repeatedly when the player stays on the tile :p
But with some tricky code, you could add Score, using variable for check if you are already on the tile, to skip the code.
 

Bucket Mouse

Active member
dale_coop said:
Yes of course...
For example, you could make a script like this:
Code:
;; CHANGE to a "0 - Walkable" special Tile "UnderSecret"

	CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedChangingTile
	
	ChangeTileAtCollision #$00, underSecret
	PlaySound #SFX_GET_COIN
	
finishedChangingTile:
	;;RTS
Save it as "ChangeToWalkableUndesecretTile.asm" in your "TileScripts" folder.
(if you want to use another special tile, just change undersecret to another one).

Then in "Project Settings > Scripts Settings", assign that script to the "Tile Collision XX" of your choice (an unused one) and rename the Tile Type in "Project Labels"

Voilà

Okay, Version 4.11 is bugging out on me....it only lets me make ONE change to the screen and then it won't update the ROM after that. I originally thought it had something to do with this code, but further testing shows the problem up and down the board. I have no idea why. But I should mention that this game started in 4.06 and I moved it to 4.11. Sometimes it works for me and sometimes it doesn't.

It works on 4.06 BUT your line for the Coin sound effect has to be different in that version:

Code:
	PlaySound #$00, #$00
The numbers are in the order they are uploaded; "Coin" happens to be first. The second number establishes the priority (meaning the sound effect must be heard over the music).

The sound plays only the first time you step there, and the original image does not reappear unless you leave the screen, so....that's the good news; we don't have to write arguments for that stuff!

The bad news is that this activates when the first pixel of your player sprite touches the tile, so the coins will vanish right before he gets there. If the walking speed is set high enough, players may not notice. Another fix might be setting the player's bounding box further inward, but that might introduce other problems.

The footprint idea won't really work if the footprints appear ahead of the player. Perhaps it could be rigged to appear when the player steps OFF, or when he's midway through crossing it. I wouldn't know how.

Finally: if you erase the ChangeTile line and just have the tile make a noise, the tile will make that noise every time you step on it. Also, the noise will be longer and more drawn out. Weird.
 
Top Bottom