4.5.6 collect items to Warp to next level tile

mouse spirit

Well-known member
Ok so maybe its increasing alot.
Can you try the script i posted earlier but insert your warp script into it?
Im sorry, maybe thats what you did.
 

mouse spirit

Well-known member
I see the issue. Put JMP before that first +notenough
Code:
 ;;; prize tile


   
CPX player1_object
BEQ +isPlayer
	JMP +notPlayer
	+isPlayer
	INC myCollect
        LDA myCollect
        CMP #$01
        BEQ +enough
        JMP +notEnough;;;;;;Right here
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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
 

mouse spirit

Well-known member
And alldarn is right, this is great....As long as it works!
We will get it.

Part 2 would be easily changing the amount when you want.So instead of making it CMP (a number),
have it CMP (a variable).

So create a variable (amountToCollect),find a good way
to set this variable at the begining of a level.
use our same code but replace the numbers with our
variable.
 

AllDarnDavey

Active member
mouse spirit said:
So create a variable (amountToCollect),find a good way
to set this variable at the begining of a level.
use our same code but replace the numbers with our
variable.

Yeah, you'd need a way to set the variable per screen too. Otherwise you'd need to design your game with the same number of collectables in every level. Not an easy task.

When you get all the kinks worked out you might want to look at combining it with the Marvelous Multi-Tile Then you could have a variable tile, that looks for a different number of collectables per screen.
 

mouse spirit

Well-known member
I love that tile!

Another idea, simply INC this new variable say "3" times each time a level is beaten.

Or even set different amounts by screentype in the code.

First 5 levels can be screentype 1.
Next 5 levels are screentype 2.

Screentype 1 needs 10 items collected.
Screentype 2 needs 15 items collected.
 

jcramer

New member
ok, it works now. edited on original post. One small problem is, it doesn't work anymore after I die, but that might just be from the weird way I set my game up.
 

mouse spirit

Well-known member
Make sure to reset variable to #$00 after death or right before death animation or something.

LDA #$00
STA (variable)

Hopefully this fixes that issue at death.
 

mouse spirit

Well-known member
Only do this if your level resets too. As to have equal collectables on the screen as well as the "how many i need" counter..
 

TolerantX

Active member
my solution instead of changing a doLoadScreen.asm (because honestly I don't have anything in script settings that "ties" to it. Things like this make me very apprehensive to do the edit, so I made my own solution that may work. Keep in mind this is from my byte off demo scripts so it will be different from yours...

This is a tile I am using as a WARP IN TILE: it resets the variable to collect to get to next level and the number used in hud.

Code:
CPX player1_object
BEQ +isPlayer
	JMP +notPlayer

+isPlayer

		LDA #$00
		STA needCollect
		
		LDA #$00
		;STA myKills
		STA myMoney
		UpdateHudElement #$05
		
;;;;; BELOW WILL CHANGE TILE AT COLLISION.

		ChangeTileAtCollision #$00, #$00
	
+notPlayer:

;;; sets a new player continue checkpoint.
	CPX player1_object
	BNE +skips
	LDA currentNametable
	STA continueScreen
	LDA Object_x_hi,x
	STA continueX
	LDA Object_y_hi,x
	STA continueY
	
+skips

also, I am not using this in my game. I only am using it as a great way to test my collect to warp things. Thank you for this awesome script!
 
Thanks! I was just working on something like this.


I wonder if there is a way to make the tile check collisions for all tiles on the screen.

The idea is that if colliding with the collectible tile changes it to a walkable tile (00), then it follows that when you collide with the last one, there are no more tile type 5 on the screen. Basically:
- Check it see if there are any tile type 5s on the screen
- If yes, then this isn't the last collectible.
- If no, this is the last collectible. Warp.
 

mouse spirit

Well-known member
Might do fine. But i think a variable that matches the amount of pickups on screen may take alot less cpu or whatever. Then when variable equals maxvariable, warp.
 

Arctic Blizzard

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
Thanks for posting this on Facebook. I was working on a maze game this is way helpful since I virtually know nothing about coding. I'm still super new to all of this. I got the script kind of working. I just need to insert the second part of the code. But I currently don't have the doLoadScreen.asm script loaded in my game.
Do I load the script doLoadScreen?
Or is there another script in my game to put that code?
 
Last edited:
Top Bottom