|
Post by zynaps2017 on Jun 22, 2017 8:17:40 GMT
Hello
I made a specific screen for a map.
I draw the map (with blocks) in this screen (screen 31, for example).
In Main Loop 1 i put this routine:
If o > 9 (if parts of map are more than 9 = all 10 parts)
..if key 6 (if i press the key 6)
....let screen 31
....waitkey
..endif
endif
I want to introduce instuctions after the waitkey to return to last screen. (Remember that when we got 10 parts, in any screen we can press key 6 and go to map screen - well... at the moment, i have to press key 6 twice to do that - anyway...).
Can anyone knows how to do it?
(I've tried RETURN and LAST SCREEN... don't work)
|
|
|
Post by alessandro on Jun 22, 2017 20:00:56 GMT
1. You should not put conditions related to the player's actions in the Main Loop event but in the player sprite event. Otherwise they will repeat on and on.
2. When you wish to change the screen the player sprite is currently in, you must add a RESTART instruction. E.g. let's suppose your map screen is located in screen 31. Pressing key 5 the first time causes the current screen number to be stored in the S variable and the map screen to be displayed, pressing it a second time will return to the previous screen (untested but should work):
LET S SCREEN IF KEY 5 LET SCREEN 31 RESTART IF KEY 5 LET SCREEN S RESTART ENDIF ENDIF Remember that every time a RESTART command is executed all sprites return to their starting positions, i.e. those specified in the N - Sprite position option. If you want the player sprite to be displayed at its originary coordinates you should store the values of X and Y into two other variables and restore them when returning to the previous screen. E.g:
LET X O LET Y P [...] RESTART LET O X LET P Y
|
|
|
Post by zynaps2017 on Jun 22, 2017 22:47:27 GMT
Grazie, Alessandro. 1. I know. But the player event is so many instructions and, at sometime, it will be inaccessible. But you're right. The Main Loop is risky. 2. Unfortunatelly, doesn't work! Pressing key 6, the sprite restart in the screen without went to screen 31 first. This is in first video. youtu.be/v7Kgr1JPLgYIn second video, i've made some changes (instead of "RESTART" above "LET SCREEN 31", i wrote "WAITKEY". The sprite went to screen 31 (pressing ke6 6 and another key), but the sprite never return to previous screen (only if i scecify instad of "screen s" put "screen 10", for instance). youtu.be/US7nhbq4CFA
|
|
|
Post by alessandro on Jun 23, 2017 12:50:05 GMT
Hola Jaime, prueba este, funciona - try this, it works.
IF KEY 5 IF I = 99 LET O X LET P Y LET I SCREEN DELAY 10 LET SCREEN 31 RESTART ELSE LET X O LET Y P LET SCREEN I DELAY 10 REDRAW LET I 99 ENDIF ENDIF This way the player sprite will return to its previous screen and position. The "map" screen is set as number 31 in this example; this is not mandatory of course.
I must be set as 99 in the Game initialization event. 99 is chosen as an arbitrary limit value because it is unlikely that your game will have such a high number of screens. Naturally you can employ other variables than I, O and P, provided they are not used anywhere else.
P.S. Could you please send links to .Z80 snapshots of your work in progress in AGD instead of youtube videos? This way it is possible to look inside your scripts and try directly on them if the suggestions work.
|
|
|
Post by zynaps2017 on Jun 23, 2017 13:35:22 GMT
Hola Jaime, prueba este, funciona - try this, it works. IF KEY 5 IF I = 99 LET O X LET P Y LET I SCREEN DELAY 10 LET SCREEN 31 RESTART ELSE LET X O LET Y P LET SCREEN I DELAY 10 REDRAW LET I 99 ENDIF ENDIF This way the player sprite will return to its previous screen and position. The "map" screen is set as number 31 in this example; this is not mandatory of course. I must be set as 99 in the Game initialization event. 99 is chosen as an arbitrary limit value because it is unlikely that your game will have such a high number of screens. Naturally you can employ other variables than I, O and P, provided they are not used anywhere else. P.S. Could you please send links to .Z80 snapshots of your work in progress in AGD instead of youtube videos? This way it is possible to look inside your scripts and try directly on them if the suggestions work. Of course! I could put as an attachment here. It's easier. I define "M" as the variable for the parts of the map (instead of variable "O"). I've tried your suggestion and it works (who knows, knows... ) plus the if m > 9 (if i have all the 10 parts of the map).
|
|