Identify Which Collectable Tile?

crazygrouptrio

Active member
I have 2 collectible tiles using the same tile script. Is there a way to identify which is which so it can change to a different tile that matches it? i.e. when player touches collectible tile A it will change to tile A, when player touches collectible tile B it will change to tile B.

OR (if easier) as 2 different tilescripts, how could I make it so it checks the screen for both tiles before running NoMorePrize?

Using 2 player adventure module.
 

dale_coop

Moderator
Staff member
If you have unused tile collision you could use 2 scripts... else, to reply directly to your question, here an example of script with a code that determines which tile type:
Code:
CPX player1_object
BNE ++

	;; get collision type of the current tile
	JSR GetTileAtPosition
	JSR DetermineCollisionTable

	;; checking if 14 type tile:
	CMP #14	
	BNE +
		;; it IS type 14
		ChangeTileAtCollision #$00, #$22
		JMP ++
	+

	;; checking if 15 type tile:
	CMP #15
	BNE +
		;; it IS type 15
		ChangeTileAtCollision #$00, #$4C
		JMP ++
	+

	;; else:
	;; here
	
	
++  ;;end
 

crazygrouptrio

Active member
I tried using 2 tile scripts first, but it didn't count all of the collectibles on the screen before doing the "you got them all" prize thing. Once I got half of them it triggered that they were all collected.

If it isn't clear, I'm not talking about 2 tile types. I'm wanting 1 tile type to change to 2 different graphics at collision, or 2 collectable tiles that add up correctly together. I don't really care which, but both methods have me stumped...
 

SciNEStist

Well-known member
the part of the script with "ChangeTileAtCollision #$00, #$22" changes the collectable tile to tile #22, correct? so before that part, we would need to have a way of branching it out based on what the current tile is.
Is there a way to retrieve the tiles number, or even pallette? if so, that might be where to start. This is all still a little beyond my abilities though.

One other way I can think of is to use the pallets in a very tricky way. IF you are clever enough to hide one shape inside another, you can make 1 sprite look like 2 different things just by changing the pallets.

For example:
 

Attachments

  • example.png
    example.png
    14 KB · Views: 1,908

crazygrouptrio

Active member
Yeah that's about as far as I've gotten too :p Really I just need a way to say "oh is it this tile? then change it to this instead" but I can't find what that would be. Ideally it would be an LDA something and CMP with the tile's number, but I don't know what it would be to specify it... i might be able to work something out with palettes but it would take away one of my palettes just to make it work and I'd rather not do that.
 

dale_coop

Moderator
Staff member
Sorry I misunderstood. Yeah you want 1 Tile Type... but 2 different gfx.
Hmmm not sure how to check that.
 

crazygrouptrio

Active member
It's a hard thing to explain :p So it would be easier to have 2 collectible tiles so they can change to their own tile graphic, but i need the game to count them both, because right now it only counts 1 of them and makes that the total. But i don't know where that's handled in the code.
 

dale_coop

Moderator
Staff member
Just duplicate the Collectable.asm script... (modify it to your needs for your tile / rename the labels).
It should work, it's that script used in the count, for the no more prize.
 

crazygrouptrio

Active member
dale_coop said:
Just duplicate the Collectable.asm script... (modify it to your needs for your tile / rename the labels).
It should work, it's that script used in the count, for the no more prize.

Mmmm definitely not. I placed just 2 each of the 2 collectable tiles. After collecting 2 out of 4 it thinks I collected all of them. It's only counting the total of collectable tiles for the original tile type (tile type 8). But it is counting both tile types towards that total. If there are 3 tiles of collectable tile type 8 and any number of the second tile type, and I collect 3 of the second tile type it will think I collected all collectables on screen. (Ugh this is getting confusing :? ) I haven't done anything to either tile script other than setting the ChangeTileAtCollision for each (and labels)
Code:
	CPX player1_object
	BEQ isPlayerForCollectable
	CPX player2_object
	BEQ isPlayerForCollectable
	JMP ++
isPlayerForCollectable:
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+
	LDA #$01
	STA tileCollisionFlag
	

	ChangeTileAtCollision #$00, #$02
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	TXA
	STA tempx	
	
	; AddValue #$08, myScore, #$01, #$00
	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	; STA hudElementTilesToLoad
	; LDA #$00
	; STA hudElementTilesMax
	; UpdateHud HUD_myScore

	PlaySound #SND_GET
	; LDA #$00
	; STA value
	; STA value+1
	; STA value+2
	; STA value+3
	; STA value+4
	; STA value+5
	; STA value+6
	; STA value+7	
	
	LDX tempx
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	DEC screenPrizeCounter
	LDA screenPrizeCounter
	CLC
	BNE ++
	
	;;; do whatever should happen if you collect all of the prizes on this screen.
	JSR HandleNoMorePrizeTiles

++
 

crazygrouptrio

Active member
So. The way I've temporarily gotten around this issue is by checking the player's direction. The 2 collectable tiles are horizontal and vertical tiles. So instead of using 2 tiles, I'm using 1 tile to check which way the player is facing to determine which graphic to change the tile to. This may cause issues in the future, but for now it works fine.
Code:
LDX player1_object      
    LDA Object_movement,x
    AND #%00001111
    CMP #%00000110
	BEQ doHorizontalTile
	CMP #%00000010
	BEQ doHorizontalTile
	
	ChangeTileAtCollision #$00, #$04
	JMP doneTileChange
	doHorizontalTile:
	ChangeTileAtCollision #$00, #$02
	doneTileChange:
 
Top Bottom