Changing player object upon warp-into flagged screen

User avatar
Raftronaut
Posts: 307
Joined: Mon Sep 03, 2018 4:47 pm

Changing player object upon warp-into flagged screen

Post by Raftronaut » Wed Aug 14, 2019 5:06 pm

Hello!

I have a somewhat complex request for help here that I believe I understand the steps needed to accomplish but need some help with the details.

My goal is to utilize my first screen flag slot: "single screen game" to initiate a MAZE mini-game when I warp my player into a room with that flag checked. I am currently using the shooter module, so this would be an entirely new gameplay style I would be adding to my game. I have Plenty of game object slots available as well so I hope to change player game object upon warping into a room, and the ability to switch between 4 playable characters (either cycled through with inputs or perhaps better yet by collecting powerups).

So to break down my work flow I have made a list of the things I would need to achieve in order to accomplish my goal here:

A) Study and adapt the ChangePlayerObject script to change Character object upon warping into the screen containing the screen flag "single screen game" slot #1.. I believe this can be done utilizing Dale Coop's experimental script posted in the archives:
http://nesmakers.com/viewtopic.php?f=3&t=1760

B) Change player death object to something other than my current vehicle explosion from the shooter module. Since the sprites will be different for this section it will need a separate animation.

C)Set up victory conditions for when player consumes all collectables within a room that has "single screen" flag checked. I already have collectibles for score in my shooter game, so I would need to determine victory ONLY occurs when "Single screen" flag is checked...

D) Set up Maze game power up for frantic arcade munching invincibility

E) Create some sort of branch that disables my projectile powerup from the shooter module. Either disabled or Reassigned to a new function.
I had considered adding a melee attack here, or perhaps use the button to switch between characters..( Although I think I like the idea of collecting Powerup (or tile) to change between the 4 characters. It would give me the opportunity to add colorful powerup sprites and add to the graphical variety of my game. PLUS< my game is woefully short on powerups currently and I have PLENTY of slots available.)


I understand this is a complicated series of requests, but I am fairly sure my thought process on getting each of these steps to work are correct. If I am overlooking anything or incorrectly planning something, please let me know. I am not sure that Changing "game states" has been attempted yet, I am sure others would find this process helpful if I can get it working.

Many of my favorite NES games had multiple play styles involved, so this may be the first small step towards doing something influenced by guardian legend, blaster master, goonies II, Zelda 2, Startropics overworld etc..
Space Raft demo updates: [url]http://nesmakers.com/viewtopic.php?f=52&t=2867[/url]

Chiptune:[url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
Mugi
Posts: 771
Joined: Thu Dec 27, 2018 8:30 pm

Re: Changing player object upon warp-into flagged screen

Post by Mugi » Wed Aug 14, 2019 5:15 pm

I created a variable based alteration for spawning the player object in my stage selection code (find it from the archive subforum) which explains how to edit handlescreenloads player spawning code to check for a variable
and spawn a different object to act as a player depending on the status of the flag.

to read singlescreen mode screen flag, you can use LDA screenflags and read the byte from it you need.
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
dale_coop
Posts: 4463
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Changing player object upon warp-into flagged screen

Post by dale_coop » Wed Aug 14, 2019 6:57 pm

Mugi's right... But if you want to check screenFlag, you will have to put your code after that the screen is loaded.
So, as I replied to you on the Discord channel... for example, in the "HandleScreenLoads.asm" script, around line 313 or around... you will find:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;END LOADING SCREENS.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
So just after, that, you can add a code of block like that:

Code: Select all

LDA screenFlags
    AND #%10000000
    BEQ +
    LDX player1_object
    DeactivateCurrentObject
    LDA #OBJ_PLAYER_2
    STA playerToSpawn    
    CreateObject newX, newY, playerToSpawn, #$00, currentNametable
    STX player1_object
    +
And in your user constants ("project Settings > User constants") find the "OBJ_PLAYER_2" constant and set it the the Game Object you want to use instead of your Player object ;)
-----
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
Raftronaut
Posts: 307
Joined: Mon Sep 03, 2018 4:47 pm

Re: Changing player object upon warp-into flagged screen

Post by Raftronaut » Wed Aug 14, 2019 9:07 pm

Mugi wrote:
Wed Aug 14, 2019 5:15 pm
I created a variable based alteration for spawning the player object in my stage selection code (find it from the archive subforum) which explains how to edit handlescreenloads player spawning code to check for a variable
and spawn a different object to act as a player depending on the status of the flag.

to read singlescreen mode screen flag, you can use LDA screenflags and read the byte from it you need.
Good tip! thanks for pointing me to it!
To clarify you are pointing specifically to:
[url] http://nesmakers.com/viewtopic.php?f=40&t=1788&hilit=handlescreenloads [/url]
(not sure why my URL links never work) I'll dig through this for the info on the variable
dale_coop wrote:
Wed Aug 14, 2019 6:57 pm
Mugi's right... But if you want to check screenFlag, you will have to put your code after that the screen is loaded.
So, as I replied to you on the Discord channel... for example, in the "HandleScreenLoads.asm" script, around line 313 or around... you will find:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;END LOADING SCREENS.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
So just after, that, you can add a code of block like that:

Code: Select all

LDA screenFlags
    AND #%10000000
    BEQ +
    LDX player1_object
    DeactivateCurrentObject
    LDA #OBJ_PLAYER_2
    STA playerToSpawn    
    CreateObject newX, newY, playerToSpawn, #$00, currentNametable
    STX player1_object
    +
And in your user constants ("project Settings > User constants") find the "OBJ_PLAYER_2" constant and set it the the Game Object you want to use instead of your Player object ;)
Ok Great, I will get started on this with my next session :)

One more quick question though, I was thinking I could create all 4 playable characters under the same game object using different animation types. Though I realized one of my 4 characters is taller (2x3 sprites instead of 2x2 sprites) so If I used the same game object to save space there would be bounding box issues between the different character heights. I think I have 9 game object slots open yet.

Since I have the space available, Should I reserve one game object per character? I presume that would afford me the greatest flexibility in the future if I decided to give them unique abilities, movement speeds, bounding boxes, etc...

Is this the smartest way to organize them?
Space Raft demo updates: [url]http://nesmakers.com/viewtopic.php?f=52&t=2867[/url]

Chiptune:[url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
dale_coop
Posts: 4463
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Changing player object upon warp-into flagged screen

Post by dale_coop » Wed Aug 14, 2019 9:31 pm

You can’t ise the same game object for all your characters... because the Player uses several actions steps. When idle, when walking, attacking, shooting,...
So it’s not possible to use a unique object...

You need 1 object per character!
But you could save objects with you Monster Death animations... a death animation uses 1 action step and no other specific flag.
Si rhetorically you could use 2 death object for 8 different death animations !
Just with a minor modification in the death scripts for 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
Raftronaut
Posts: 307
Joined: Mon Sep 03, 2018 4:47 pm

Re: Changing player object upon warp-into flagged screen

Post by Raftronaut » Thu Aug 15, 2019 3:43 am

Also, I just noticed I would need to use a monster object in order to change player palettes. Since PLayer object defaults to only two palettes correct?
Space Raft demo updates: [url]http://nesmakers.com/viewtopic.php?f=52&t=2867[/url]

Chiptune:[url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
dale_coop
Posts: 4463
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Changing player object upon warp-into flagged screen

Post by dale_coop » Thu Aug 15, 2019 7:54 am

Yep you could also use monster objects (if you want use different color palettes), it would work too.
-----
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
Raftronaut
Posts: 307
Joined: Mon Sep 03, 2018 4:47 pm

Re: Changing player object upon warp-into flagged screen

Post by Raftronaut » Thu Aug 15, 2019 7:29 pm

Ok Great, I am going to start by setting up 4 independent monsters for the playable characters.
OH, I suppose it is OK if they share the same CHR file correct? I have plenty of space yet, but I can certainly fit all 4 character character graphics inside the same CHR file..

I will need at least one monster on screen for these stages. I assume monsters will be able to be loaded from a separate CHR file from the playable characters correct?

thanks ;)
Space Raft demo updates: [url]http://nesmakers.com/viewtopic.php?f=52&t=2867[/url]

Chiptune:[url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
dale_coop
Posts: 4463
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Changing player object upon warp-into flagged screen

Post by dale_coop » Thu Aug 15, 2019 10:05 pm

Monsters and your extra characters need to share the same CHR. Because 1 tileset is assigned to the screen, in theory... never tried it myself (in my tests, theextra character was a Game Objectt).
-----
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
Raftronaut
Posts: 307
Joined: Mon Sep 03, 2018 4:47 pm

Re: Changing player object upon warp-into flagged screen

Post by Raftronaut » Mon Aug 19, 2019 9:22 pm

dale_coop wrote:
Thu Aug 15, 2019 10:05 pm
Monsters and your extra characters need to share the same CHR. Because 1 tileset is assigned to the screen, in theory... never tried it myself (in my tests, theextra character was a Game Objectt).
Hey Dale!

I set up my 4 new playable characters as monsters 1-4,
I added the code to HandleScreenLoads.asm
I set up OBJ_PLAYER_2 to the correct number in my monster objects inventory.
I set the monster group to my new playable characters and set the palette.

My character warps into the room sucessfully and changes objects, but the animation states are not registering for some reason.

here is a video example:
[url][/url]

Here are some screenshots of how I have the character set up (in monsters)..
maze 1.PNG
maze 1.PNG (32.91 KiB) Viewed 515 times



maze 2.PNG
maze 2.PNG (21.72 KiB) Viewed 515 times
maze3.PNG
maze3.PNG (16.26 KiB) Viewed 515 times
maze 4.PNG
maze 4.PNG (17.12 KiB) Viewed 515 times
maze5.PNG
maze5.PNG (28.19 KiB) Viewed 515 times
Any idea why the player animations won't cooperate? I am likely overlooking something obvious......
Space Raft demo updates: [url]http://nesmakers.com/viewtopic.php?f=52&t=2867[/url]

Chiptune:[url] https://soundcloud.com/user-634230995-350638590 [/url]
Post Reply