|
Post by Aleisha Beesher on Sept 30, 2017 18:35:14 GMT
In the game I'm working on right now, about halfway through the player acquires a laser rifle, and is able to shoot. For this change I've modified the player sprite to show them holding the gun, and using a conditional variable I'm able to change the sprite during the game. That works great, but there's one snag--when the player dies, and restarts in the default position in the room, it also defaults to the sprite originally set for the room (without the laser). Once the player moves it changes to the sprite with the laser, but that looks awkward as the player goes from no gun to gun suddenly. I've been trying to think of ways to change this, but as that is set in the N. Sprite Positions screen, I can't figure out a way to get around it. Maybe an ASM call?
Thanks!
|
|
|
Post by zynaps2017 on Oct 1, 2017 7:57:57 GMT
Yes. Because when you put the sprites, you have to put the sprite 0 in a room because if you don't do that, if you die in that room, it restarts without a player. I've the same problem in a game i'm working. I think the solution is to create a third sprite (with a single frame), for instance, looking at us, and when we start moving the sprite is with/without laser gun, depending the variable. Try to do that. Make a sprite, put it on every room instead of original sprite. The problem is that it takes you +/- 200 bytes from memory...
|
|
|
Post by Jonathan Cauldwell on Oct 1, 2017 15:46:07 GMT
Not sure whether this would work off the top of my head...
If you set a variable when you've picked up the gun then you could try putting some code in the event where sprites are spawned. If the sprite type is 0 and the variable has been set, set the new sprite image there and see if it works...
|
|
|
Post by zynaps2017 on Oct 1, 2017 19:01:09 GMT
Hello, Jonathan.
I did that you wrote (and i presume Aleisha did the same). Like "IF D=1 / LET IMAGE = 6", for instance. I have "IF I = 0 / LET IMAGE 1 / ELSE / LET IMAGE 4".
|
|
|
Post by alessandro on Oct 2, 2017 13:57:08 GMT
Assuming the gun is treated as an object, you could even avoid using a variable to check the presence of an object in the player's inventory. Just an IF GOT [object] will do, e.g. assuming the gun is listed as object 5 and the sprite of the character carrying it as sprite 7, and sprite 2 represents the same character without the gun:
IF GOT 5 LET IMAGE 7 ELSE LET IMAGE 2 ENDIF I did that in the third chapter of Cousin Horace, when Horace wears a Guardian cap in order to avoid being recognized. The player sprite changes every time the character is carrying that object.
Naturally you would want to create separate player character sprites for each of its possible directions.
|
|
|
Post by Aleisha Beesher on Oct 2, 2017 14:57:31 GMT
Thank you for the replies! I will try these solutions out in my next version.
|
|
|
Post by zynaps2017 on Oct 2, 2017 15:09:07 GMT
Assuming the gun is treated as an object, you could even avoid using a variable to check the presence of an object in the player's inventory. Just an IF GOT [object] will do, e.g. assuming the gun is listed as object 5 and the sprite of the character carrying it as sprite 7, and sprite 2 represents the same character without the gun: IF GOT 5 LET IMAGE 7 ELSE LET IMAGE 2 ENDIF I did that in the third chapter of Cousin Horace, when Horace wears a Guardian cap in order to avoid being recognized. The player sprite changes every time the character is carrying that object. Naturally you would want to create separate player character sprites for each of its possible directions. Alessandro When we make the game in AGD, we have to put a sprite 0 in each screen or when we die the game don't restart. I think maybe the solution is to put on INITIALISE SPRITE EVENT the routine (any of them). I tried it and IT WORKS!!! Now the ONLY "problem" is the direction the player are (if i defined the sprite looking left, when it restars it restarts looking left, either is on the left or the right side of the screen). In INITIALIZE SPRITE i had: IF TYPE 0 / LET X O / LET Y P / ENDIF Now i have: IF TYPE 0 / LET X O / LET Y P / IF I=0 // LET IMAGE 1 / ELSE // LET IMAGE 3 / ENDIF / ENDIF.
|
|
|
Post by alessandro on Oct 2, 2017 15:40:43 GMT
When we make the game in AGD, we have to put a sprite 0 in each screen or when we die the game don't restart. That is only necessary if you employ the KILL command. If you set the player to "die" when the player character sprite touches an enemy, you could substitute it with a death animation (by spawning a new sprite whilst removing the old one) and make the characterr respawn in the same coordinates. To do this you have to save the player's coordinates into two variables. At the end of the player sprite event (and before a SPRITEINK command if present) put: LET S X LET T Y
When respawning the character sprite just set X to S and Y to T to respawn the player sprite in the same direction. Also add: SUBTRACT 1 TO LIVES IF LIVES = 0 ENDGAME ENDIF
in order to keep decreasing lives when the player "dies". Not using the KILL command also prevents the screen from being redrawn at the respawning of the player character. It also saves the bytes for putting a "0" sprite in each screen: you only need it in the starting screen and where you want the player to appear in an arbitrary screen by performing a certain action (teleporting etc.). Now the ONLY "problem" is the direction the player are (if i defined the sprite looking left, when it restars it restarts looking left, either is on the left or the right side of the screen). A better solution is to spawn the new sprite according to the direction it was moving to, by assigning a number of image equal to the direction, i.e.: sprite 0 = character moving to the right, sprite 1 = character moving to the left and so on. LET IMAGE = DIRECTION will do the trick. Of course if you use the KILL command you cannot do this and are forced to hard-code a fixed direction for the player sprite when it respawns.
|
|
|
Post by zynaps2017 on Oct 2, 2017 17:32:54 GMT
"If you set the player to "die" when the player character sprite touches an enemy, you could substitute it with a death animation (by spawning a new sprite whilst removing the old one) and make the characterr respawn in the same coordinates." I get it. In this game i have something like that. If deadly the energy comes to 0 and the type 0 becomes type 1, with the death sequence. Bt, when the frame is 4, i put the command "KILL". In kill player have the instruction "SUBTRACT 1 FROM LIVES" and "IF LIVES = 0 ..." What you say is that i can put that instructions "SUBTRACT..." and "IF LIVES =0..." in TYPE 1 instead of KILL PLAYER event... Interesting...
|
|
|
Post by zynaps2017 on Oct 2, 2017 17:44:45 GMT
"LET S X LET T Y"
I have something like that in TYPE 0 and INITILIZE SPRITE (has i wrote above).
In IS i have IF TYPE 0 / LET X O / LET Y P / ENDIF; In TYPE 0 i have: (in screenup, screendownm screenleft and screenright): LET X 8 / LET O X / LET P Y (the 8 is an example). So , when the player die, she restarts from the last position she enters the room. (i know you have asolution to start from the position that the payer dies, but for me it's not good because if she (in this game is a she) falls and dies in the spikes, restart in the spikes doesn't change anything, even i put that command of momentary invulnerability.
And in the bottom have LET F X / LET N Y (Why this? Because the TYPE 3 is a pursuer...).
|
|