4.5.6 collect items to Warp to next level tile

jcramer

New member
This is a tile that warps you after you collect all the tiles on screen. All your levels will need the same amount of collectables, unless you use the multi-tile or something.


Step 1. Create a variable called "myCollect" with an initial value of 0.

Step 2. Create a new tile.

CollectLevelClear.asm

Code:
 ;;; COLLECT LEVEL CLEAR TILE


   
CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	INC myCollect
        LDA myCollect
        CMP #$06 ;;;;;;; HOW MANY TO COLLECT????
        BEQ +enough
		
        JMP +notEnough
	;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	+enough

        JMP +doTheWarp

        +notEnough
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	+notPlayer
	JMP +noWarpYet
	+doTheWarp
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	CPX player1_object
	BNE notPlayerForWarpTiles
	
	WarpToScreen warpToMap, warpToScreen, #$01
		;; arg0 = warp to map.  0= map1.  1= map2.
		;; arg1 = screen to warp to.
		;; arg2 = screen transition type - most likely use 1 here.
			;; 1 = warp, where it observes the warp in position for the player.
notPlayerForWarpTiles:
	
	+noWarpYet

Step 3. add these lines of code to Game > Subroutines > doLoadScreen.asm around line 495, this resets the count of collectables back to zero every time you die or leave the screen.

Code:
	LDA #$00 
	STA myCollect
 

mouse spirit

Well-known member
I say do it with variables.
Create a variable.
Colleting a tile can increase the variable.
When variable equals ...10(or whatever)
Do warp.
 

mouse spirit

Well-known member
Me too.
Make a user variable.
When the tile pickup script is ending for that exact pickup item, toss in a

Code:
INC (variable name here)

And in the warp, toss in a
Code:
LDA (var name here)
CMP #$09
BEQ doWarpCode
RTS
doWarpCode:
(Heres your warp code.)

Change numbers as you see fit.
 

mouse spirit

Well-known member
If you post those codes i can try to edit them for you. And i will repost them . Like the pickup item or tile script and the warp code you are using.Just be sure to keep backups.
Also i edited my previous post. If you put that in front of your warp code i think it should work.
 

jcramer

New member
Here's what i got. It compiled, but didn't have any effect.

Prize_MazeBase_withCollect.asm
Code:
;;; prize tile

CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	+notPlayer
	
	INC myCollect

WarpToScreen_MazeBase_withCollect.asm

Code:
;;; prize tile

CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	
	+notPlayer
	
	INC myCollect
 

mouse spirit

Well-known member
Take out the last 5 lines of warptoscreen mazebase.
Actually maybe leave RTS.
Go ahead and make the number at CMP to #$01, for super simple testing.

Lastly is the warp a tile script or where do you place that asm? Because if that warp is a tile you would have to walk over that tile.
 

mouse spirit

Well-known member
So make the collect tile and the warp tile combined as one tile that never warps unless you have the correct ammount of collections. That way you are walking on that warp tile.Also make the tile NOT change if the amount is collected.
I will try to make it here,although i am on my phone i bet i can copy and paste fine.
i think what you have is almost there, very close.
 

mouse spirit

Well-known member
Hm. I was trying but the scripts changed. Hha i think you may have editted the post. But yeah so say
"Increase variable.
If not enough collections,change tile and collect,
but if the correct amount was just collected instead goto warp script,
not change tile."

Also inc variable at the begining of the code for this to work right. As so you can then say on that last collectable

"Ive collected it,
its the right number,
so skip changetile part of code
and do warp code."
 

jcramer

New member
here it is combined. (yes, its a tile). now it it wont compile, error on line 41 notPlayerForWarpTile, label already defined. but if i comment it out i get errors on 31 and 34 doWarpCode, unknown label

Code:
;;; prize tile

CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	
	+notPlayer
	
	INC myCollect
	
	LDA myCollect
	CMP #$01
	BEQ doWarpCode
	dowarpcode:
	CPX player1_object
	BNE notPlayerForWarpTile
	
	WarpToScreen warpToMap, warpToScreen, #$01
		;; arg0 = warp to map.  0= map1.  1= map2.
		;; arg1 = screen to warp to.
		;; arg2 = screen transition type - most likely use 1 here.
			;; 1 = warp, where it observes the warp in position for the player.
    
    notPlayerForWarpTile:
	
    RTS
 

mouse spirit

Well-known member
Try this but throw your warp code in here..but just the simple warp code. As i should have it set up right here.

Code:
 ;;; prize tile


   
CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	INC myCollect
        LDA myCollect
        CMP #$ 01
        BEQ +enough
        +notEnough
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	+enough

        JMP +doTheWarp

        +notEnough
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	+notPlayer
	JMP +noWarpYet
	+doTheWarp
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;;;;YOUR WARP CODE HERE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	+noWarpYet
 

mouse spirit

Well-known member
No problem, i figured .

Yes so heres for the error you have....

You can say JMP dowarpcode as much as you like
Or beq dowarpcode.....

But the place they are jumping to "dowarpcode" can only exist once.

So on the next time you need similar code, simply name it "dowarpcodes" that time. Just has to be different.
 

jcramer

New member
it worked. adding the s fixed it lol.

Code:
 ;;; prize tile


   
CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	INC myCollect
        LDA myCollect
        CMP #$01
        BEQ +enough
        +notEnough
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
	+enough

        JMP +doTheWarp

        +notEnough
	ChangeTileAtCollision #$00, #$00
	
	;MACRO AddValue arg0, arg1, arg2, arg3
	;arg0 = how many places this value has.
	;arg1 = home variable
	;arg2 = amount to add
	;arg3 = what place value is receiving the addition?
		;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
	
	AddValue #$06, myScore, #$1, #$02
	UpdateHudElement #$03
	
	;PlaySound #sfx_cursor
	
	+notPlayer
	JMP +noWarpYet
	+doTheWarp
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	CPX player1_object
	BNE notPlayerForWarpTiles
	
	WarpToScreen warpToMap, warpToScreen, #$01
		;; arg0 = warp to map.  0= map1.  1= map2.
		;; arg1 = screen to warp to.
		;; arg2 = screen transition type - most likely use 1 here.
			;; 1 = warp, where it observes the warp in position for the player.
notPlayerForWarpTiles:
	
	+noWarpYet
 

jcramer

New member
Should be a useful code for anyone looking here, too. A maze game leaves something to be desired if you can just walk strait to the exit.
 

mouse spirit

Well-known member
Very true. Maybe even edit the first post to reflect this or even change the title to have (solved) in it.
Im glad we figured it out.
 

mouse spirit

Well-known member
Youre welcome. I like helpin and it helps me practice and get better also.
Im down for doin whatever i can so ask away.
 
Top Bottom