Unformatted text preview:

Slide 1AnnouncementsKenny Spade: Imagine CupUpcoming Project DeliverableGame InputDigital vs Analog ControlsInput Type OverviewXbox 360 Controller InputGamePad ClassC# StructsGamePadState StructGamePadButtons Struct (Buttons)GameDPad Struct (DPad)GamePadThumbsticks Struct (Thumbsticks)Joystick Dead ZoneGamePadTriggers Struct (Triggers)Controller VibrationKeyboard InputMouse InputWrapper ClassReadingProcedural programming paradigmObject-oriented programming paradigmWays Procedural Designs are Expressed in C#Bad Code SmellsCode Smells: Duplicated CodeCode smells: Long MethodCode smells: Feature EnvyCode smells: Large classCode smells: switch statementsCode smells: Data classHomeworkComputer Science – Game DesignUC Santa CruzCMPS 20: Game Design ExperienceImagine CupTeam FormationXNA InputJanuary 14, 2010Arnav JhalaAdapted from Jim Whitehead’s slidesComputer Science – Game DesignUC Santa CruzAnnouncements•Team Formation (Details are on the website)–Team member names and bio–Contact Information–Means of communication–Location of meetings•Once teams are formed I will randomly assign more members in teams of <4 students (combine two 2 person teams)•This information must be submitted, typewritten, on a piece of paper. After submission of this assignment, each team member will be expected to know this information, so you should take this opportunity to add phone numbers to cell phones, email addresses to email applications, etc.•Details of sections are now on the webpage•Link to Moodle class page is now on the main class homepage•Email TA David Seagal or me for Moodle related issuesComputer Science – Game DesignUC Santa CruzKenny Spade: Imagine CupComputer Science – Game DesignUC Santa CruzUpcoming Project Deliverable•Game Concept Document–A compelling document that sells your game concept–Title page•Title of game, name of group, name of team members, sample artwork–Overview page•Table at top: game genre, platform (PC/XBox), team size•Key points section–Bulleted list of important elements of gameplay–Goal of game, what makes game unique, main characters, main fictional elements–Sample artwork image to give feel of the game–Biographies•True, pocket biographies of each team member (1-2 paragraphs each) stressing experience that makes you a strong game designer–1-3 pages giving a textual description of the game•Fictional background, brief description of characters, goal of player in game, how does player interact with the game, brief description of levels, game audience, other important elements as needed.–1-2 pages of sample conceptual artwork•Hand-drawn sketches are fine•See template and evaluation criteria on course websiteComputer Science – Game DesignUC Santa CruzGame Input•XNA Framework supports three input sources–Xbox 360 controller•Wired controller under Windows•Wireless or wired for Xbox 360•Up to 4 at a time–Keyboard•Good default for Windows games•Xbox 360 also supports USB keyboards–Mouse•Windows only (no Xbox 360 support)•Poll for input–Every clock tick, check the state of your input devices–Generally works OK for 1/60th second ticksComputer Science – Game DesignUC Santa CruzDigital vs Analog Controls•Input devices have two types of controls•Digital–Reports only two states: on or of–Keyboard: keys–Controller A, B, X, Y, Back, Start, D-Pad•Analog–Report a range of values–XBox 360 controller: -1.0f to 1.0f–Mouse: mouse cursor values (in pixels)Computer Science – Game DesignUC Santa CruzInput Type OverviewInput DeviceDigital ButtonsAnalog ControlsVibration Win? Xbox? NumberXbox 360Controller14 4 Yes Yes (wired or wireless with adapter)Yes (wireless or wired)4Keyboard >100 0 No Yes Yes 1Mouse 5 3 No Yes No 1Computer Science – Game DesignUC Santa CruzXbox 360 Controller Input•Every clock tick–Get state of controller•Call GetState() on GamePad class•Pass in PlayerIndex–PlayerIndex.One, PlayerIndex.Two, …–Corresponds to lit region in “ring of light”•Returns a GamePadState structure–Check if controller is connected•IsConnected boolean in GamePadState–Check GamePadState for current state of digital and analog inputs–Recall that update() is called every clock tick•Get input in update(), or a method called from itComputer Science – Game DesignUC Santa CruzGamePad Class•A static class–Do not need to create an instance to use–All methods are static•GetState–Retrieve current state of all inputs on one controller•SetVibration–Use to make controller vibrate•GetCapabilities–Determine which input types are supported. –Can check for voice support, and whether controller is connected.public static class GamePad{ public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex); public static GamePadState GetState(PlayerIndex playerIndex); public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode); public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor);}Computer Science – Game DesignUC Santa CruzC# Structs•A struct in C# is a lightweight alternative to a class•Similar to class–Can have constructors, properties, methods, fields, operators, nested types, indexers•Different from class–Struct does not support inheritance, or destructors–Is a value type (classes are reference types)•Rule of thumb:–Use structs for types that are small, simple, similar in behavior to built-in typesComputer Science – Game DesignUC Santa CruzGamePadState Struct•Properties for reading state of the GamePad–Digital Input: Buttons, DPad–Analog Input: ThumbSticks, Triggers–Check connection state: IsConneced–PacketNumber•Number increases when gamepad state changes•Use to check if player has changed gamepad state since last tickpublic struct GamePadState{ public static bool operator !=(GamePadState left, GamePadState right); public static bool operator ==(GamePadState left, GamePadState right); public GamePadButtons Buttons { get; } public GamePadDPad DPad { get; } public bool IsConnected { get; } public int PacketNumber { get; } public GamePadThumbSticks Th umbSticks { get; } public GamePadTriggers Triggers { get; }}Computer Science – Game DesignUC Santa CruzGamePadButtons Struct (Buttons)•Properties for retrieving current button state–A, B, X, Y–Start, Back–LeftStick, RightStick•When you press straight down on each


View Full Document

UCSC CMPS 20 - Lecture Notes

Documents in this Course
Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?