mrtomftw
Abandoned Uranium Working

Posts: 15
|
Post by mrtomftw on May 14, 2022 21:28:41 GMT
Hello!
I'm making a game where you move freely from screen to screen, and upon death I would like the player to respawn at the point they entered the current screen, rather than the set player respawn point. How do I go about doing this? I've tried recording the X and Y position of the player as variables when the screen changes (LET A = X, LET B = Y) but cannot make the player sprite move to those coordinates when respawning.
So what's the actual solution?
|
|
|
Post by Minilop on May 15, 2022 21:07:59 GMT
I haven't had chance to try this but perhaps have another variable, say C. i
in the game initialisation event
LET C = 0
in the Sprite Initialisation event:
IF TYPE 0 IF C <> 0 LET X = A LET B = Y ENDIF ENDIF
then in your player event:
IF C = 0 LET A = X LET B = Y LET C = 1 ENDIF
then in all your code that controls moving between screens ( screenup, screendown etc) also add LET C = 0
for example: IF X >= RIGHTEDGE ; Is Player at the right edge of the screen?
LET X = LEFTEDGE ; Move him to the left
ADD 8 TO X ; increase his x pos a bit
SCREENRIGHT ; switch to the screen on the right
LET C = 0 EXIT ; end this event
ENDIF
Then in your KILL PLAYER event
LET C = 2
So when the player event first runs in a new screen, the x and y are stored in A and B and C is set to 1 so it doesnt run again If the player is killed C is set to 2 so that when the screen reloads after the kill, x and Y are set to the A and B values we stored If the player successfully moves between screens the players x and y are the values as set in your screen moving code,.
As I said, I haven't tried this so it might not work in your game, but I'd probably give it a go first and see how you get on.
|
|
mrtomftw
Abandoned Uranium Working

Posts: 15
|
Post by mrtomftw on May 16, 2022 18:31:02 GMT
Yep, that does it. I knew I was on the right track with storing the coordinates. I just couldn't figure out how to get it to trigger on death. The KILL PLAYER code isn't even needed, it just does it regardless which is nice.
Thank you.
|
|
|
Post by Minilop on May 16, 2022 21:59:30 GMT
Cool! glad that worked for you, yes reading through the code I can see the KILL PLAYER code is redundant. I look forward to seeing the finished game, good luck with your development!
|
|