|
Post by dreamcastpast on Jan 6, 2017 21:25:02 GMT
Hi All,
Happy New Year!
I am currently working on a 48k game in AGD 3.0 that I'm hoping to release sometime this year, sooner rather than later. I'm making good progress, probably 75% completed. I'm new to programming and AGD, my knowledge comes solely from Paul Jenkinson's tutorials, my own tinkering and troubleshooting and some help with messages from Alessandro (thanks!). I'm learning all the time, but...
In AGD 3.0 I have a Miner type game with a character travelling left to right through 20 screens so far, collecting objects (stars) along the way. I have placed 100 objects (stars) throughout the caverns. When setting up the Events 'Player Control' I changed the 'get object' score value to 1 to represent a single star the player has just collected. I would like to have a sprite appear in the very first room (screen 00) after the player collects the 100th star located in room 20 (screen 19). The player must then traverse all the way back to room 1 (screen 00), touch the sprite or object that has now appeared (for instance 'EXIT) to finish the game.
So here are the questions...
1. How can I have a sprite appear (for instance 'EXIT') in screen 00 as a consequence of collecting the 100th object (star) from screen 19?
2. The score numbering is displayed with six digits (000000) I would like to have only 3 digits as my stars will only number 100 in total. Is there a way to remove or even hide the first three zeros of the 'score'?
Many thanks!
|
|
|
Post by alessandro on Jan 7, 2017 10:48:32 GMT
Happy New Year mate As for your questions... 1. Set a variable to 0 and increase it by one every time the character collects an object. For example, let's call this variable A: - In the Game Initialization event write: LET A 0 so that A is set to 0 each time the game starts. Now go to the Sprite Position screen, select room 0 and place the exit sprite wherever you want. Then, in the sprite event associated to the collectable item (the star in your case), write IF COLLISION 0 REMOVE ADD 1 TO A LET LINE 20 ; LET COLUMN 5 ; more on this below! DISPLAY A ; ENDIF The exit sprite should only appear when the player has collected the 100th item, and this means A = 100. Let's suppose the exit sprite is number 5 and you want to make it appear at 120,150. In the Main Sprite event you will write: IF SCREEN = 0 IF A = 100 LET Q X LET R Y LET X 120 LET Y 150 SPAWN 5 0 LET X Q LET Y R ENDIF ENDIF
This way the exit sprite will appear when the player collects the 100th item, even if it's still in room 0 (i.e. the player did not collect it first). The two Q and R variables are used as a reminder of the character sprite's original position. You could also define the exit as an object rather than a sprite, and in this case you would use PUT [object number] instead of SPAWN [sprite,frame]. But when using a sprite you could also animate the exit, whereas objects cannot be animated. 2. Do not use the SCORE variable. Use the variable from above to keep track of the collected stars instead. In the above example, each time an item is collected, the number of items so far collected increases by one and is displayed at line 20 and column 5. On a side note, why do you keep using the old AGD 3.0? AGD 4.6 is way better - many more functions, one more sprite available, support for coloured sprites, more variables available (from A to R) etc.
|
|
|
Post by dreamcastpast on Jan 9, 2017 13:29:02 GMT
Thanks for the reply Alessandro! It seems like I've gone about my collectables in the wrong way... I've created 100 'OBJECTS' in my game and used them as collectable stars! I'm thinking now that I should have created 1 'SPRITE' of a star, then placed that sprite 100 times throughout the game and used that as the collectable... So, just for this game, can I use some similar code to keep count of the 100 'OBJECTS' and to spawn a sprite or object for my exit after 100 'OBJECTS' have been collected? I stumbled upon online tutorials for AGD 3.0 and decided to follow them just to see if I could control something on a Spectrum, I didn't really think I could make a game. As the weeks went by a game started to take shape. I didn't think to check if any other versions of AGD existed as I was following the tutorials, so I find myself now with my game about 75-80% complete and only reccently realising there is a better, more up to date version (4.6). I hoped I may be able to import my AGD 3.0 game into AGD 4.6 but I can't. I did debate whether to start from scratch in 4.6 but decided to finish this game as it is in 3 then move to 4.6 for any games afterward Thanks again!
|
|
|
Post by andrewvanbeck on Jan 10, 2017 13:36:46 GMT
I think the best way would be to have that end game sprite in screen 0, but starting on a blank frame. Then you could have an event like this... say the end game sprite is event 5, so you add the sprite to screen 0 as type 5, and event 5 might look a bit like this...
IF SCREEN 0 IF A > 99 LET FRAME = 1 IF COLLISION 0 ENDGAME (or whatever command it is to finish the game) ENDIF ELSE LET FRAME = 0 ENDIF ENDIF
So if its on screen 0, the sprite will be on frame 0 if A < 100, otherwise it'll be on frame 1, and touching the sprite will end the game. Individual sprites are the easiest way to go, so many objects would eat up memory... I mean a sprite frame will use the same memory as about 5 objects - but you can re-use it, or even have the colours change, and positioning them on the screens will only cost a few bytes each. You could have incremental barriers quite easily too. Like imagine if you have a door in your level that is locked unless you already collected all the objects from previous screens. Say on screen 5, you might have collected 10 objects, well you'd just need a little code for each barrier, like:
IF SCREEN 5 IF A > 9 LET FRAME = 1 IF COLLISION 0 LET SCREEN = 6 ENDIF ELSE LET FRAME = 0 ENDIF ENDIF
Could have one every 5 levels for example, then people wouldn't be able to miss an object in screen 1, have to go back and get it, then back to the finish screen again, then back to the start again... if they hit a barrier it could just mean that they missed on object on one of the last 5 screens. The barrier sprite could even be the old woman from JSW, telling Willy to go back and get more stuff.
|
|
|
Post by dreamcastpast on Jan 10, 2017 22:25:39 GMT
Thanks for the input andrewvanbeck!
The examples above are definitely something I'll be looking at for a new game. For now though, as I've nearly finished this game, I'd like to be able to proceed with what I have, even though the collectables have been done with 'OBJECTS' rather than sprites.
I've got no experience with counters, do you know how I can keep count of collected 'OBJECTS' (not using the score) as I'd like to implement some of the above but can't yet as I need a counter for 'OBJECTS' rather than a counter for 'SPRITES'. In my next game I'll take the advice here and use 'SPRITES' as collectables but for now I'd just like to finish this game an move on to a new one...
Thanks!
|
|