______________________________________________________________________________ | SECTION 1 PART B SUBPART 4 | Simple game development | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Game Development ~~~~~~~~~~~~~~~~ Introduction 1-Before you get Started 2-Writing a Game 3-Tips and Reference Introduction ~~~~~~~~~~~~ Making computer games is not as hard as it seems. In this article I'm going to explain the basics of making games. This article will be tilted towards simple games, but these steps are used in just about every game ever made. Section 1 Before you get started making a game you should have a few things. Step 1. Planning 1. An idea. This is the most important part of making a game. 2. Once you have an idea, think up a storyboard. This is not necessary always. For example, Tetris doesn't have a story. 3. Now, plan the Levels. If the game has several levels, think how they are going to look. 4. After you have the basic concept, think about goals. There has to be some kind of goals to make the player keep playing. 5. Now think about the gameplay. Gameplay makes a game. Without gameplay the game is boring. 6. Finally think of little bonuses you can add.(Score, explosions, sounds, animations, Level completion bonuses, Power-ups, etc.) Use these to spice the game up. Step 2. Tools 1. First, you're going to need a graphics program(unless it's a text -adventure OR it's graphics are ASCII characters). Personally I suggest QBDRAW17(it's only Screen 13 though). There are several graphics programs available(Check Simtel) or you could draw in Window's Paint Brush or another commercial program(you'll need some GIF, PCX or BMP code to load these though) 2. Second, you're going to need some Algorithyms for Artificial Intelligence. here's an Example, In Space Invaders, the enemies algorithym was: 1. Go Right until Wall. 2. When hit wall go Left. 3. Go Left until Wall. 4. When hit wall go Right. 5. Move Down. 6. Loop back to step 1. 3. Code for Input Devices. (Keyboard, Joystick, Mouse,etc.) You can get this just about anywhere. 4. Music and Sound. There is nothing wrong with using the PC Speaker to do sounds(Just don't put long and annoying Music that'll wake up your parents at 3 AM) Remember, you can't adjust the PC Speaker's volume(at least from the outside). If you're going to have Sound Blaster sounds, find some libraries(it's not easy to write them yourself). Section 2 Now we are going to write a Pong Game {Cut here} ******************************************************** SCREEN 13: CLS 'Screen with 256 colors DIM Sphere(100) 'Allocate memory for sprites DIM Paddle(200) PAINT (160, 100), 201 'Paint Background CIRCLE (160, 100), 7, 4 'Draw Ball PAINT (160, 100), 4 'Paint Ball LINE (10, 10)-(18, 50), 1, BF 'Draw Paddle GET (151, 92)-(169, 108), Sphere 'Get Sprites and store in array GET (9, 4)-(19, 56), Paddle CLS : PAINT (160, 100), 201 'Clear and Repaint screen 'Initialize Variables p1 = 0: p2 = -1 'Scores X = 1: Y = 1 'Ball's Location X1 = 5: Y1 = 75 'Player 1's Location X2 = 295: Y2 = 75 'Player 2's Location DO WHILE INKEY$ <> CHR$(27) 'Begin Main Program Loop and loop until ESC 'is pressed. LOCATE 1, 8: PRINT p1: LOCATE 1, 36: PRINT p2 'Print Scores GOSUB Keys IF X > 300 THEN Xadj = -2: p1 = p1 + 1: SOUND 200, 1 'See if Ball hits Side IF X <= 1 THEN Xadj = 2: p2 = p2 + 1: SOUND 200, 1 'See if Ball hits Side IF Y >= 180 THEN Yadj = -2: SOUND 200, 1 'See if Ball hits Top IF Y <= 1 THEN Yadj = 2: SOUND 200, 1 'See if Ball hits Top FOR i = 1 TO 3 'Continously move Ball X = X + Xadj Y = Y + Yadj PUT (X, Y), Sphere, PSET NEXT i PUT (X1, Y1), Paddle, PSET 'Put Paddles PUT (X2, Y2), Paddle, PSET FOR q% = 1 TO 100 'Add Delay (Increase if game runs too fast) GOSUB Keys NEXT q% SELECT CASE Y 'If the Ball is within one of the Paddle's Y Range, 'Compare it's X Location CASE (Y1 - 15) TO (Y1 + 30) GOSUB Precheck CASE (Y2 - 15) TO (Y2 + 30) GOSUB Precheck END SELECT LOOP 'Main Program Loop Precheck: 'Since the last Case found their Y location similiar, It SELECT CASE X 'checks their X locations. If it's in range, contact occurs. CASE X1 TO (X1 + 10) 'Reverse Ball's X direction and play Sound to show Xadj = 2: SOUND 37, 1 'contact occured CASE (X2 - 10) TO X2 'Reverse Ball's X direction and play Sound to show Xadj = -2: SOUND 37, 1 'contact occured END SELECT RETURN Keys: SELECT CASE INKEY$ 'Get Input from Keyboard CASE IS = CHR$(0) + CHR$(72) 'Player 1 Up GOSUB up CASE IS = CHR$(0) + CHR$(80) 'Player 1 Down GOSUB Down CASE IS = "Q", "q" 'Player 2 Up GOSUB Up2 CASE IS = "A", "a" 'Player 2 Down GOSUB Down2 END SELECT RETURN Down: 'Move First Player Down IF Y1 < 142 THEN 'Makes sure Paddle doesn't go Offscreen FOR i = 1 TO 3 'Make Animation Smooth Y1 = Y1 + 3 PUT (X1, Y1), Paddle, PSET Y1 = Y1 + 3 NEXT i END IF RETURN 'Go back to Main Program Down2: 'Move Second Player Down IF Y2 < 142 THEN 'Makes sure Paddle doesn't go Offscreen FOR i = 1 TO 3 'Make Animation Smooth Y2 = Y2 + 3 PUT (X2, Y2), Paddle, PSET Y2 = Y2 + 2 NEXT i END IF RETURN 'Go back to Main Program up: 'Move First Player Up IF Y1 > 6 THEN 'Makes sure Paddle doesn't go Offscreen FOR i = 1 TO 3 'Make Animation Smooth Y1 = Y1 - 3 PUT (X1, Y1), Paddle, PSET Y1 = Y1 - 3 NEXT i END IF RETURN 'Go back to Main Program Up2: 'Move Second Player Up IF Y2 > 6 THEN 'Makes sure Paddle doesn't go Offscreen FOR i = 1 TO 3 'Make Animation Smooth Y2 = Y2 - 3 PUT (X2, Y2), Paddle, PSET Y2 = Y2 - 3 NEXT i END IF RETURN 'Go back to Main Program ******************************************************* {cut here} Section 3 Remember, don't try to over-achieve yourself on your First game. In other words, On your first try, make something like Pac-Man, not DOOM. A game can be broken down in a few sections 1. The Game World and it's Data 2. The Graphics Engine(Which draws the sprites on the screen) 3. The Input/Output System(Whether it's the Keyboard, Joystick or Mouse) 4. The Game's Artificial Intelligence System 5. The Main Game Loop(The Loop that continously loops during the game) 6. The User Interface(Title Screen, Options, Score, Lives, Energy, etc.) 7. The Sound Effects system(Spices up the Gameplay) Any Questions should be directed to me at: diego@sgi.net Check out my NEW and Constantly updated Web Page at: Http://www.geocities.com/SiliconValley/6165/ -------------------------------------------------------- * EDITOR'S NOTE: * This article was originally printed in Peter Cooper's BASIX Fanzine, * Issue #5 from April 1996.