pablo
Menagerie
Posts: 10
|
Post by pablo on Aug 10, 2023 20:38:12 GMT
Hello, it's good to be here Sorry if my English isn't perfect. I'm trying to show a sprite as a dying person at the beginning of the game and then show him as dead after we speak to him at first. EVENT SPRITETYPE8
IF SCREEN = 8 ; at the right screen IF IMAGE 12 ; if he is my dying friend IF B > 0 ; but the story has advanced and he is already dead LET FRAME = 1 ; show his frame as dead ENDIF ENDIF ENDIF
IF COLLISION PLAYER IF IMAGE 12 IF B = 0 ; the story hasn't advanced yet COLOUR 71 AT 10 3 PRINT "Oh I'm dying...." ; he dies WAITKEY INK 7 LET B = 1 ; the story advances LET FRAME = 1 ; and we show him dead REDRAW ENDIF ENDIF ENDIF Why doesn't this work? The message appears and the story advances, but the image is still the first frame (dying instead of dead). What am I doing wrong? Thanks in advance!
|
|
pablo
Menagerie
Posts: 10
|
Post by pablo on Aug 11, 2023 7:47:51 GMT
I've managed to initialize the sprite to "dead" but only when you reenter the screen or you die, with this code:
EVENT INITSPRITE
IF TYPE 8 IF IMAGE 12 IF B > 0 LET FRAME = 1 ENDIF ENDIF ENDIF But I can't find the way to do it right after you speak with him (the "LET FRAME = 1" in the COLLISION PLAYER doesn't seem to work)
|
|
pablo
Menagerie
Posts: 10
|
Post by pablo on Aug 11, 2023 8:24:29 GMT
I did it!
IF COLLISION PLAYER IF IMAGE 12 IF B = 0 ; the story hasn't advanced yet LET FRAME = 1 ; We show him dead COLOUR 71 AT 10 3 PRINT "Oh I'm dying...." ; he dies WAITKEY INK 7 LET B = 1 ; the story advances REDRAW ENDIF ENDIF ENDIF Somehow, if I change the position of that "LET FRAME = 1" right at the beginning of that code block, it works! It doesn't work if it's right before the "REDRAW". Why is that?
|
|
|
Post by ramon on Sept 4, 2023 10:50:28 GMT
|
|
|
Post by Jonathan Cauldwell on Oct 1, 2023 12:55:43 GMT
I did it! IF COLLISION PLAYER IF IMAGE 12 IF B = 0 ; the story hasn't advanced yet LET FRAME = 1 ; We show him dead COLOUR 71 AT 10 3 PRINT "Oh I'm dying...." ; he dies WAITKEY INK 7 LET B = 1 ; the story advances REDRAW ENDIF ENDIF ENDIF Somehow, if I change the position of that "LET FRAME = 1" right at the beginning of that code block, it works! It doesn't work if it's right before the "REDRAW". Why is that? The way sprites are stored is to have a copy of the previous sprite information (coordinates, image, frame etc) and the sprite's next set of information. When the sprite is redrawn the old sprite is deleted while the new sprite is simultaneously displayed on screen. It's one of the ways we avoid flicker and tearing. Once this is done the new details are copied to the old details and the events code can change the new details. Obviously, calling REDRAW will display the old sprite details as those will be deleted the next time the sprites are updated. Off the top of my head I suspect the WAITKEY might be the reason why it works as the engine does some housekeeping (I can't remember exactly what) while it waits for a keypress.
|
|