310 likes | 509 Views
CS 179.14 PC/Console Game Programming/development. Chapter 2: Drawing, Data and controls. Table of Contents. Final Project Guidelines XNA Programming: - Data Storage - Basic Graphics - Player Input Game Design Notes: Game Genres (Expanded). Final Project guidelines. Breaking it down.
E N D
CS 179.14 PC/Console Game Programming/development Chapter 2: Drawing, Data and controls
Table of Contents • Final Project Guidelines • XNA Programming: • - Data Storage • - Basic Graphics • - Player Input • Game Design Notes: Game Genres (Expanded)
Final Project guidelines Breaking it down
Programming Project • This programming project is targeted for CS Major Student groups • Create a game that consists of the following requirements: • a.) Genre: Any Genre will fit • b.) Game Length: Trial Length (10-20 minutes long / 1 – 2 stages) and will automatically show top score, and go back to main title • c.) Graphics: 2D or 3D (no bonus points for high level 3D) • d.) Sound: No profanities or anything similar • e.) Content: Basic story, not epic. A kid – adult game.
Programming Project • Grade Breakdown: • Graphics: 30% • Sound: 10% • Story / Content: 40% • Controls / Ease of use: 20% • Total 100% (or A)
Game Design Project • This project is targeted for non CS Major groups • The premise of this project is to have the groups create a game concept from the ground up until marketing the game, without having programming the game. • The game will need to have the following elements: • a.) Game Concept: Genre and Theme and Elements • b.) Character/s - background of the character and their designs • c.) Game Story – Major events of the game in detail • d.) Availability – which platform will it be? • e.) Marketing – Market the created Design and Concept of the Game.
Game Design Project • Grade Breakdown: • Game Concept: 20% • Character Design: 15% • Game’s Story: 25% • Marketing: 20% • Appeal: 20% • Total: 100% (or A)
XNA Programming Drawing,Data and Controls
Drawing objects in XNA • In this section, we will learn more about the creation of drawings in XNA, how data is saved • We will create a sample program called MoodLight to simulate the various drawing or coloring the application can do. • It will for now, be without controls and will change colors using combinations of if statements.
Drawing in XNA • Basic Programing Diagram:
Drawing in XNA • To begin programming, we open up our previous sample file we’ve created. Else, we open up a new Project and save it as MoodLight. • We open up the file called Game1.cs • Look at the following method: Protected override void Draw(GameTimegameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); //TODO: Add your drawing code here base.Draw(gameTime); }
Drawing in XNA • The method contains instructions to draw something on the screen. • GraphicsDevice.Clear(Color.CornflowerBlue); • This method implies to clear the screen of the device with the color called CornflowerBlue. The method Clear (it’s already a premade method like Draw without the need to change the code) is one of the built in methods belonging in the XNA Framework. We can change it to another color if we want it to. • We will modify this method to provide our own color. We will be declaring variables to set the new color. backgroundColor; Color
Drawing in xna • Assigning a color value to the variable backgroundColor: • We now replace the previous value in the Clear method with backgroundColor. • GraphicsDevice.Clear(backgroundColor); new Color (0,0,0); backgroundColor =
Drawing in XNA • The resulting updated method will now have: Protected override void Draw(GameTimegameTime) { Color backgroundColor; backgroundColor = New Color (0,0,0); GraphicsDevice.Clear(backgroundColor); base.Draw(gameTime); }
Drawing in XNA • The behavior of the graphic depends on the update method being run. • We will now manipulate the colors using conditions inside the Update method of the code. Later in the next part, manual controls shall be used to update the colors. • Firstly, we will need to create several variables for the colors Red, Green and Blue. They are named redIntensity, greenIntensity, and blueIntensity. They are declared as type byte (smallest unit of memory used in a game). • We will use byte as it saves up on memory, especially in this case that we might end up creating a game for XBOX or even a phone or Zune device which has very limited memory (512MB for XBOX). // The Game World - our color values byte redIntensity; byte greenIntensity; byte blueIntensity;
Drawing in XNA • In order to make the colors change, we will have to add in logic that will make the values change. • We will be using IF statements to control the change when we update the colors. • The simple diagram above shows the basic IF statement that if the redCountingUP value is still counting up (TRUE) then the value of redIntensity is increased by 1. statement condition If ( redCountingUP ) redIntensity++;
Drawing in Xna • However, there are cases where we may need to do an alternative step if the statement is false. statement condition Statement done if false If ( redCountingUP ) redIntensity++ else redIntensity--;
Drawing XNA • Open the folder 04 MoodLight in the samples folder of XNA development to see the final product. • Another variation is found in 05 MoodLightfolder, which has a different behavior in changing lights.
controls in xna • In video games, there are several ways to control it. • a.) Joysticks • b.) Control Pads • c.) Keyboard and Mouse • d.) Touch • e.) Motion
Controls in XNA • To make games work in XNA, we need to understand the basic control statement when coding • We use the GamePad class to reference our controls to a game pad. We use the method GetState to read the state of our game pad. Here’s an example GamePadState Buttons Green A ButtonState.Pressed Red B ButtonState.Released Blue X ButtonState.Released Yellow Y ButtonState.Released Start ButtonState.Released Back ButtonState.Released
Controls in XNA • To read a specific gamepad, we implement this line inside the game code: GamepadState pad1 = GamePad . GetState ( PlayerIndex.One ); GamepadState called pad1 GamePad class that looks after gamepads GamePad being read Method that gets the state of a gamepad
Controls in XNA • We can test out the controls in XNA by modifying the previous exercise (MoodLight) code to allow controls. Value we’re looking for Statement done if true Button pressed If ( pad1.Buttons.B == ButtonState.Pressed ) redIntensity++ ;
Controls in XNA • We modify the Moodlight code with the following: • We also modify the MoodLight code to remove the previous exercise of automating the color change Protected override void Update(GameTimegameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); GamePadState pad1 = GamePad.GetState(PlayerIndex.One); if(pad1.Buttons.B == ButtonState.Pressed) redIntensity++; if(pad1.Buttons.X == ButtonState.Pressed) blueIntensity++; if(pad1.Buttons.A == ButtonState.Pressed) greenIntensity++; base.Update(gameTime); }
Controls in XNA • To find out more on Game Controller Input. Get this file from: • http://create.msdn.com/en-US/education/catalog/utility/input_reporter
Game design notes Game genres
Game Genres • Action / Adventure Games • Objective: to get to the other side of the map, exploration, earn treasure/points, use tools to defeat enemies • Graphics: early years are in 2D, current generation of games moving into open world (3D). • Early sample of action/adventure games: Pitfall! • Notable existing works: Super Mario, Sonic the Hedgehog, Prince of Persia, Megaman, Metroid, Assassins Creed, Metal Gear, Grand Theft Auto, Devil May Cry, Resident Evil
Game Genres • Rhythm Games • Objective: Time the button presses correctly to stay in rhythm and earn more points. Try to perfect a round without missing a beat/step • Graphics: 3D or 2D • Music: Driven by either Japanese pop music, Pop Music, Rock Music • Early sample of Rhythm Games: Pa Rappa the Rapper, Beatmania • Notable Existing Works: Dance Dance Revolution, Guitar Hero, Rockband, Guitar Mania, Drum Mania
Game Genres • Real Time Strategy Games • Objective: Beat your enemy/enemies by building structures, training units and gathering resources • Graphics: 2D Grid or 3D 2/3 Isometric View • Early Sample: Dune I and Dune II • Notable Existing works: StarCraft series, Command and Conquer series, Age of Empire Series, Company of Heroes series, Sins of a Solar Empire, Star Control series
Game Genres • Racing Games • Objective: earn the highest score until time runs out / beat all opponents to the finish line / earn the highest points in drifting / get to the finish line before time runs out / get the fastest time in a race / Out Drag everyone • Graphics: Overhead 2D, Rearview 2D, 3D (various angles) • Early Sample: Pole Position, Out Run, Road Blasters • Notable Existing works: Need for Speed, Gran Turismo, Grid, F1, Midnight Club, GTR, Burnout, Auto Modellista
Game Genres • Shooting Games • Objective: Shoot down as many ships as possible and beat the final boss. Earn the most number of points in a game. • Graphics: 2D overhead, sideways, front facing, 3D first person, third person • Early Samples: Battle City, Wolfenstein , SpaceWar, Space Invaders, Macross, Operation Wolf • Notable Existing Works: Ace Combat, Gears of War, Counter Strike, Medal of Honor, Call of Duty, Halo, Unreal Tournament, Time Crisis, Rainbow Six, Ghost Recon, ARMA, Bioshock
Game Genres • Role Playing Games • Objective: Be the strongest possible to beat the final boss, save the world and get the girl • Graphics: 2D side scrolling, overhead, isometric / 3D • Early Samples: Dungeons and Dragons, Phantasy Star, Final Fantasy • Notable Existing works: Final Fantasy, Xenogears, Fallout, Kingdom Hearts, Suikoden, Fable, Dragon Age, Diablo