Games at Bolton Joysticks Andrew Williams

Slides:



Advertisements
Similar presentations
Microsoft ® Word 2010 Training Create your first Word document II.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Game Programming Patterns Game Loop
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
Customizing Reports. Custom Reports A report is a formatted hardcopy of the contents of one or more tables from a database. Although you can format and.
3.3. G AME I NPUT Handling input within games. In lecture exploration of answers to frequently asked student questions.
Copyright © 2002 Bolton Institute Joysticks Andrew Williams
Copyright © 2002 Bolton Institute The AWSprite Library Andrew Williams
Games at Bolton Games Hardware, Architecture and Peripherals Andrew Williams
Games at Bolton Simple Directmedia Layer Andrew Williams
Copyright © 2002 Bolton Institute Simple Directmedia Layer (SDL) Andrew Williams
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Binary Arithmetic Math For Computers.
Testbed: Exercises.
Using Coordinate Geometry to Create Moving Images In unit 29 we created a simple drawing for the background of a children’s game. We are going to start.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Programming Concepts Part B Ping Hsu. Functions A function is a way to organize the program so that: – frequently used sets of instructions or – a set.
GIRLS Robotic Camp. Let’s Begin Meet and Greet – Camp leaders introduce themselves – Students introduce themselves.
Where procedures are important, and learning is fun.
Getting Started with. EndNote Basic: It allows you to: Collect references from online sources or enter them manually Access your references from any computer.
HCI Meeting 3 Thursday, September 2. Class Poll What does the word interface mean in the context of HCI and user-system interface design? What verb should.
More switches, Comparison Day 7 Computer Programming through Robotics CPST 410 Summer 2009.
MOVEMENT TRACKING SYSTEM (MTS) TURN ON THE SYSTEM & LOG INTO THE CONTROL STATION INSTRUCTOR:
How do I use data to plan for learning? Module 6.
Logic Gates It’s Only Logical. Logic Gates Are the switches that computers and similar devices use. They hold their state until something changes. Are.
Basic Components Electronics Batteries & Cells Chemical devices that provide DC voltage A cell is an electrochemical device made of 2 electrodes.
COMPUTER PROGRAMMING II SUMMER 2011 Visual Basic to C#
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
Possible Improvements For Modular Relative Time Petri Nets (or: rooting for the underdog)
Basic Systems and Software. Were we left off Computers are programmable (formal) machines. Digital information is stored as a series of two states (1.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Haptic & Direct User Input with DirectInput ® 8 API Graphics Lab. Korea Univ.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
Game Programming Patterns Game Loop From the book by Robert Nystrom
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Nothing moves by itself. Why do things move and how do they move? Things only move when they are pushed or pulled. Something that pushes or pulls is called.
Before the photographer took these two photographs he had to decide which way up he’d hold the camera. Which photograph is a landscape view and which.
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
Computer Control and Monitoring Today we will look at: What we mean by computer control Examples of computer control Sensors – analogue and digital Sampling.
By Joshua Shaw.  We have previously added a While Loop  We are now going to use it for programming the robot  We have also added two motor programs.
CS 134 Alternate Inputs.
SWITCHES Prepared by: Prof.M.P.Kothari.
Sound Music & Sound Effects.
Android Bluetooth Game Controllers
TYPICAL INPUT DEVICES By Dajia Forbes 1c.
Digital electronics and logic gates
Programming – Touch Sensors
And the text with form..
More Selections BIS1523 – Lecture 9.
While Loops and If-Else Structures
All very logical I think!
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
Selection CSCE 121 J. Michael Moore.
Game Controller Lesson Three.
How to Fix “Glitchy” Servo Code
Programming a Servo By Joshua Shaw.
Game Controller Lesson Two.
Test123 blah. hjghgghhg.
Creating your first website
HCI Human Computer Interface
÷ 5 = 29 How many 5s are there in 1? Great!
÷ 2 = 24 How many 2s are there in 4?
Creating your first website
Game Programming Algorithms and Techniques
In this task you will see different shapes.
How to allow the program to know when to stop a loop.
Buttons.
Presentation transcript:

Games at Bolton Joysticks Andrew Williams

Games at Bolton Reference  Joystick handling is covered in great detail here: –

Games at Bolton Digital vs Analogue  Digital –On or off –Buttons –The “Hat” (SDL)  Analog(ue) –Joysticks –A range of values ( to ) for SDL

Games at Bolton A PS2-Style Joypad Modern gamepads have both analogue and digital

Games at Bolton A PS2-Style Joypad “Hat”

Games at Bolton A PS2-Style Joypad 8-way Directional Control “Hat”

Games at Bolton A PS2-Style Joypad SDL treats it as digital “Hat”

Games at Bolton A PS2-Style Joypad Joysticks

Games at Bolton A PS2-Style Joypad SDL treats these as analogue Joysticks

Games at Bolton A PS2-Style Joypad Buttons

Games at Bolton A PS2-Style Joypad Buttons SDL treats these as digital

Games at Bolton A PS2-Style Joypad Buttons Don't forget the shoulder buttons

Games at Bolton Joysticks and SDL  Reference: –Joystick handling in SDL is covered in great detail here in the SDL documentation (see the GHAP webpage)

Games at Bolton Initializing SDL  This assumes only one joystick –SDL has functionality for discovering how many joysticks there are and what type they are, etc /* initialize SDL */ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK| SDL_INIT_TIMER); /* Open the Joystick */ SDL_Joystick *joystick; SDL_JoystickEventState(SDL_ENABLE); joystick = SDL_JoystickOpen(0);

Games at Bolton Joystick Event-Handling while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: /* handle keyboard stuff here */ break; case SDL_JOYAXISMOTION: /* handle joystick motion here * (see next slide) */ break; }

Games at Bolton /* handle joystick motion here */ case SDL_JOYAXISMOTION: /* handle joystick motion here */ if(SDL_JoystickGetAxis(joystick, 0) < -3200) { xMove = -2; } else if(SDL_JoystickGetAxis(joystick, 0) > +3200) { xMove = +2; } else { xMove = 0; } if(SDL_JoystickGetAxis(joystick, 1) < -3200) { yMove = -2; } else if(SDL_JoystickGetAxis(joystick, 1) > +3200) { yMove = +2; } else { yMove = 0; } break;

Games at Bolton Analogue  The example on the previous slide simply treats the joystick as a digital device: it is moved either to the left or the right  This is not really appropriate for an analogue device –To use it properly, we should reflect how far the joystick has been moved The further it has been moved, the faster the movement

Games at Bolton Analogue Joystick Motion case SDL_JOYAXISMOTION: /* handle joystick motion here */ if(SDL_JoystickGetAxis(joystick, 0) < ) { xMove = -8; } else if(SDL_JoystickGetAxis(joystick, 0) < ) { xMove = -4; } else if(SDL_JoystickGetAxis(joystick, 0) < -3200) { xMove = -2; } else if(SDL_JoystickGetAxis(joystick, 0) > ) { xMove = +8; } else if(SDL_JoystickGetAxis(joystick, 0) > ) { xMove = +4; } else if(SDL_JoystickGetAxis(joystick, 0) > +3200) { xMove = +2; } else { xMove = 0; } /* You'd need something similar for the y dimension */ break;

Games at Bolton Joystick Buttons case SDL_JOYBUTTONDOWN: /* Joystick Button Press */ if( event.jbutton.button == 0 ) { firingMachineGun = true; } if(event.jbutton.button == 1) { firingRockets = true; } break; case SDL_JOYBUTTONUP: /* Joystick Button Release */ if( event.jbutton.button == 0 ) { firingMachineGun = false; } if(event.jbutton.button == 1) { firingRockets = false; } break; Continued overleaf

Games at Bolton Joystick Buttons (continued)  You fire machine guns and/or rockets after the switch statement: switch(event.type) { /* blah blah * see previous slides * blah blah */ } if(firingMachineGuns) { /* handle machine gun firing */ } if(firingRockets) { /* handle rocket firing */ }