Download presentation
Presentation is loading. Please wait.
Published byNicholas Ball Modified over 9 years ago
1
VIDEO GAME PROGRAMMING Video Game Programming Junior – Number Attack INSTRUCTOR TEACHER’S ASSISTANT
2
VIDEO GAME PROGRAMMING CONCEPT – Wrapping Maps A Wrapping Map is a map that loops when you reach the edges. Imagine a map drawn on a toilet paper roll. Wrapping maps are used a lot in space games and flying games (as stars, clouds or ground).
3
VIDEO GAME PROGRAMMING PART 1 – Wrapping Map Objective: –Create the basic map that will scroll underneath our plane. Step 1 – Create Map Art. Step 2 – Add Wrapping Map to Title Level. Step 3 – Build and Run.
4
VIDEO GAME PROGRAMMING STEP 1: Create Map Art Open MS Paint and create an 800x1200 map of some ground. Save as wrappingMap.bmp in your Maps folder.
5
VIDEO GAME PROGRAMMING STEP 2: Add Wrapping Map to Title Level Add a new Map to the Title level. Set the following in the General tab: 1.Map Name: wrappingMap 2.File Name: the map you created. 3.Wrap: Check this box.
6
VIDEO GAME PROGRAMMING STEP 2: Add Wrapping Map to Title Level continued… Under the Scrolling tab, set the Y Speed to 5.
7
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. If all is well, you should see your map scrolling downward. If you want the map to scroll faster or slower, change the Y Speed to whatever you want.
8
VIDEO GAME PROGRAMMING PART 2 – Transparent Map Objective: –Create the Title Screen Logo. We’re going to make it transparent so we can see our scrolling map behind it. Step 1 – Create Map Art. Step 2 – Add Transparent Map to Title Level. Step 3 – Build and Run.
9
VIDEO GAME PROGRAMMING STEP 1: Create Map Art Open MS Paint and create an 800x600 picture with the words “Number Attack” drawn in however you like. Make sure the area that is supposed to be transparent is green. Save as title.bmp in your Maps folder.
10
VIDEO GAME PROGRAMMING STEP 2: Add Transparent Map to Title Level Add a new Map to the Title level. Set the following in the General tab: 1.Map Name: main 2.File Name: the map you created. 3.Use Transparency: Check this box.
11
VIDEO GAME PROGRAMMING STEP 2: Add Transparent Map to Title Level continued… In the Position Tab, set the Z- Order to 1.
12
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. If all is well, you should see your map scrolling downward with your Number Attack art on top of it.
13
VIDEO GAME PROGRAMMING PART 3 – Cursor Objective: –Create a cursor for the title screen that will allow us to interact with buttons later on. Step 1 – Tweak Cursor Art (Optional). Step 2 – Add Cursor Sprite to Title Level. Step 3 – Build and Run.
14
VIDEO GAME PROGRAMMING STEP 1: Tweak Cursor Art (Optional) If you would like to change the cursor art, simply open the CURSOR actor’s CURSOR animation set. Double-click on the single frame of animation to open MS Paint. When you’re done, go to File->Save (not Save-As)
15
VIDEO GAME PROGRAMMING STEP 2: Add Cursor Sprite to Title Level Add a new Sprite to the Title level. Set the following in the General tab: 1.Name: cursor 2.Map: main 3.Z-Order: 1
16
VIDEO GAME PROGRAMMING STEP 2: Add Cursor Sprite to Title Level continued… In the Animation Tab, use the CURSOR Actor. In the Behavior Tab, add the MouseCursorMoveFN function.
17
VIDEO GAME PROGRAMMING STEP 2: Add Cursor Sprite to Title Level continued… Check the following boxes or bubbles in the Collision tab: 1.Loose Collision 2.Activate Sprite Collision 3.Check With Sprites 4.Ghost Collision 5.Check Same Display List
18
VIDEO GAME PROGRAMMING CONCEPT – Loose Collision Loose Collision tells FUN to use the sprite’s Bounding Box instead of any collision data we’ve defined. The Bounding Box is automatically created and wraps the ENTIRE sprite in a collision box. When would we not want to use Loose Collision?
19
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should be able to move the cursor around now.
20
VIDEO GAME PROGRAMMING PART 4 – Interface Buttons Objective: –Now that we have a cursor, let’s make some buttons that let us Start or Quit the game. Step 1 – Add Start Sprite to Title Level. Step 2 – Add Quit Sprite to Title Level. Step 3 – Reposition Sprites Using Level Preview. Step 4 – Build and Run.
21
VIDEO GAME PROGRAMMING STEP 1: Add Start Sprite to Title Level Add a new Sprite to the Title level. Set the following in the General tab: 1.Name: start 2.Map: main
22
VIDEO GAME PROGRAMMING STEP 1: Add Start Sprite to Title Level continued… In the Animation Tab, use the BUTTON_START Actor. In the Behavior Tab, add the ButtonStartFN function.
23
VIDEO GAME PROGRAMMING STEP 1: Add Start Sprite to Title Level continued… Check the following boxes or bubbles in the Collision tab: 1.Loose Collision 2.Activate Sprite Collision 3.Check With Sprites 4.Ghost Collision 5.Check Same Display List
24
VIDEO GAME PROGRAMMING STEP 1: Add Start Sprite to Title Level continued… You can change the art in the BUTTON_START Actor if you want to.
25
VIDEO GAME PROGRAMMING STEP 2: Add Quit Sprite to Title Level Insert a copy of the start sprite and name it quit. In the Animation Tab, use the BUTTON_QUIT Actor. In the Behavior Tab, remove the ButtonStartFN function and add the ButtonQuitFN function.
26
VIDEO GAME PROGRAMMING CONCEPT – If – Else Statements If Else statements are just like if statements, except if the conditional is false, then the computer executes the code under the else statement Open the ButtonQuitFN function. You’ll notice a part in the code that says something like:
27
VIDEO GAME PROGRAMMING CONCEPT – If – Else Statements continued… if(This->CollisionWithSprite("cursor")) { This->Animation(1); if(MouseTriggered(DIM_LEFT)) { myGame->EndGame(); } else { This->Animation(0); }
28
VIDEO GAME PROGRAMMING STEP 3: Reposition Sprites Using Level Preview Open the Level Preview for the Title level and place your start and quit sprites wherever you want them. Place them kind of far apart from eachother; if they’re too close you might click on both of them at the same time. This would be bad…
29
VIDEO GAME PROGRAMMING STEP 4: Build and Run Build and Run your game. Check out what the start and quit buttons do. If you can click on both of them at the same time, reposition them until you can’t. What happens when you click the start button? Why?
30
VIDEO GAME PROGRAMMING PART 5 – Set Up Level1 Objective: –Add the maps to the first level. Step 1 – Add Wrapping Map to Level1. Step 2 – Add Map to Level1. Step 3 – Build and Run.
31
VIDEO GAME PROGRAMMING STEP 1: Add Wrapping Map to Level1 Add a new Map to level1. Set the following in the General tab: 1.Map Name: wrappingMap 2.File Name: use wrappingMap.bmp 3.Wrap: Check this box
32
VIDEO GAME PROGRAMMING STEP 1: Add Wrapping Map to Level1 continued… In the Scrolling tab, set the Y Scroll Speed to 5 (or whatever you set it to in the title level).
33
VIDEO GAME PROGRAMMING STEP 2: Add Map to Level1 Add a new Map to level1. Set the following properties: 1.Map Name: main 2.File Name: mainBG.bmp 3.Use Transparency: Check this. 4.Z-Order: Set to 1.
34
VIDEO GAME PROGRAMMING STEP 2: Add Map to Level1 continued… Now add Collision Data to the map. Just make a big square around the edge of the map. Make sure your normals are pointing toward the center of the map (inward).
35
VIDEO GAME PROGRAMMING CONCEPT – Transparent Maps In FUN, you cannot add sprites (text objects, etc) to wrapping maps. To add sprites to our level, we need to have a non-wrapping map on top of our wrapping map. We make it completely transparent so we can see our wrapping map below it.
36
VIDEO GAME PROGRAMMING STEP 3: Build and Run Now Build and Run your game. This time, when you hit the start button on the title screen it should be displaying something instead of a black screen when you enter level1.
37
VIDEO GAME PROGRAMMING PART 6 – Adding the Player Objective: –Add the player to the first level. Step 1 – Create Player Art. Step 2 – Add PLAYER Actor. Step 3 – Add Player Sprite to Level1. Step 4 – Build and Run.
38
VIDEO GAME PROGRAMMING STEP 1: Create Player Art Open MS Paint and create 2 planes (both 60x60). Make the first one have a red theme and the second have a blue theme. Save them in your Actors folder as player1.bmp and player2.bmp.
39
VIDEO GAME PROGRAMMING STEP 2: Add PLAYER Actor Create a new Actor named PLAYER. Add a new Animation Set named ONE. Add player1.bmp to ONE and give it collision data. Add a new Animation Set named TWO. Add player2.bmp to TWO and give it collision data.
40
VIDEO GAME PROGRAMMING STEP 3: Add Player Sprite to Level1 Create a new Sprite in level1. Set the following properties: 1.Name: player1 2.Map: main 3.Actor: PLAYER 4.Initial Animation: ONE
41
VIDEO GAME PROGRAMMING STEP 3: Add Player Sprite to Level1 continued… 5.Behavior: Add KeyboardWASDMovementFN. 6.Position: Manually place using ‘…’ 7.Precise Collision: Check this 8.Activate Sprite Collision: and this 9.Check With Sprites: and this… 10.Check With Map: and this. 11.Speed: 5
42
VIDEO GAME PROGRAMMING STEP 4: Build and Run Now Build and Run your game. You should have a red ship flying around the screen. Make sure you can move it with WASD keys.
43
VIDEO GAME PROGRAMMING PART 7 – Projectiles Objective: –Add some projectiles to our game. Step 1 – Create Projectile Art. Step 2 – Add PLAYERSHOT Actor. Step 3 – Add PlayerShot Sprite to Level1. Step 4 – Build and Run.
44
VIDEO GAME PROGRAMMING STEP 1: Create Projectile Art Open MS Paint and create 2 projectiles (both 16x16). Give the first one a red theme and the second one a blue theme. Save them as playerShot1.bmp and playerShot2.bmp in your Actors folder.
45
VIDEO GAME PROGRAMMING STEP 2: Add PLAYERSHOT Actor Create a new Actor named PLAYERSHOT. Add a new Animation Set named ONE. Add playerShot1.bmp to ONE and give it collision data. Add a new Animation Set named TWO. Add playerShot2.bmp to TWO and give it collision data.
46
VIDEO GAME PROGRAMMING STEP 3: Add PlayerShot Sprite to Level1 Add a new Sprite to level1. In the General Tab set the following: 1.Name: playerShot 2.Map: main 3.Unused: Check this 4.Local Data: ShotData
47
VIDEO GAME PROGRAMMING CONCEPT – Local Data Local Data is a set of data that belongs to a particular object. We can define one set of Local Data that is used by multiple objects. For instance, we can define a set of local data containing Health and then give it to our enemy sprites. That way, FUN can track each enemies individual Health as they get hit.
48
VIDEO GAME PROGRAMMING STEP 3: Add PlayerShot Sprite to Level1 continued… Set the following in the Animation Tab: 1.Actor: PLAYERSHOT 2.Initial Animation: ONE 3.Peg Registered: Check This
49
VIDEO GAME PROGRAMMING CONCEPT – Peg Registered Normally, when FUN draws sprites, it starts drawing the top-left pixel at the position of the sprite. This is a problem if we have multiple frames of animation each with different sizes. Peg Registration means that FUN will draw the Sprite using its center as the position of the sprite.
50
VIDEO GAME PROGRAMMING CONCEPT – Peg Registered continued…
51
VIDEO GAME PROGRAMMING STEP 3: Add PlayerShot Sprite to Level1 continued… Check the following in the Collision Tab: 1.Precise Collision 2.Activate Sprite Collision 3.Check With Sprites 4.Ghost Collision
52
VIDEO GAME PROGRAMMING STEP 3: Add PlayerShot Sprite to Level1 continued… Add the SpriteDeleteOutOfViewportFN and ShotDeleteOnSpriteCollisionFN functions. Set the Speed to 8.
53
VIDEO GAME PROGRAMMING CONCEPT – Delete Flag Open up the SpriteDeleteOutOfViewportFN function. if (This->InViewport() == FALSE) { // delete this sprite This->DeleteFlag(TRUE); }
54
VIDEO GAME PROGRAMMING CONCEPT – Delete Flag continued… When the sprite is no longer visible, we want to delete it. The problem is, if we delete it right then and there, it might cause problems in the game and crash it. Instead, we set a flag that tells FUN to delete that sprite at the end of the current game loop.
55
VIDEO GAME PROGRAMMING PART 7.1 – Player Shooting Objective: –Add proper behavior to allow the player to shoot. Step 1 – Add Behavior to Player Sprite. Step 2 – Change Player HotSpots. Step 3 – Build and Run.
56
VIDEO GAME PROGRAMMING STEP 1: Add Behavior to Player Sprite Add the KeyboardShootFN to the player sprite.
57
VIDEO GAME PROGRAMMING STEP 2: Change Player HotSpots Open the PLAYER actor’s ONE animation set. Where it says Hot Spots, click the ‘…’ button next to Hot Spot 0.
58
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. Now try shooting. If your bullet is coming out the wrong part of the ship, try changing Hot Spot 0 until it’s right.
59
VIDEO GAME PROGRAMMING PART 8 – Adding Numbers Objective: –Add numbers the player can shoot to receive bonuses. Step 1 – Add Number Sprite to Level1. Step 2 – Add Spawning Behavior to Level1. Step 3 – Build and Run.
60
VIDEO GAME PROGRAMMING STEP 1: Add Number Sprite to Level1 Add a new Sprite to level1. Set the following properties: 1.Name: number 2.Map: main 3.Unused: Check this 4.Display List: 1
61
VIDEO GAME PROGRAMMING STEP 1: Add Number Sprite to Level1 continued… 5.Actor: NUMBER 6.Initial Animation: ZERO 7.Precise Collision: Check this 8.Activate Sprite Collision: and this 9.Check With Sprites: and this… 10.Ghost Collision: and this.
62
VIDEO GAME PROGRAMMING STEP 1: Add Number Sprite to Level1 continued… Under the Displacement Tab set: 1.Speed: 4 2.Vector Direction: Y = 1
63
VIDEO GAME PROGRAMMING STEP 1: Add Number Sprite to Level1 continued… Finally, add the SpriteDeleteBelowViewportFN function to the sprite. We use this function because our numbers will be falling and, once they reach the bottom of the screen, we can’t shoot them, so we delete them.
64
VIDEO GAME PROGRAMMING STEP 2: Add Spawning Behavior to Level1 Add the LevelNumberSpawnFN function to level1. Open this function, let’s have a look…
65
VIDEO GAME PROGRAMMING CONCEPT – Game Loops A Game Loop represents the action the game takes every single frame. Game Loops do things like: Check for Input AI Physics Play Sound Render
66
VIDEO GAME PROGRAMMING CONCEPT – Game Loops continued… Once a Game Loop executes everything it’s supposed to do, it starts over again from the beginning.
67
VIDEO GAME PROGRAMMING CONCEPT – While Loops While Loops are how we implement a Game Loop. A while loop repeatedly executes the code inside of it until the conditional becomes false, or rather, while the conditional is true.
68
VIDEO GAME PROGRAMMING CONCEPT – While Loops continued… While loops look something like this… while (somethingIsTrue) { doThisCode; }
69
VIDEO GAME PROGRAMMING STEP 3: Build and Run Now Build and Run your game. You should have some random numbers appearing around the top of the level and slowly falling toward the bottom.
70
VIDEO GAME PROGRAMMING PART 9 – Movement Patterns Objective: –Make the numbers follow a specific movement pattern. Step 1 – Add a New Movement Pattern. Step 2 – Add Movement Pattern to Number Sprite. Step 3 – Build and Run.
71
VIDEO GAME PROGRAMMING CONCEPT – Movement Patterns A Movement Pattern is a defined course a sprite will follow if it can. Movement Patterns are useful tools when we’re developing AI for enemies.
72
VIDEO GAME PROGRAMMING STEP 1: Add a New Movement Pattern Under the Game Assets tree, right- click on Movement Patterns and select Add. Click the Free Track button and draw a movement pattern starting from somewhere near the top and working down. Name it NumberFallMP and Save.
73
VIDEO GAME PROGRAMMING STEP 2: Add Movement Pattern to Number Sprite Open the Properties for the number sprite and click the Movement Tab. Click the Movement Pattern box. Select the NumberFallMP pattern. Click the Initially Started and Loop boxes.
74
VIDEO GAME PROGRAMMING STEP 3: Build and Run Now Build and Run your game. Do the numbers follow the pattern you gave them? Go ahead and tweak the movement pattern until the enemies are doing what you want them to do.
75
VIDEO GAME PROGRAMMING PART 10 – Make Numbers Shootable Objective: –Make the numbers follow a specific movement pattern. Step 1 – Add Proper Behavior. Step 2 – Build and Run.
76
VIDEO GAME PROGRAMMING STEP 1: Add Proper Behavior Add the SpriteDeleteNumberOnCollisionF N function to the playerShot sprite.
77
VIDEO GAME PROGRAMMING STEP 2: Build and Run You got it! Build and Run your game. At this point you should have numbers spawning, moving around, and dying when you shoot them. If not, let us know.
78
VIDEO GAME PROGRAMMING PART 11 – Make Things Explode Objective: –My personal favorite, now we’re going to add some flashy visuals when something dies. Step 1 – Add a New Particle System. Step 2 – Build and Run.
79
VIDEO GAME PROGRAMMING STEP 1: Add a New Particle System Under level1, right-click on Particle Systems and select Add. Set the following properties: 1.Name: ExplodeRed 2.Unused: Check. 3.Number of Particles: 1000 4.Belongs to: main
80
VIDEO GAME PROGRAMMING STEP 1: Add a New Particle System continued… Now, open the text file Explode Particle System.txt located in your game’s root directory. Highlight all the code using then copy ( ) and paste ( ) it into the ExplodeRed particle system.
81
VIDEO GAME PROGRAMMING STEP 2: Build and Run Build and Run your game. Now try shooting some numbers. You can play around with the values inside the ExplodeRed particle system to see what each thing does.
82
VIDEO GAME PROGRAMMING PART 12 – Operators Objective: –Now we’re going to add the basic math operators. The player will shoot these, along with some numbers, for a special bonus. Step 1 – Add Oper Sprite. Step 2 – Add Behavior to playerShot Sprite. Step 3 – Build and Run.
83
VIDEO GAME PROGRAMMING STEP 1: Add Oper Sprite Insert a copy of the number sprite and name it oper. We can’t name it operator because that’s a C++ Keyword (like ‘if’, ‘while’, etc) Change the Actor to OPERATOR.
84
VIDEO GAME PROGRAMMING STEP 2: Add Behavior to playerShot Sprite Add the SpriteDeleteOperatorOnCollision FN function the the playerShot sprite. Open up this function, time to learn MORE CODE!
85
VIDEO GAME PROGRAMMING CONCEPT – Sprite Pointers Sprite Pointers (or SpritePTR in FUN) are how we uniquely identify different sprites of the same type. We can use Sprite Pointers to access data specific to one sprite. In the SpriteDeleteOperatorOnCollisionFN function, we use SpritePTR to access an oper sprite’s Delete Flag when we shoot it.
86
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should have numbers and operators falling from the sky now.
87
VIDEO GAME PROGRAMMING PART 13 – New Particle System Objective: –If you noticed in the SpriteDeleteOperatorOnCollisionFN function, it tried to use a ExplodeYellow Particle System. Let’s add that. Step 1 – Create a New Particle System. Step 2 – Change its Properties. Step 3 – Build and Run.
88
VIDEO GAME PROGRAMMING STEP 1: Create a New Particle System Insert a Copy of our ExplodeRed particle system and name it ExplodeYellow.
89
VIDEO GAME PROGRAMMING STEP 2: Change its Properties Open the ExplodeYellow particle system. Change: This-> Color(RGB(255,0,0),RGB(200,200,100)); To: This-> Color(RGB(255,255,0),RGB(200,200,100));
90
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. Now try shooting some operators. Do they explode?
91
VIDEO GAME PROGRAMMING PART 14 – Math Expression Objective: –Add text to display which numbers and operators have been shot and what they must equal. Step 1 – Add the Symbol Sprite. Step 2 – Add the Equal Sprite. Step 3 – Add Text. Step 4 – Build and Run.
92
VIDEO GAME PROGRAMMING STEP 1: Add the Symbol Sprite Add a new Sprite to level1 and set: 1.Name: symbol 2.Display List: 1 3.Map: main 4.Actor: SYMBOL 5.Initial Animation: ADD 6.Position: x = 270, y = 500
93
VIDEO GAME PROGRAMMING STEP 1: Add the Symbol Sprite continued… Add the SymbolUpdateFN behavior to the symbol sprite. Open this function.
94
VIDEO GAME PROGRAMMING CONCEPT – Setting Animation In the SymbolUpdateFN you should see a piece of code that looks like this: This->Animation(Operator);
95
VIDEO GAME PROGRAMMING CONCEPT – Setting Animation continued… This piece of code is how you change a sprite’s current animation set. Build and Run your game real quick to see this in action. As you shoot operators, the symbol animation changes.
96
VIDEO GAME PROGRAMMING STEP 2: Add the Equal Sprite Insert a copy of the symbol sprite and name it equal. Set the following: 1.ACTOR: symbol 2.Initial Animation: NOTEQUAL 3.Position: x= 400, y= 500 4.Behavior: Remove the SymbolUpdateFN function.
97
VIDEO GAME PROGRAMMING STEP 3: Add Text Add a new Text Object to level1. Set the following: 1.Name: LeftNumber 2.Type: Number 3.Font Size: 72 4.Font Color: Red 5.Initial Value: 0
98
VIDEO GAME PROGRAMMING STEP 3: Add Text continued… 6.Position: Left: 210 Top: 480 Right: 270 Bottom: 600
99
VIDEO GAME PROGRAMMING STEP 3: Add Text continued… Insert a copy of LeftNumber and name it RightNumber. Change the following properties: 1.Font Color: Blue 2.Position: Left: 340 Top: 480 Right: 400 Bottom: 600
100
VIDEO GAME PROGRAMMING STEP 3: Add Text continued… Insert a copy of RightNumber and name it AnswerNumber. Change the following properties: 1.Font Color: Yellow 2.Position: Left: 470 Top: 480 Right: 580 Bottom: 600
101
VIDEO GAME PROGRAMMING STEP 4: Build and Run Build and Run your game. You should now have some math text at the bottom of your screen. If not, let us know.
102
VIDEO GAME PROGRAMMING PART 15 – Secondary Fire Objective: –Add a secondary fire mode the player can use to select the second number. Step 1 – Add the playerShot2 Sprite. Step 2 – Add a New Particle System. Step 3 – Build and Run.
103
VIDEO GAME PROGRAMMING STEP 1: Add the playerShot2 Sprite Insert a copy of the playerShot sprite and name it playerShot2. Use Insert After: playerShot… Change the Initial Animation to TWO.
104
VIDEO GAME PROGRAMMING STEP 2: Add a New Particle System Insert a copy of the ExplodeRed particle system and name it ExplodeBlue. Change: This->Color(RGB(255,0,0),RGB(200,200,100)); To: This->Color(RGB(0,0,255),RGB(200,200,100));
105
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should be able to shoot your secondary weapon using the right key. Try shooting some numbers with your secondary shot.
106
VIDEO GAME PROGRAMMING PART 16 – Tie Everything Together Objective: –Now we’re going to make it so the math on the screen actually does something. Step 1 – Add Level Behavior. Step 2 – Adjust Text Objects. Step 3 – Build and Run.
107
VIDEO GAME PROGRAMMING STEP 1: Add Level Behavior Add the LevelMathFN function to level1.
108
VIDEO GAME PROGRAMMING STEP 2: Adjust Text Objects Open the Properties for the RightNumber text object. Uncheck the Visible box. Do the same for the LeftNumber text object.
109
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. Shoot a combination of numbers and operators using both your primary and secondary shot. Try to come up with the number that gives you the right answer.
110
VIDEO GAME PROGRAMMING PART 17 – Add Scoring Objective: –When the player shoots something or gets the right math answer, increase their score. Step 1 – Add Score Text. Step 2 – Add Score Number. Step 3 – Build and Run.
111
VIDEO GAME PROGRAMMING STEP 1: Add Score Text Add a new Text Object to level1. Set the following properties: 1.Name: ScoreText 2.Type: Text 3.Color: Red 4.Initial Value: Score
112
VIDEO GAME PROGRAMMING STEP 1: Add Score Text continued… 5.Position: Left: 0 Top: 520 Right: 70 Bottom: 550
113
VIDEO GAME PROGRAMMING STEP 2: Add Score Number Add a new Text Object to level1. Set the following properties: 1.Name: ScoreNumber 2.Type: Number 3.Color: Red 4.Font Size: 26 5.Initial Value: 0
114
VIDEO GAME PROGRAMMING STEP 2: Add Score Number continued… 6.Position: Left: 0 Top: 550 Right: 200 Bottom: 600 7.Behavior: TextScoreUpdateFN
115
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should see your score go up every time you get the right answer.
116
VIDEO GAME PROGRAMMING PART 18 – Multiplayer Objective: –Now we’re going to add a 2 player mode. Step 1 – Add More and Less Sprites to Title level. Step 2 – Add Player Number and Text to Title Level. Step 3 – Build and Run.
117
VIDEO GAME PROGRAMMING STEP 1: Add More and Less Sprites to Title Level In the title level, insert a copy of the quit sprite and name it more. Set these properties for more: 1.Actor: BUTTON_MORE 2.Initial Animation: NORMAL 3.Behavior: Remove ButtonQuitFN and ADD ButtonMorePlayersFN. 4.Position: x= 0, y= 0
118
VIDEO GAME PROGRAMMING STEP 1: Add More and Less Sprites to Title Level continued… Insert a copy of more and name it less. Change these properties for less: 1.Actor: BUTTON_LESS 2.Initial Animation: NORMAL 3.Behavior: Remove ButtonMorePlayersFN and ADD ButtonLessPlayersFN
119
VIDEO GAME PROGRAMMING STEP 2: Add Player Number and Text to Title Level Add a new text object to title. Set the following properties: 1.Name: PlayersText 2.Type: Text 3.Font Size: 20 4.Color: Anything 5.Initial Value: Players
120
VIDEO GAME PROGRAMMING STEP 2: Add Player Number and Text to Title Level continued… 6.Position: Left: 0 Top: 0 Right: 100 Bottom: 50
121
VIDEO GAME PROGRAMMING STEP 2: Add Player Number and Text to Title Level continued… Add a new text object to title. Set the following properties: 1.Name: PlayersNumber 2.Type: Number 3.Font Size: 20 4.Color: Anything 5.Initial Value: 1 6.Behavior: TextNumPlayersFN
122
VIDEO GAME PROGRAMMING STEP 2: Add Player Number and Text to Title Level continued… 7.Position: Left: 0 Top: 0 Right: 40 Bottom: 50 Now use the Level Preview to place the new sprites and text.
123
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should be able to select 1 or 2 players at the title screen.
124
VIDEO GAME PROGRAMMING PART 19 – Add Player 2 Objective: –Now we’re going to add the second player. They can use the key to shoot. The second player will shoot the second number in our math equation. Step 1 – Add player2 Sprite to level1. Step 2 – Build and Run.
125
VIDEO GAME PROGRAMMING STEP 1: Add player2 Sprite to level1 In level1, insert a copy of the player1 sprite and name it player2. Set properties for player2 sprite: 1.Unused: Check this 2.Initial Animation: TWO 3.Position: Use to set manually
126
VIDEO GAME PROGRAMMING STEP 1: Add player2 Sprite to level1 continued… 4.Behavior: Remove KeyboardWASDMovementFN and KeyboardShootFN. ADD KeyboardArrowMovementFN and KeyboardShoot2FN.
127
VIDEO GAME PROGRAMMING STEP 2: Build and Run Build and Run your game. You should now be able to play a 2 player game! Player 2 uses the arrow keys to move and to shoot.
128
VIDEO GAME PROGRAMMING PART 20 – Enemies Part 1 Objective: –Add enemies with their own projectiles, movement patterns, and particle explosions. Step 1 – Create Enemy and Enemy Projectile Art. Step 2 – Add Enemy and Enemy Shot Actors. Step 3 – Add Enemy and Enemy Shot Sprites. Step 4 – Build and Run.
129
VIDEO GAME PROGRAMMING STEP 1: Create Enemy and Enemy Projectile Art In MS Paint create 2 images: 1.enemy.bmp (60x60) 2.enemyShot.bmp (16x16) 3.Save them both in the Actors folder.
130
VIDEO GAME PROGRAMMING STEP 2: Add Enemy and EnemyShot Actors Create 2 new Actors: 1.ENEMY 1.New Animation Set: DEFAULT 2.Uses enemy.bmp 3.Give it collision data.
131
VIDEO GAME PROGRAMMING STEP 2: Add Enemy and EnemyShot Actors continued… 2.ENEMY 1.New Animation Set: DEFAULT 2.Uses enemyShot.bmp 3.Give it collision data.
132
VIDEO GAME PROGRAMMING STEP 3: Add Enemy and EnemyShot Sprites Add a new Sprite in level1 and set the following properties: 1.Name: enemy 2.Map: main 3.Unused: checked 4.Display List: 1 5.Local Data: ShotData
133
VIDEO GAME PROGRAMMING STEP 3: Add Enemy and EnemyShot Sprites continued… 6.Actor: ENEMY 7.Initial Animation: DEFAULT 8.Behavior: SpriteDeleteBelowViewportFN, EnemyShootFN, SpriteDecreasePlayerHealthFN 9.Collision: Precise, Activate, Check With Sprites, Ghost Collision
134
VIDEO GAME PROGRAMMING STEP 3: Add Enemy and EnemyShot Sprites continued… 10.Speed: 4 11.Vector Direction: Y = 1
135
VIDEO GAME PROGRAMMING STEP 3: Add Enemy and EnemyShot Sprites continued… Insert a copy of playerShot named enemyShot and set the following properties: 1.Display List: 1 2.Actor: ENEMYSHOT 3.Initial Animation: DEFAULT
136
VIDEO GAME PROGRAMMING STEP 3: Add Enemy and EnemyShot Sprites continued… 4.Behavior: REMOVE SpriteDeleteNumberOnCollision FN and SpriteDeleteOperatorOnCollisio nFN. ADD SpriteDecreasePlayerHealthFN.
137
VIDEO GAME PROGRAMMING STEP 4: Build and Run Build and Run your game. What happens? Why?
138
VIDEO GAME PROGRAMMING PART 20 – Enemies Part 2 Objective: –Now that we have actors and sprites, let’s add some behavior to make everything work. Step 1 – Add Spawn Behavior to level1. Step 2 – Add Behavior to Sprites. Step 3 – Add a New Particle System. Step 4 – Build and Run.
139
VIDEO GAME PROGRAMMING STEP 1: Add Spawn Behavior to level1 Add the LevelEnemySpawnFN function to level1.
140
VIDEO GAME PROGRAMMING STEP 2: Add Behavior to Sprites Add the SpriteDeleteEnemyOnCollisionF N function to the following sprites: 1.playerShot 2.playerShot2 3.player1 4.player2
141
VIDEO GAME PROGRAMMING STEP 3: Add a New Particle System Insert a copy of the ExplodeRed particle system and name it ExplodeEnemy. Go ahead and change the properties of this one to whatever you want.
142
VIDEO GAME PROGRAMMING STEP 4: Build and Run Build and Run your game. You should be able to shoot your enemies as they fall. You should also be able to run into them and destroy them.
143
VIDEO GAME PROGRAMMING PART 21 – Enemy Movement Objective: –Add a simple movement pattern to enemies. Step 1 – Create a new Movement Pattern. Step 2 – Add it to the enemy Sprite. Step 3 – Build and Run.
144
VIDEO GAME PROGRAMMING STEP 1: Create a new Movement Pattern Create a new Movement Pattern. Name it EnemyMP. Use the Free Track tool.
145
VIDEO GAME PROGRAMMING STEP 2: Add it to the enemy Sprite Open the properties for the enemy sprite. Check Movement Pattern and use EnemyMP. Check both the Initially Started and Loop boxes.
146
VIDEO GAME PROGRAMMING STEP 3: Build and Run Now Build and Run your game. The enemies should be following the new movement pattern. Change it around until you’re happy.
147
VIDEO GAME PROGRAMMING PART 22 – Health Objective: –Add player health to the game. Step 1 – Add Health Text. Step 2 – Add Health Numbers. Step 3 – Build and Run.
148
VIDEO GAME PROGRAMMING STEP 1: Add Health Text Add a new Text Object to level1 and set the following properties: 1.Name: HealthText 2.Type: Text 3.Color: Yellow 4.Initial Value: Health
149
VIDEO GAME PROGRAMMING STEP 1: Add Health Text continued… 5.Position: Left: 700 Top: 520 Right: 800 Bottom: 600
150
VIDEO GAME PROGRAMMING STEP 2: Add Health Numbers Add a new Text Object to level1 and set the following properties: 1.Name: HealthNumber1 2.Type: Number 3.Font Size: 28 4.Color: Red 5.Initial Value: 3
151
VIDEO GAME PROGRAMMING STEP 2: Add Health Numbers continued… 5.Position: Left: 710 Top: 550 Right: 750 Bottom: 600 6.Behavior: TextPlayer1HealthFN
152
VIDEO GAME PROGRAMMING STEP 2: Add Health Numbers continued… Insert a copy of HealthNumber1 and set the following properties: 1.Name: HealthNumber2 2.Color: Blue 3.Unused: check this
153
VIDEO GAME PROGRAMMING STEP 2: Add Health Numbers continued… 4.Position: Left: 750 Top: 550 Right: 800 Bottom: 600 5.Behavior: REMOVE TextPlayer1HealthFN. ADD TextPlayer2HealthFN.
154
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should be able to get hit by the enemies and have your health decreased (same goes for player2). Also, running into enemies should lower your health.
155
VIDEO GAME PROGRAMMING PART 23 – Victory Screen Objective: –Add a victory screen that prompts the player to play again. Step 1 – Make Ending Screen Art. Step 2 – Add Map to Victory Level. Step 3 – Copy Sprites to Victory Level. Step 4 – Build and Run.
156
VIDEO GAME PROGRAMMING STEP 1: Make Ending Screen Art In MS Paint, create 2 images: 1.victory.bmp (800x600) 2.gameover.bmp (800x600) 3.Save them both in your Maps folder.
157
VIDEO GAME PROGRAMMING STEP 2: Add Map to Victory Level Add a new Map to the victory level. 1.Map Name: main 2.File Name: victory.bmp
158
VIDEO GAME PROGRAMMING STEP 3: Copy Sprites to Victory Level You can copy sprites from one level to another by holding and dragging a sprite from one level to another. Drag these sprites from title into victory: 1.Cursor 2.Start 3.Quit
159
VIDEO GAME PROGRAMMING STEP 3: Copy Sprites to Victory Level continued… Open the properties for the start sprite in the victory level. Change these properties: 1.Name: play 2.Actor: BUTTON_PLAY 3.Initial Animation: NORMAL 4.Behavior: REMOVE ButtonStartFN and ADD ButtonPlayAgainFN.
160
VIDEO GAME PROGRAMMING STEP 3: Copy Sprites to Victory Level continued… Go into the victory level preview and place the new sprites wherever you want them.
161
VIDEO GAME PROGRAMMING STEP 4: Build and Run Now Build and Run your game. Try and win if you can!
162
VIDEO GAME PROGRAMMING PART 24 – Game Over Screen Objective: –Add a game over screen that prompts the player to play again. Step 1 – Add Game Over Level. Step 2 – Set Level Properties. Step 3 – Build and Run.
163
VIDEO GAME PROGRAMMING STEP 1: Add Game Over Level Insert a copy of the victory level and name it gameover. In the gameover level, open the properties for the main map. Change the File Name to gameover.bmp Go into the Level Preview and place things where you want them.
164
VIDEO GAME PROGRAMMING STEP 3: Build and Run Build and Run your game. You should have: 1.2 Player Mode 2.Enemies that shoot 3.Numbers 4.Mad math stuff 5.Ending Screens
165
VIDEO GAME PROGRAMMING CONGRADULATIONS! You’ve just finished Number Attack If you want to add more levels, insert a copy of level1 only make sure you select Insert After level1!!! If you don’t, things will break.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.