[4.1] Switching between Player and another Object (test)

User avatar
dale_coop
Posts: 3596
Joined: Fri Feb 16, 2018 7:05 am
Location: France

[4.1] Switching between Player and another Object (test)

Post by dale_coop » Fri Jan 11, 2019 11:44 pm

I made a simple script, that can with the Player with another Object (Game Object or Monster Object)... just a test for fun (has a lot of
Issues).



1/ Add a new "User Constant" in the "Script Settings > User Constants" tab, name it "OBJ_PLAYER_XTRA" and give it the value of the object index you want to use for your Player to switch to, for this example, I used "14".
But HERE, you can change to any object index you want to use to with! (monster objects start from 16).


2/ Make a script named for example "SwithPlayerToXtraObject.asm", with this code:

Code: Select all

;; change character to OBJ_PLAYER_XTRA
switchPlayerXTRA
	LDX player1_object
	LDA Object_x_hi,x
	STA newX
	LDA Object_y_hi,x
	STA newY
	DeactivateCurrentObject
	
	LDA playerToSpawn
	BEQ goSwitchingPlayerXTRA	
	;; put back tehe initial player object
	LDA #$00
	JMP continueSwitchingPlayerXTRA
goSwitchingPlayerXTRA:
	;; we use another one :
	LDA #OBJ_PLAYER_XTRA
continueSwitchingPlayerXTRA:
	STA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
	TXA
	STA player1_object
	
	;PlaySound #SND_TRANSFORM
	RTS

3/ Add this script to your "Input Scripts" and add this script to the "PRESS" "Select" button for example. When you press select it switch the character (more fast one, or invincible one, ...)!

Voilà, it's just a small test script, do whatever you want with it.

In fact, I would not recommend to use this script
In your great game, because it’s full of bug ;)

Need to work more on that before being useable.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
Redherring32
Posts: 450
Joined: Sat Aug 11, 2018 2:48 pm
Location: Usa

Re: [4.1] Switching between Player and another Object

Post by Redherring32 » Sat Jan 12, 2019 12:19 am

That's amazing! It'd be cool to use this to create the illusion of shape shifting. :)
My current WIP game: Shadow: An Adventure In Monochrome, you can also find me over at the Community Discord.
User avatar
dale_coop
Posts: 3596
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Switching between Player and another Object

Post by dale_coop » Sat Jan 12, 2019 12:34 am

Yep, it's just a sample of a script, to give an idea how to do... it's not perfect, seems to have some issues with others objects and maybe some collisions...
It's just fun!

I tried also with a monster object :

I made a tile, with some custom scripts (inspired from the TileCollectable.asm)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
Gilbertmaxter
Posts: 97
Joined: Tue Oct 16, 2018 3:04 am

Re: [4.1] Switching between Player and another Object (test)

Post by Gilbertmaxter » Sat Jan 12, 2019 12:52 am

Wow very cool
User avatar
Craigery
Posts: 30
Joined: Mon Apr 30, 2018 8:53 pm

Re: [4.1] Switching between Player and another Object (test)

Post by Craigery » Sat Jan 12, 2019 1:01 am

So much potential here! Also Dale you are a machine on the forums!
User avatar
Bucket Mouse
Posts: 321
Joined: Wed Mar 07, 2018 2:25 am

Re: [4.1] Switching between Player and another Object (test)

Post by Bucket Mouse » Sat Jan 12, 2019 3:52 am

dale_coop wrote:
Fri Jan 11, 2019 11:44 pm
3/ Add this script to your "Input Scripts" and add this script to the "PRESS" "Select" button for example. When you press select it switch the character (more fast one, or invincible one, ...)!

Voilà, it's just a small test script, do whatever you want with it.
Thing is, becoming fast or invincible is traditionally a temporary effect. This would be great for that sort of thing, but we would need a timer -- and I'm clueless as to how to build a timer. It would require making a loop that would allow for the rest of the game to pass by while it counted up or down. Possibly a subroutine. I would fail here math-wise because it would likely be a count over 255 and I wouldn't know how to get the time I want in asm/hex.

Off the top of my head....one variable, "TimerCount," increases each frame and another, "TimerArrival," equals the number TimerCount should stop at.

Code: Select all

TimerStart
	LDA TimerCount
	CMP TimerArrival
	BEQ TimerDone
	INC TimerCount
	RTS

TimerDone
	LDX player1_object
	LDA Object_x_hi,x
	STA newX
	LDA Object_y_hi,x
	STA newY
	DeactivateCurrentObject
	
	LDA #OBJ_PLAYER
	STA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
	TXA
	STA player1_object
	
	;PlaySound #SND_TRANSFORM
	RTS
Nobody try that -- I just posted it to get corrections and suggestions from Dale, who knows more than me.
User avatar
dale_coop
Posts: 3596
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Switching between Player and another Object (test)

Post by dale_coop » Sat Jan 12, 2019 11:05 am

You 're right Bucket Mouse, I would definitely use this script for becoming invincible is traditionally a temporary effect.
For the timer...

For the timer... you should try to add it to the GamerTimer, take a look what I did with the timer for my automatic recharge Ammo: http://nesmakers.com/viewtopic.php?p=10687#p10687
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
DanielT1985
Posts: 122
Joined: Sat Sep 01, 2018 7:44 pm

Re: [4.1] Switching between Player and another Object (test)

Post by DanielT1985 » Tue Jan 15, 2019 11:59 pm

If this can be possible, then does that mean people can add multiple playable characters into their game?
User avatar
dale_coop
Posts: 3596
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Switching between Player and another Object (test)

Post by dale_coop » Wed Jan 16, 2019 12:03 am

DanielT1985 wrote:
Tue Jan 15, 2019 11:59 pm
If this can be possible, then does that mean people can add multiple playable characters into their game?
I guess so... but would required a lot of code and scripts to manage that.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
Electric cat
Posts: 78
Joined: Sun Oct 07, 2018 4:09 am

Re: [4.1] Switching between Player and another Object (test)

Post by Electric cat » Mon Mar 25, 2019 5:06 am

Holy cow this is great,

OK SOO..
QUESTION 1. Can there we a way to make this sort of thing unlockable.

Question 2. If the above question is yes, then can this be used to give the player object a new ability?

Thank all for being so RAD!
Post Reply