Gameprogrammeren: Menu’s in Penguin Pairs

Slides:



Advertisements
Similar presentations
Nov 2005 MSc Slide 1 - Another Example of a Structural Pattern Alternative way of adding Functionality to an existing class (alternative to a derived class)
Advertisements

Constructor and New Fields // Don't synch draw() with vertical retrace of monitor graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = true;
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Pre Check In - Auto Shipment = OFF final. We start making a PreCheckIn with pickup.
By Janet Holland & Barbara Higgins-Dover Adobe Photoshop Blended Image Tutorial.
 Next - Previous  Horizontal Bar  Vertical Menu.
Adobe Photoshop Elements 2.0 Creating A Button For Your Website.
Display 480x800 QVGA 320x480 HVGA Capacitive touch 4 or more contact points Camera 5 mega pixels or more Dedicated camera button Hardware buttons.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Object Oriented Design COSC 315 Fall 2014 Bridget M. Blodgett.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
11 Making a Sprite Session 4.2. Session Overview  Describe the principle of a game sprite, and see how to create a sprite in an XNA game  Learn more.
Adobe Photoshop Blended Image Tutorial Adobe Photoshop Tools Toolbar Tools Palette Windows Menu.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
Words. Characters and Strings Character –A single character inside of single quotes char letter = 'A' ; char digit = '0' ; – Strings Zero or more character.
Class Constructors class Student { private: string id, firstName, lastName; float gpa; public: Student() Student(string sID) Student(string first, string.
CONDITIONALS. Boolean values Boolean value is either true or false It is name after the British mathemetician, George Boole who first formulated Boolean.
private void Application_Launching(object sender, LaunchingEventArgs e) { } private void Application_Activated(object.
A: A: double “4” A: “34” 4.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
Midterm: Question 1 (35%) (30 minutes) Write an assembly program to draw a rectangle. – (5%) Show a message to ask for information of the rectangle – (5%)
Class Method Read class Student { private: string id; string firstName, lastName; float gpa; public: // Will the method change any data members? // Yes!
11 Using the Keyboard in XNA Session 9.1. Session Overview  Discover more detail on how the XNA keyboard is implemented  Find out how to use arrays.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
View - Commands. Is used to fit the entire project in the graphics window. Toolbar Button: Keyboard Shortcut: F2 Is used to fit the entire project in.
CHAPTER 5 Text XNA Game Studio 4.0. Objectives Discover how text is drawn using Microsoft XNA. Add some font resources to your XNA program. Draw some.
XNA 4.0 Side Scrolling.
Lecture 4 Using SpriteFonts
Spanish Checkpoint B Physical Adjectives Personality Adjectives
Sprite Sheets, Game States
Using and Creating Sprites
Gameprogrammeren: Klassen en objecten in Painter
Voorbeeld-programma's
Gameprogrammeren: Edit states
Physics Careers February1st, 2017
Implementing Polymorphism
CS 1430: Programming in C++.
Visual Basic Properties, Methods and Events
Review Operation Bingo
© המרכז להוראת המדעים האוניברסיטה העברית בירושלים
null, true, and false are also reserved.
Collision Detection.
Animated Sprites.
Side Scrolling Game Development.
Simple Windows Applications
Les Verbes ER LCHS NOW SHOWING Marquee with 3-D perspective rotation
How to Fix “Glitchy” Servo Code
CS 1430: Programming in C++.
Chapter 5, Conditionals Brief Notes
Pictures with reflection and blurred background (Basic)
WIZCHANNELS.COM Step 1. Stb emulator main menus on 1st startup.
Gameprogrammeren: Interactie in Penguin Pairs
Adobe Photoshop Elements 2.0
Pictures with reflection and blurred background (Basic)
Player preferences, Loading Scenes, Activating and Enabling
Getting Started with Milestone 2
Pictures with reflection and blurred background (Basic)
2 Timothy 1:2-5 Textured and layered background with title (Advanced)
Blended Image Tutorial
Gameprogrammeren: Game states
Pictures with reflection and blurred background (Basic)
ONE NIGHT ONLY! CJMS Talent Show Friday, December 11
Spell your name using word art from above
Picture with watercolor overlay background (Advanced)
Collisions with Static Objects
Presentation transcript:

Gameprogrammeren: Menu’s in Penguin Pairs Arjan Egges Paul Bergervoet Wouter van Toll

Overzicht

Menu’s Tekst Aan/uit knop Slider

TextGameObject class TextGameObject : GameObject { protected SpriteFont spriteFont; protected Color color; protected string text; public TextGameObject(string assetname, int layer = 0, string id = "") : base(layer, id) spriteFont = PenguinPairs.AssetManager.Content.Load<SpriteFont>(assetname); color = Color.White; } ...

TextGameObject public override void Draw(GameTime gameTime, SpriteBatch s) { if (visible) spriteBatch.DrawString(spriteFont, text, this.GlobalPosition, color); } public Color Color get { return color; } set { color = value; } public string Text get { return text; } set { text = value; }

Knoppen: muisklik detecteren Hoe weten we of op een knop geklikt wordt? Muisknop ingedrukt Muis is binnen de rechthoek die de knop omsluit BoundingBox property toevoegen aan SpriteGameObject: public override Rectangle BoundingBox { get int left = (int)(GlobalPosition.X - origin.X); int top = (int)(GlobalPosition.Y - origin.Y); return new Rectangle(left, top, Width, Height); }

Eenvoudige knop class Button : SpriteGameObject { protected bool pressed; public Button(string imageAsset, int layer = 0, string id = "") : base(imageAsset, layer, id) { } public override void HandleInput(InputHelper inputHelper) { pressed = inputHelper.MouseLeftButtonPressed() && BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y); } public bool Pressed { get { return pressed; } }

Aan/uit knop (toggle) class OnOffButton : SpriteGameObject { public OnOffButton(string imageAsset, int layer = 0, string id = "") : base(imageAsset, layer, id, 0) } public override void HandleInput(InputHelper inputHelper) if (inputHelper.MouseLeftButtonPressed() && BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y)) sheetIndex = (sheetIndex + 1) % 2; ...

Aan/uit knop (toggle) public bool On { get return sprite.SheetIndex == 1; } set if (value) sprite.SheetIndex = 1; else sprite.SheetIndex = 0;

Slider class Slider : GameObjectList { protected SpriteGameObject back, front; protected bool dragging; protected int leftmargin, rightmargin; public Slider(string sliderback, string sliderfront, int layer = 0, string id = "") : base(layer, id) } ...

Slider public Slider(string sliderback, string sliderfront, int layer = 0, string id = "") : base(layer, id) { leftmargin = 5; rightmargin = 7; back = new SpriteGameObject(sliderback, 0); this.Add(back); front = new SpriteGameObject(sliderfront, 1); front.Position = new Vector2(leftmargin, 8); this.Add(front); dragging = false; }

Slider public override void HandleInput(InputHelper inputHelper) { if (inputHelper.MouseLeftButtonDown()) { if (back.BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y) || dragging) float newxpos = MathHelper.Clamp(inputHelper.MousePosition.X - back.GlobalPosition.X - front.Width / 2, back.Position.X + leftmargin, back.Position.X + back.Width - front.Width - rightmargin); front.Position = new Vector2(newxpos, front.Position.Y); dragging = true; } else dragging = false;

Slider public float Value { get return (front.Position.X - back.Position.X - leftmargin) / (back.Width - leftmargin - rightmargin - front.Width); } set float newxpos = value * (back.Width - leftmargin - rightmargin – front.Width) + back.Position.X + leftmargin; front.Position = new Vector2(newxpos, front.Position.Y);