VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT

Preview:

Citation preview

VIDEO GAME PROGRAMMING

Video Game Programmin

g

Junior – DigiPutt

INSTRUCTOR

<instructor name>

TEACHER’S ASSISTANT

<TA name>

VIDEO GAME PROGRAMMING

PART 1 – Game Properties

Objective:– Set up basic game properties. This is

usually the first step when starting a project from scratch.

• Step 1 – Open Project Properties.• Step 2 – Set Project Properties.

VIDEO GAME PROGRAMMING

STEP 1: Open Project Properties

• In FUN, go to the Project menu and select Properties.

• You can also just hit <alt + enter> to open the Project Properties.

VIDEO GAME PROGRAMMING

STEP 2: Set Project Properties

• Set the Compiler to use either Microsoft Visual C++ 6.0 or Borland Free Command Line Tools.

• Set the Window Title to whatever you want to call your game (DigiPutt for instance).

VIDEO GAME PROGRAMMING

PART 2 – Level OnStart Tab

Objective:– Add functionality to the OnStart tab of a

level.

• Step 1 – Add Code.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Code

• Open the Level Properties for the title level and click on the OnStart tab.

• Type the following EXACTLY:MouseCenter();

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• When you start a new game the

mouse cursor should automatically be at the center of the screen.

VIDEO GAME PROGRAMMING

PART 3 – Add Map to hole1 Level

Objective:– Add a new map to the level hole1.

• Step 1 – Add Map.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Map

• Add a new Map to hole1 and set the following properties:

1. Name: main2. File: hold1.bmp (in Maps folder)3. Collision Data: Draw Rectangular

Collision data around the hole with inward pointing normals. Draw data around the walls with outward pointing normals.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• At this point, nothing should be

happening, we just want to make sure you have everything all right and good.

VIDEO GAME PROGRAMMING

PART 4 – Adding the Tee

Objective:– Add a “tee” sprite to hole1. This is

important as, when the game goes to place a ball, we use the tee sprite to tell it where to put the new balls.

• Step 1 – Add a New Sprite.• Step 2 – Set Sprite Properties.

VIDEO GAME PROGRAMMING

STEP 1: Add a New Sprite

• Add a new Sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• Set the following Properties for the hole1 sprite:

1. Name: tee2. Map: main3. Actor: TEE4. Initial Animation: UP5. Position: Place on top of the spot

labeled “tee” on the map.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

6. Collision: Loose Collision, Activate Sprite Collision, Check With Sprites, Ghost Collision, Check Same Display List

VIDEO GAME PROGRAMMING

PART 5 – Adding the Cursor

Objective:– Add the cursor for our main game. The

player will use the cursor as his/her club.

• Step 1 – Add a New Sprite.• Step 2 – Set Sprite Properties.

VIDEO GAME PROGRAMMING

STEP 1: Add a New Sprite

• Add a new Sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• Set the following properties:1. Name: cursor2. Map: main3. Display List: 24. Local Data: CursorData5. Actor: CURSOR6. Peg Registered: Checked

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

7. Behavior: MouseCursorMoveFN8. Collision: Loose Collision, Activate,

Check With Sprites, Ghost Collision, Show Bounding Box (optional)

VIDEO GAME PROGRAMMING

PART 6 – Set Mouse to Center

Objective:– Set the cursor to start at the center of

the screen.

• Step 1 – Add Code.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Code

• Open the Level Properties for hole1.

• Click on the OnStart tab.• Add the following EXACTLY:MouseCenter();

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• You should see both the tee and the

cursor and the cursor should start at the center of the screen.

VIDEO GAME PROGRAMMING

PART 7 – Adding the Ball

Objective:– Add the ball to the game.

• Step 1 – Add a New Sprite.• Step 2 – Set Sprite Properties.• Step 3 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add a New Sprite

• Add a new Sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• GENERAL:1. Name: ball2. Map: main3. Display List: 14. Unused: Checked5. Local Data: BallData

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• ANIMATION:1. Actor: BALL2. Initial Animation:

YELLOW_NORMAL3. Peg Registered: Checked

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• BEHAVIOR:1. State Machines:

BallCursorDragSM, BallAnimationSetSM

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• COLLISION:1. Precise: Check2. Activate Sprite Collision: Check3. Check With Sprites: Check4. Ghost Collision: Check5. Check Same Display List: Check6. Check With Map: Check

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• EFFECTS:1. Reflection: Check2. Friction: 15

VIDEO GAME PROGRAMMING

STEP 3: Build and Run

• Build and Run your game.• You shouldn’t see your ball because

we checked Unused. This is important!

VIDEO GAME PROGRAMMING

PART 8 – Creating Sprites at Run Time

Objective:– Have multiple balls spawn for multiple

players.

• Step 1 – Explanation.• Step 2 – Add Behavior to Level.• Step 3 – Build and Run.

VIDEO GAME PROGRAMMING

CONCEPT – Creating Sprites at Run Time

• In Number Attack we had to potentially create an infinite number of enemies, so we couldn’t just add infinite sprites to our level and place them, we used a function that spawned them at run-time.

• We need to do this in DigiPutt because we don’t know how many players we’re going to have in the game, so we have a function to spawn balls at run time based on how many people are playing.

VIDEO GAME PROGRAMMING

STEP 2: Add Behavior to Level

• Open the Level Properties for hole1 and click the OnStart tab.

• Add the following EXACLTY:CreateBallsForLevel();

VIDEO GAME PROGRAMMING

STEP 3: Build and Run

• Build and Run the game.• Try starting a Multiplayer game with at

least 2 players.• Hit the balls by clicking on them, dragging

the mouse, and then releasing the left mouse button.

• Could you hit anything but the yellow ball?

VIDEO GAME PROGRAMMING

PART 9 – Player Selection and Quitting

Objective:– Add the ability to change turns (so other

people can play). Also, add the ability to hit <escape> to quit the game.

• Step 1 – Add Behavior to Level.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to Level

• Open the Level Properties for hole1 and set the following:

1. Behavior: Add the LevelChangeTurnFN and KeyboardFirstLevelFN functions.

2. Quit on Escape: Uncheck this box.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• Try starting a multiplayer game

again.• You should now be able to change

whose turn it is using the 1-9 Keys on the keyboard.

VIDEO GAME PROGRAMMING

PART 10 – Adding the Hole

Objective:– Add the hole to the game.

• Step 1 – Create a new Sprite.• Step 2 – Set Properties.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Sprite

• Create a new Sprite in hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties

• Set the following properties for the new sprite:

1. Name: hole2. Map: main3. Actor: HOLE4. Position: Manually place on top of

the H on the map.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties continued…

5. Collision: Precise, Activate Sprite Collision, Check With Sprites, Ghost Collision

VIDEO GAME PROGRAMMING

PART 11 – Update the Ball’s Behavior

Objective:– Add some more behavior to the ball. We’re

going to make it so the balls ghost collision is turned off after it leaves the tee so it can run into other balls and changes animation once it’s in the hole.

• Step 1 – Add Behavior to ball.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to ball

• Add the following functions to the ball sprite:

1. BallCollisionOffTeeFN 2. BallDeleteInHoleFN

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• Try hitting multiple balls so they collide

with each other.• We don’t quite have correct behavior, but

we’re close.• Also, if you get a ball in the hole, the game

is supposed to crash (the game is looking for the ‘par’ for the hole, which we haven’t added, so it crashes.)

VIDEO GAME PROGRAMMING

PART 12 – Making Stationary Balls Move When Struck

Objective:– Add the ability to make balls already on

the course move when struck.

• Step 1 – Add Behavior to ball.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to ball

• Add the BallSetSpeedOnCollisionFN function to the ball sprite.

• This will make it so, when 2 balls collide, the stationary ball will start rolling.

VIDEO GAME PROGRAMMING

PART 13 – Displaying the Final Scores

Objective:– Add final scores to the gameover

screen.

• Step 1 – Add Behavior to end Level.• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to end Level

• Open the Level Properties for the end level.

• Under OnStart type the following EXACTLY:

DisplayFinalScores();• Next, add the KeyboardFirstLevelFN

function under Behavior and UNCHECK the Quit on Escape box.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Now Build and Run your game.• Now, when all the balls are in the

hole, you can hit <enter> to go to the end level and view every players score.

VIDEO GAME PROGRAMMING

PART 14 – Adding Bumpers

Objective:– Add bumpers around the level that the

ball can bounce off of.

• Step 1 – Create a new Sprite.• Step 2 – Set Properties.

VIDEO GAME PROGRAMMING

STEP 1: Add a new Sprite

• Add a new Sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties

• Set the following Properties for the new sprite:

1. Name: bumper2. Map: main3. Actor: BUMPER4. Initial Animation: UPPERLEFT

VIDEO GAME PROGRAMMING

STEP 2: Set Properties continued…

5. Position: Manually place the bumper on the spot labeled 1 on the map.

6. Collision: Precise, Activate Sprite Collision, Check With Sprites

VIDEO GAME PROGRAMMING

PART 15 – Creating More Bumpers

Objective:– Add more bumpers (go figure).

• Step 1 – Insert Copy of bumper Sprite.

• Step 2 – Set Properties.• Step 3 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Insert Copy of bumper Sprite

• Insert a Copy of the bumper sprite and name it bumper2.

• Insert another Copy of the bumper sprite and name it bumper3.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties

• Set these Properties for the bumper2 sprite:

1. Initial Animation: UPPERRIGHT2. Position: Manually place it on the spot

labeled 2 on the map.• Set these for bumper3:1. Initial Animation: LOWERLEFT2. Position: Manually place it on the spot

labeled 3 on the map.

VIDEO GAME PROGRAMMING

STEP 3: Build and Run

• Build and Run your game.• You should have working bumpers to

assist you in putting the ball around corners.

VIDEO GAME PROGRAMMING

PART 16 – Adding Ball Response to Water Traps

Objective:– Add Water Trap Functionality to the ball.

Later, we’ll be adding water traps that, when the ball hits the trap, causes the player to lose a stroke.

• Step 1 – Add Behavior to ball Sprite.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to ball Sprite

• Add the BallOnWaterFN function to the ball sprite.

VIDEO GAME PROGRAMMING

CONCEPT – Interactive “Tiles”

• In DigiPutt we’re going to have a number of interactive tiles. These tiles are small sprites that we bunch together in groups to create the illusion of having one much larger sprite.

• We use these tiles to affect the ball in special ways (water traps, sand, etc.)

VIDEO GAME PROGRAMMING

PART 17 – Add the First Water Trap “Tile”

Objective:– Add the base water trap tile. Later,

we’ll be making multiple copies of this sprite in a group.

• Step 1 – Add a New Sprite.• Step 2 – Set Properties.

VIDEO GAME PROGRAMMING

STEP 1: Add a New Sprite

• Add a new Sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties

• Set the following properties for the new sprite:

1. Name: water2. Map: main3. Actor: WATER4. Collision: Loose, Activate, Check

With Sprites, Ghost

VIDEO GAME PROGRAMMING

PART 18 – Create Group of Water Trap Sprites

Objective:– Add the base water trap tile. Later,

we’ll be making multiple copies of this sprite in a group.

• Step 1 – Create a New Group of Sprites.

• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Create a New Group of Sprites

• Right-click on the water sprite and select Create Group.

• Use the Rectangle Tool to draw a square around the area of the map labeled Water.

• Set Horizontal and Vertical Spacing to 0.

VIDEO GAME PROGRAMMING

STEP 1: Create a New Group of Sprites continued…

• Use the Magic Wand to fill the area with sprites.

• Close the window and name the group water.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Now Build and Run your game.• Try hitting a ball into the water.• You should get a 1 stroke penalty

and your ball should be placed back where it started.

• If you hit the ball hard enough, it will skip over the water!

VIDEO GAME PROGRAMMING

PART 19 – Adding Ball Response to Sand

Objective:– Add Sand Trap response behavior to

the ball. Sand Traps greatly reduce the speed of the ball (or increase friction).

• Step 1 – Add Behavior to the Ball.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to the Ball

• Add the BallOnSandFN function to the ball sprite.

• This will make it so that when any ball collides with sand traps, the friction of the ball is greatly increased, thus the ball is slowed down.

VIDEO GAME PROGRAMMING

PART 20 – Adding the First Sand Trap “Tile”

Objective:– Add sand sprite.

• Step 1 – Create a New Sprite.• Step 2 – Set Sprite Properties.

VIDEO GAME PROGRAMMING

STEP 1: Create a New Sprite

• Add a new Sprite to the hole1 level.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• Set the following properties for the new sprite:

1. Name: sand2. Map: main3. Actor: SAND4. Collision: Loose, Activate, Check

with Sprites, Ghost Collision

VIDEO GAME PROGRAMMING

PART 21 – Create Group of Sand Trap Sprites

Objective:– Create a group of sand sprites.

• Step 1 – Create a new Group of Sprites.

• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Group of Sprites

• Right-click on the sand sprite and select Create Group.

• Use the Rectangle Tool to draw a square around the area of the map labeled Sand.

• Set Horizontal and Vertical Spacing to 0.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Group of Sprites continued…

• Use the Magic Wand to fill the area with sprites.

• Close the window and name the group sand.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Now Build and Run your game.• Try hitting some balls over the sand.• Notice how the ball slows down

significantly.

VIDEO GAME PROGRAMMING

PART 22 – Adding Ball Response to Hills

Objective:– Add Hill response behavior to the ball.

Hills will cause the ball to slowly accelerate downward.

• Step 1 – Add Behavior to the Ball.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior to the Ball

• Add the BallOnHillFN function to the ball sprite.

• This will make it so that when any ball collides with hills the ball slowly starts moving downward.

VIDEO GAME PROGRAMMING

PART 23 – Adding the First Hill Sprite

Objective:– Add hill sprite.

• Step 1 – Create a New Sprite.• Step 2 – Set Sprite Properties.

VIDEO GAME PROGRAMMING

STEP 1: Create a New Sprite

• Add a new Sprite to the hole1 level.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• Set the following properties for the new sprite:

1. Name: hill2. Map: main3. Actor: HILLTILE4. Initial Animation: DOWN5. Collision: Loose, Activate, Check with

Sprites, Ghost Collision

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• Next, set the Speed to 0.06.• We use the hill’s speed to define

how steep the hill is.• Since the hill’s vector direction is

(0,0) it’s not actually moving.• You’ll want to use values between

0.01 and 0.06.

VIDEO GAME PROGRAMMING

PART 24 – Create Group of Hill Sprites

Objective:– Create a group of hill sprites.

• Step 1 – Create a new Group of Sprites.

• Step 2 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Group of Sprites

• Right-click on the hill sprite and select Create Group.

• Use the Rectangle Tool to draw a square around the area of the map labeled Hill1.

• Set Horizontal and Vertical Spacing to 0.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Group of Sprites continued…

• Use the Magic Wand to fill the area with sprites.

• Close the window and name the group hill.

VIDEO GAME PROGRAMMING

STEP 2: Build and Run

• Build and Run your game.• Try hitting a ball onto the hill.• Does the hill affect the movement of

the ball?

VIDEO GAME PROGRAMMING

PART 25 – Adding Another Hill

Objective:– Create a new hill sprite.

• Step 1 – Create a new Sprite.• Step 2 – Set Sprite Properties. • Step 3 – Create a new sprite group.

VIDEO GAME PROGRAMMING

STEP 1: Create a New Sprite

• Add a new Sprite to the hole1 level.

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties

• Set the following properties for the new sprite:

1. Name: hill2. Map: main3. Actor: HILLTILE4. Initial Animation: DOWN5. Collision: Loose, Activate, Check with

Sprites, Ghost Collision

VIDEO GAME PROGRAMMING

STEP 2: Set Sprite Properties continued…

• Next, set the Speed to 0.05.

VIDEO GAME PROGRAMMING

STEP 3: Create a New Sprite Group

• Create a group of hill sprites out of the hill sprite you just created. Create the group over the part of the map labeled hill2 and name the group hill2.

VIDEO GAME PROGRAMMING

PART 26 – Adding Ball Response to Rollers

Objective:– Add Roller Response to the ball sprite.

Rollers are different than hills in that they are a bigger, single sprite and the ball won’t stop on a roller, unlike a hill.

• Step 1 – Add behavior.

VIDEO GAME PROGRAMMING

STEP 1: Add Behavior

• Add the BallOnRollerFN function to the ball sprite.

VIDEO GAME PROGRAMMING

PART 27 – Adding a Roller

Objective:– Now that we have the functionality in,

let’s add a roller sprite.

• Step 1 – Create a new sprite.• Step 2 – Set properties.• Step 3 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Create a new Sprite

• Add a new sprite to hole1.

VIDEO GAME PROGRAMMING

STEP 2: Set Properties

• Set the following properties for the new sprite:

1.Name: roller2.Map: main3.Actor: ROLLER4.Initial Animation: DOWN5.Collision: Loose, Activate, Check with

Sprites, Ghost Collision

VIDEO GAME PROGRAMMING

STEP 2: Set Properties continued…

6. Speed: 0.357. Position: Manually place on the

part of the map labeled Roller.

VIDEO GAME PROGRAMMING

STEP 3: Build and Run

• Build and Run your game.• Hit the ball so it goes over a roller.

The ball should be pushed downward as long as it’s on the roller.

VIDEO GAME PROGRAMMING

PART 28 – Adding a new Hole

Objective:– Congrats! You’ve finished the first hole.

Now we’re going to add another hole.

• Step 1 – Create the art for hole2.• Step 2 – Insert a copy of hole1.• Step 3 – Build and Run.

VIDEO GAME PROGRAMMING

STEP 1: Create the Art for Hole2

• Open MS Paint.• Open the file hole_template.bmp and

IMMEDIATELY go to File->Save As and save it as hole2.bmp.

• You should do this for every new hole you create so you can reuse this template art.

• Draw the hole. When you’re done, just go to File->Save to save it.

VIDEO GAME PROGRAMMING

STEP 2: Insert a Copy of Hole1

• Right-Click on hole1 and select Insert Copy.

• Name the copy hole2.• MAKE SURE you select Insert After

hole1. If you don’t do this, your levels will be out of order and your game won’t work.

VIDEO GAME PROGRAMMING

STEP 2: Insert a Copy of Hole1 continued…

• Right-click on every sprite group in hole2 and select Restore to One. This way you can create multiple copies of your base tile sprites and insert multiple groups of sprites.

• If you don’t want to use a sprite (the roller for instance) then open the Sprite Properties for that sprite and check the Unused box.

Recommended