|
Post by karloff on Oct 19, 2019 21:45:24 GMT
Hello everyone! My name is Anatoly and I'm new here Long time Spectrum fan! Recently discovered AGD 4.8 and immediately started working on my first ever ZX Spectrum game)) Big thank you to Jonathan for making this great program! I followed all the tutorials on YouTube and was able to create a mini game from scratch. I created the core of the game, all the screens from start to finish and a simple menu, but still have some troubles with finishing project properly. There is some stuff that I just cant get my head around with and that was not covered in YouTube tutorials. I've looked on forum, but haven't found a clear answer, so decided to ask my self and maybe someone will help me with my issues. I have a few things that I'm stuck with, but I'll begin with basic ones (not for me at least)) - After player dies (lives=0), or finishes game - how to make the game return to main screen? In my case its controlmenu. - How to set a KILL player animation? I made a sprite of player dying and left an empty sprite type for it ( type 2 in my case). I saw here on forum someone asked about the kill animation and got the answer, but I somehow can't make it work. Hope you can help me with those things so I can finally make a first finished version of game. Here a some snapshots from the game that I'm working on and is called Quest For Elements by the way)) All the best!
|
|
|
Post by alessandro on Oct 20, 2019 8:35:57 GMT
Welcome to the forum Anatoly The screenshots look interesting, I like the minimal look of the graphics. Now, about your questions... First of all, AGD 4.8 is an unfinished version which may contain bugs. I would follow Jonathan's advice and try Multi-Platform (MP) AGD, which is now at version 0.7.5, instead. AGD is structured in such a way that there is no clear possibility of going back to the start once the game ends in either victory or defeat. You might insert in the Lost Game and Completed Game events this sequence: WAITKEY / ASM 205 / ASM 0 / ASM 125, i.e. a pause for a keypress followed by a CALL 32000 instruction, so that the game waits for a key pressed by the user and then restarts. However I never tried this solution because I manage the game with an external program, taking care of such tasks and others, e.g. control selection, key redefinition etc., without spending precious memory within AGD. My first advice is always the same - do not do within AGD what you can do outside of AGD. In this specific case, that means restarting the game from BASIC with a RANDOMIZE USR 32000 command, or machine code with a CALL 32000 instruction. For the death animation, you must not use the KILL command, unless you are working at a Manic Miner-style game, where the player character sprite (PCS from now on) is always spawned in the same place for each screen. I explained it elsewhere in this forum. However, I later discovered that you can also avoid using the variables (S and T in my example) for memorizing the X and Y co-ordinates of the PCS, if you do not need them for other uses, like the chasing sprite script, or for restoring the PCS position after "hiding" an object in an unreachable part of the screen. If you wish to respawn the PCS at the same spot of his/her "death", you should follow this procedure: 1) Spawn a death animation sprite (DAS) at the PCS position 2) Remove the PCS 3) Set a counter so that the DAS is displayed for a certain amount of time 4) Spawn a PCS at the DAS position 5) Remove the DAS Let's suppose that the variable C holds the counter for the DAS, that the DAS is sprite number 2, and that its script is number 2 as well. In Game Initialization, set this variable to 0. Whenever the PCS should "die", for instance when colliding with an enemy sprite, C must be set to 1 in the enemy sprite's code: IF COLLISION 0 LET C 1 ENDIF Then, insert this code in the PCS script: IF C = 1 SPAWN 2 2 ORIGINAL REMOVE ENDIF This "tells" AGD to spawn the DAS, remove the PCS and start the counter for the DAS, and that if there are no more lives left, the game must end. Now, in the script for sprite 2, the DAS, write: IF IMG = 2 ADD 1 TO C IF C > 50 SUB 1 TO LIVES IF LIVES = 0 ENDGAME ELSE LET C 0 SPAWN 0 0 REMOVE ENDIF ENDIF ENDIF This way, when the counter exceeds 50, one life is deducted, and if they are zero, the game ends, moving to the Complete Game event, else it resets the counter, spawns a PCS, and removes the DAS. It's up to you whether you want to display a game over message in the Complete Game event under the IF LIVES = 0 condition, or you wish to do that (as I would) outside of the AGD code. Hope that helps!
|
|
|
Post by karloff on Oct 20, 2019 9:15:30 GMT
Thanks a lot Alessandro! I will follow your recommendations and hopefully will make it work) In other case, I assume it is possible to migrate my game project from AGD 4.8 to MPAGD, right?
|
|
|
Post by karloff on Oct 20, 2019 12:58:32 GMT
Hi there Alessandro! The return to main menu routine that you recommended works perfectly! But there are still troubles with kill animation. I seem to do exactly what you proposed, but I get this error when I try to save the script for DAS (sprite 2 in my case). I don't understand what am I doing wrong here
|
|
|
Post by Jonathan Cauldwell on Oct 20, 2019 13:24:34 GMT
Welcome Anatoly.
The tokeniser doesn't recognise IMG in the first line. Replace the line with IF IMAGE = 2 and AGD will understand.
If you've made considerable progress with your game in 4.8 you might as well try to complete it. MPAGD doesn't yet import 4.8 games, only 4.0 to 4.7 but if enough users start to create games with version 4.8 I'll add that functionality to MPAGD.
Saving a finished game complete with BASIC loader from within AGD will make your game automatically return to the control menu every time. However, if you save your game as a data file and write your own BASIC loader like Alessandro does AGD assumes you will take care of that yourself via a BASIC GOTO or a machine code JP 32000 instruction. You can easily force AGD to return to the menu after each game with POKE 32000,205 but don't do it while you're developing the game in the tool or you won't be able to escape back into AGD!
|
|
|
Post by alessandro on Oct 20, 2019 15:06:37 GMT
Sorry but Jonathan is right, I wrote IMG when I should have written IMAGE. That is the syntax of AGDx, a "fork" of AGD which retains the look and feel of the old utility while adding several enhancements. If you want to try it, you can download version Lg from here (there is a more recent version in the archive but it seems to be bugged), but remember it won't accept code made with AGD 4.8.
|
|
|
Post by karloff on Oct 20, 2019 19:00:40 GMT
Sorry but Jonathan is right, I wrote IMG when I should have written IMAGE. That is the syntax of AGDx, a "fork" of AGD which retains the look and feel of the old utility while adding several enhancements. If you want to try it, you can download version Lg from here (there is a more recent version in the archive but it seems to be bugged), but remember it won't accept code made with AGD 4.8. It's ok) I've eventually got the kill animation working, but now stuck with some new problems When PCS hits the enemy sprite, after kill animation ends the PCS sprite re-spawns in that very same position it just died (in the air while jumping for example) and not in the start position of the screen where it should be and kill animation somehow does not work properly when hitting deadly blocks and also has the issue with re-spawning. And also after player dies lives are not decreasing properly and when I lost all lives I get mission completed message Feeling that getting this to work will be the hardest task for me))) Thanks also for suggesting AGDx! I will try it maybe on a new project, but this one I probably finish in AGD 4.8, because a lot of work was already done in it. I have to see how much I can squeeze from AGD 4.8
|
|
|
Post by karloff on Oct 20, 2019 19:30:35 GMT
Welcome Anatoly. The tokeniser doesn't recognise IMG in the first line. Replace the line with IF IMAGE = 2 and AGD will understand. If you've made considerable progress with your game in 4.8 you might as well try to complete it. MPAGD doesn't yet import 4.8 games, only 4.0 to 4.7 but if enough users start to create games with version 4.8 I'll add that functionality to MPAGD. Saving a finished game complete with BASIC loader from within AGD will make your game automatically return to the control menu every time. However, if you save your game as a data file and write your own BASIC loader like Alessandro does AGD assumes you will take care of that yourself via a BASIC GOTO or a machine code JP 32000 instruction. You can easily force AGD to return to the menu after each game with POKE 32000,205 but don't do it while you're developing the game in the tool or you won't be able to escape back into AGD! Thanks for replaying Jonathan! I actually really like AGD 4.8. Your tutorials where very helpful to understand how everything works and now I'm able to make games for ZX Spectrum! I think I will eventually try MPAGD, but I've already done the whole core of the game, with all the screens and sprites and want to finish it (hopefully)) in AGD. It's just those extra things that are mind-bugling like kill animation, adding loading screen, adding screen that I also drawn in zx paintbrush for controlmenu, adding music - all those things to make the game look like a real pretty finished Speccy game)) And there are no video tutorials about those things unfortunately for guidance, so I scratching my head, looking through forum hoping to find answers. Actually I've found one tutorial on how to add ay music to AGD game, but before trying it, I want to make everything else working properly (ohh, that kill animation )
|
|
|
Post by alessandro on Oct 20, 2019 22:37:37 GMT
It's ok) I've eventually got the kill animation working, but now stuck with some new problems When PCS hits the enemy sprite, after kill animation ends the PCS sprite re-spawns in that very same position it just died (in the air while jumping for example) and not in the start position of the screen where it should be and kill animation somehow does not work properly when hitting deadly blocks and also has the issue with re-spawning. And also after player dies lives are not decreasing properly and when I lost all lives I get mission completed message Feeling that getting this to work will be the hardest task for me))) 1. The method I suggested you actually assumes that the new PCS should start in the same position where it "died". If you want the PCS to start each time at a fixed position instead, you should set a spawning point for the PCS in each screen and use the KILL command, in order to reset the screen and return each sprite to its starting position. In the example above, the code should be modified as follows: IF IMAGE = 2 ADD 1 TO C IF C > 50 KILL ENDIF ENDIF
so that when the counter exceeds 50, the KILL command is issued, and the screen is re-initialized. 2. For deadly blocks, you should insert this code in the PCS script (following the example above): IF DEADLY SPAWN 2 2 LET C 1 REMOVE ENDIF This way, a DAS is spawned, the counter is set to 1, and the PCS disappears, to be respawned when the counter exceeds 50. However, if you hit a deadly obstacle, the character will be respawned precisely on it, "killing" it again. To avoid this, you must either set another counter to give the sprite a temporary period of immunity (I employed this technique in Sophia and Sophia II), or again, use the KILL command and restart the screen, provided you set a spawning point for the PCS in it. 3. You get the "mission completed" message because you did not set a condition for it. When LIVES reaches zero, the ENDGAME command will be executed anyway, so the game flow will arrive at the Completed Game event. You must then set a check for lives either within AGD or outside of it. For instance, let's suppose you set message 1 to "Well Done" and message 2 to "You Lost!": LET LINE ... LET COLUMN ... IF LIVES > 0 MESSAGE 1 ELSE MESSAGE 2 ENDIF
Of course, you do not need this if you use the KILL command to reset the screen; just assign the two messages in the Completed Game and Lost Game events respectively, because Lost Game is triggered when LIVES reaches zero after a KILL command.
|
|
|
Post by karloff on Oct 24, 2019 11:53:53 GMT
Thanx Alessandro! I will try this and let you know if I succeeded.
|
|
|
Post by karloff on Dec 4, 2019 21:46:05 GMT
Hi there! Was away for a wile, but now I'm glad to say that I eventually succeeded in making the DAS working! What is more interesting, I got it to work with the first variant of code that you provided me Alessandro) So thanks once again for the help! Now I have only two problems left to get around with: adding a loading screen and ay tune to play in the game. There is a function in AGD V4.8 in Miscellaneous section to add a loading screen, but I don't quite understand how I can add my loading screen that I made in ZX Paintbrush. Every time when I press to load the screen the program asks if I'm sure to import the screen, I press 'yes' and then blue screen appears and nothing happens and I have to restart the program. What am I doing wrong? Or maybe I can add a loading screen some other way?
|
|
|
Post by alessandro on Dec 5, 2019 11:59:19 GMT
Hi Karloff, I never felt the need to use the loading screen option in AGD. Personally I think it should be removed to make room for more useful features. If you want to use it, though, you should save your screen as a TZX/TAP file (with header), then insert such file in the virtual tape recorder of your emulator. When the message "Import screen - sure?" message appears, press Y and the loading screen file will be loaded.
The other way is more complex, but indispensable if you wish to create your own loading procedure. From our experience in the 1980s you will surely remember that the standard BASIC loader was something around the lines of:
10 BORDER 0: PAPER 0: INK 0: CLEAR <code starting address - 1> 20 LOAD "" SCREEN$ 30 LOAD "" CODE 40 RANDOMIZE USR <code running address>
The screen is made black in order to avoid displaying the loading screen while being loaded, then the program code is loaded and run. The code starting and running addresses usually coincide, but in the case of AGD 4.x the starting point is mobile while the running address is always 32000.
Therefore you should: - type and save the program above as a TAP file - save the loading screen (with header) as a TAP/TZX file - save the AGD game without BASIC loader - assemble the three files in that order with ZX-Blockeditor and save a single TAP/TZX file.
|
|
|
Post by karloff on Dec 7, 2019 20:42:43 GMT
Thanx a lot, Alessandro! Once again!)) I tested and it works Know I stumbled across another small issue and maybe you can help me. I made a screen in AGD's screen editor for the intro menu, then wrote this small code in the events intro/menu section: COLOUR 0 CLS LET SCREEN 21 REDRAW (and further menu code) After that, the screen appears just fine in the menu, but out of nowhere the sprites also appear on that screen corrupting it, although I did not place any sprites on that screen. It seams that they randomly appear on that menu screen as they where placed on other screens. I'm at loss. Have you encountered something like that?
|
|
|
Post by karloff on Dec 7, 2019 20:58:18 GMT
I also noticed that sprites appear on menu screen exactly on same positions they were on the last screen the game ended. Maybe this information will also be useful))
|
|
|
Post by alessandro on Dec 7, 2019 22:22:35 GMT
Again, the intro/menu is a feature I never used; but I will try to give you some help nonetheless, based on my own experience.
Try eliminating the COLOUR 0/CLS lines and using RESTART instead of REDRAW.
|
|