GAMES MASTER TUTORIAL, part 2 With Dr Andy Wright David has asked me to give an example of a multi-room game. I am a bit pushed for time, and anyway this is supposed to be educational, so I have provided a fairly simple 6-room playing area. You control a ship that can move from room to room. I have placed a few simple "aliens" in some of the rooms, and you can shoot them. They kill you if they touch you, too, but this is really a demonstration of methods, rather than my idea of what makes a good game! The Room Plan I started off with the idea of making the identity of each room very obvious by placing blocks in the shape of the numerals 1 to 6, in the middle of each room. Then this morning I got the latest SAM Supplement disk, which had an excellent giant character set on it, and I thought I would use this to make backgrounds for each room - giant A's for room 1, B's for room 2, etc. So I grabbed the characters A-F from the screen with GM's GRAB FRAME option, as separate sprites. These are used to BFILL (Block FILL) the main block of each room. The arrangement of blocks in each room acts as a barrier to sprite movement, or as a collision detection area that can trigger actions. The diagram below shows the 6 rooms. The numbers with the arrows correspond to long narrow blocks (invisible unless you use the GM BLOCKS EDITOR) that lie close to the walls of the room. For example, in room 4, where your ship starts, a block with type 15 is located in the ceiling, and a block with type 18 on the right-hand wall. I could have made these any size, and aligned them with doorway graphics on the background, but decided to go for whole-wall coverage. For ease of remembering, I made blocks 8-21 trigger execution of modules (Games Master program sections 8-21 when touched by the ship although I could have chosen any modules. The collision action table (nor shown here) was set up wwith the SPRITE vs. BLOCKs option in GM. * **** ***** ** * * * * 8 9 * 10 11 * * -> <- * -> <- ** * * * *** ****** ***** 12 V 13 V 14 V 15 ^ 16 ^ 17 ^ * ***** * * * * * * * 18 19 * 20 21 * ***** -> <- **** -> <- ***** * * * * * ***** ***** Here is a list of the GM Modules for the demo on the disk. If you have Games Master, you should be able to load the game into thhe Editor and alter it as much as you like (except 256K owners may run out of memory). If you can't, you may need a later version of the GM Editor - in which case return your original disk with an SAE for a free update. Comments in brackets are not part of the original listing. (The first module executed - sets up a few variables.) *** MODULE 1 *** PAL 1 REM L,R,T,B are used to set the REM sprite position in new rooms LET L=3 LET R=108 LET T=184 LET B=33 REM initial position LET X=20 LET Y=80 REM jump to module 5, set up REM room 4 JPMOD 5 (Modules 2-7 set up rooms 1-6. Each one clears the screen and the sprites, selects the correct pre-defined block set, fills the first (main) block with a given sprite (sprites 2-7 are giant letters A-F), then use a FOR-NEXT loop (which uses the form START,END,STEP) to fill some of the blocks in the set. Of course you can be more ambitious - like by placing an individual pre-designed graphic inside a block, or by having particular background features at the same location as the block. Or you could place a stationary sprite instead of a block - this has the advantage that collision detection triggers off every sprite pixel, and you can move BEHIND the sprite if required... The room set-ups finish by PLACEing the ship (sprite 1) at an X and Y coordinate - which I will explain later - on plane 4. Everything in this demo is on one plane, but planes are important where you have things going overand under other things, so I usually pick for to start with, so I can add stuff at higher and lower planes later. Some modules PLACE an alien or two, as well. *** MODULE 2 *** REM set up room 1 CLS SCLEAR BLOCKSET 1 BFILL 1,2 FOR N=2,4,1 BFILL N,10 NEXT N PLACE 1,X,Y,4 REM place pulsers CALLMOD 23 *** MODULE 3 *** REM set up room 2 CLS SCLEAR BLOCKSET 2 BFILL 1,3 FOR N=2,8,1 BFILL N,9 NEXT N PLACE 1,X,Y,4 REM orb PLACE 13,40,170,4 PATH 0,1,30 *** MODULE 4 *** REM set up room 3 CLS SCLEAR BLOCKSET 3 BFILL 1,4 FOR N=2,8,1 BFILL N,9 NEXT N PLACE 1,X,Y,4 REM eye PLACE 8,90,120,4 *** MODULE 5 *** REM set up room 4 CLS SCLEAR BLOCKSET 4 BFILL 1,5 FOR N=2,4,1 BFILL N,9 NEXT N PLACE 1,X,Y,4 *** MODULE 6 *** REM set up room 5 CLS SCLEAR BLOCKSET 5 BFILL 1,6 FOR N=2,7,1 BFILL N,9 NEXT N PLACE 1,X,Y,4 PLACE 13,70,80,4 *** MODULE 7 *** REM set up room 6 CLS SCLEAR BLOCKSET 6 BFILL 1,7 FOR N=2,3,1 BFILL N,10 NEXT N PLACE 1,X,Y,4 (Modules 8-21 are triggered into action by block types 8-21 - see the Room Plan. When movement to a room to the left or right is wanted, the ship's new Y coordinate should be the same as it is now, and it is read from the sprite data with SPEEK. The 191 is in there because the internal format uses a faster, inverted Y axis. The ship's X coordinate is set to L or R (near the Left or Right edge of the room, as appropriate.) Movement to a room above or below preserves the current X coordinate but sets Y to be near the top or bottom of the new room. The correct module is then Jumped to. The module ends with a PLACE command that will put the ship at the new X and Y position. *** MODULE 8 *** REM player vs RHS of room 1 REM Adjust X coord, jp to REM module 3 to set up room 2 LET X=L LET Y=191-SPEEK(1,12) JPMOD 3 *** MODULE 9 *** REM player vs LHS of room 2 REM Adjust x coord, jp to REM module 2 to set up room 1 LET X=R LET Y=191-SPEEK(1,12) JPMOD 2 *** MODULE 10 *** REM player vs RHS of room 2 REM module 4 sets up room 3 LET X=L LET Y=191-SPEEK(1,12) JPMOD 4 *** MODULE 11 *** REM player vs LHS of room 3 REM module 3 sets up room 2 LET X=R LET Y=191-SPEEK(1,12) JPMOD 3 *** MODULE 12 *** REM player vs bottom of room 1 REM module 5 sets up room 4 LET X=SPEEK(1,11) LET Y=T JPMOD 5 *** MODULE 13 *** REM player vs bottom of room 2 LET X=SPEEK(1,11) LET Y=T JPMOD 6 *** MODULE 14 *** REM player vs bottom of room 3 LET X=SPEEK(1,11) LET Y=T JPMOD 7 *** MODULE 15 *** REM player vs top of room 4 REM module 2 to set up room 1 LET X=SPEEK(1,11) LET Y=B JPMOD 2 *** MODULE 16 *** REM player vs top of room 5 REM module 3 to set up room 2 LET X=SPEEK(1,11) LET Y=B JPMOD 3 *** MODULE 17 *** REM player vs top of room 6 REM module 4 to set up room 3 LET X=SPEEK(1,11) LET Y=B JPMOD 4 *** MODULE 18 *** REM player vs RHS of room 4 REM module 6 sets up room 5 LET X=L LET Y=191-SPEEK(1,12) JPMOD 6 *** MODULE 19 *** REM player vs LHS of room 5 REM module 5 sets up room 4 LET X=R LET Y=191-SPEEK(1,12) JPMOD 5 *** MODULE 20 *** REM player vs RHS of room 5 REM module 7 sets up room 6 LET X=L LET Y=191-SPEEK(1,12) JPMOD 7 *** MODULE 21 *** REM player vs LHS of room 6 REM module 6 sets up room 5 LET X=R LET Y=191-SPEEK(1,12) JPMOD 6 (Triggered by the player hitting the spacebar. Emits a "shot" sprite - number 15 - at a given X and Y offset from the current sprite - number 0.) *** MODULE 22 *** REM ship fires shot SOUND 1 EMIT 0,15,6,0 (The "pulsers" are put at different positions on a pre-designed path designed with the PATH EDITOR. Some are at different points in the ANIM sequence so they do not all pulse in time with each other.) *** MODULE 23 *** REM pulsers with varied paths REM and path positions. PLACE 11,100,90,4 PATH 0,1,30 ANIM 0,11,6 PLACE 11,120,10,4 PATH 0,1,80 PLACE 11,105,180,4 PATH 0,1,120 ANIM 0,11,4 PLACE 11,99,21,4 (You've been killed! Activated by ship vs. eye, orb or pulser collisions.) *** MODULE 24 *** REM end of ship explode anim KILL 0 (Orb collision noise) *** MODULE 25 *** REM orb hits block SOUND 3 (Shot collision with block dies and makes a noise.) *** MODULE 26 *** REM shot vs. block SOUND 4 KILL 0 (Trying to be a bit flashier - hitting pulser releases 4 broken bit sprites 16-19 from near its old location. Their speed and direction is set up with the SPRITE DETAILS Option.) *** MODULE 27 *** REM shot vs. pulser KILL 0 SOUND 5 REM release 4 broken bits! EMIT 255,16,0,4 EMIT 255,17,4,4 EMIT 255,18,0,0 EMIT 255,19,4,0 KILL 255 *** MODULE 28 *** REM shot vs. orb or eye REM kill the shot, explode other SOUND 5 KILL 0 TRANSFORM 255,14,0,0 *** MODULE 29 *** REM end of explode anim KILL 0 *** MODULE 30 *** REM bit hits anything KILL 0 (Turn the ship into an explosion sprite. An explosion sprite's last frame triggers module 29, and it dies.) *** MODULE 31 *** REM orb/eye/pulser vs ship SOUND 6 TRANSFORM 255,14,0,0 (This module is executed regularly. If you press RETURN, the demo restarts.) *** MODULE 40 *** IF INKEY =65:JPMOD 1 Well that's about it! I hope it has given some of you inspiration to either 1. design a game or 2. buy Games Master! Good Luck from Andy Wright.