Drawing or switch a BG tile with another one?

drexegar

Member
Just like how you get a check point and the tile switches to whatever you want or a collectible tile changing to a blank tile,

is there a manual way to:

- Get tile position on screen
- switch it with another bg tile from the current bg graphics

Or is it something similar to the sprite drawing code like a macro.
 

AllDarnDavey

Active member
Yes, you're looking for the Macro "ChangeTileAtCollision"
Here's its definition:
MACRO ChangeTileAtCollision arg0, arg1
;; this changes a tile at the current point of collision.
;; collision is determined by what is currently loaded into the
;; tileX and tileY variables.

;; arg0 - new collision type
;; arg1 - starting tile number of new metatile.
LDA #$01
STA tileCollisionFlag

When you collide with a tile using this in its tile collision script it will swap the tile with the the 16x16 tile whose upperleft address is arg1, and you can change the tile collision flag to something different using arg0.

Or do you mean changing a tile without a collision?
 

drexegar

Member
AllDarnDavey said:
Yes, you're looking for the Macro "ChangeTileAtCollision"
Here's its definition:
MACRO ChangeTileAtCollision arg0, arg1
;; this changes a tile at the current point of collision.
;; collision is determined by what is currently loaded into the
;; tileX and tileY variables.

;; arg0 - new collision type
;; arg1 - starting tile number of new metatile.
LDA #$01
STA tileCollisionFlag

When you collide with a tile using this in its tile collision script it will swap the tile with the the 16x16 tile whose upperleft address is arg1, and you can change the tile collision flag to something different using arg0.

Or do you mean changing a tile without a collision?

This is very helpful too! but yes without collision.
does this work for monsters with collision? If it does then there is a desperate way I can change tiles.

Im working on a 3d road, and I want the background to move, if I can control just one row of tiles to change to give an illusion of scrolling, I would be fine. If not im going to have to just resort to more pallete swapping.
 
Top Bottom