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.

Slides:



Advertisements
Similar presentations
2000 Prentice Hall, Inc. All rights reserved. 1 Outline 3.1Introduction 3.2Game Loop Components 3.3How to Implement in C# 3.4Adding Image to XNA Project.
Advertisements

Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Code Elements and Processing Coordinate System. Code elements: pages Comments: are documentation notes that are ignored by the computer but are.
Constructor and New Fields // Don't synch draw() with vertical retrace of monitor graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = true;
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
Translate, Rotate, Matrix Pages Function Function Definition Calling a function Parameters Return type and return statement.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
2D Graphics in XNA Game Studio Express (Modeling a Class in UML) Game Design Experience Professor Jim Whitehead February 5, 2008 Creative Commons Attribution.
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience January 14, 2010 Arnav Jhala.
AI & 2D Development COSC 315 Fall 2014 Bridget M. Blodgett.
CHAPTER 4 Images XNA Game Studio 4.0. Objectives Find out how the Content Manager lets you add pictures to Microsoft XNA games. Discover how pictures.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
Using Namepsaces  This section lists the namespaces that the application will be using frequently. Saves the programmer from specifying a fully qualified.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Developing the Game User Interface (UI) Lesson 5.
XNA Basic XACT tool. What’s format song file which XNA support? Only.wav because it’s not compress file. Beside, you need XACT project ( XACT project)
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
Review. Terms 6 x 6 Rule – States that each slide should have no more than six bulleted items with no more than 6 words on each bullet Contextual Spelling.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Introduction to XNA Graphics Programming Asst. Prof. Rujchai Ung-arunyawee COE, KKU.
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
Resizing Images CS 268. Where to start? Pictures (of course)  Need to down size them for the web.  Pictures taken with a 10 mega pixel camera are usually.
CHAPTER 10 Using C# Methods to Solve Problem XNA Game Studio 4.0.
1 Viewing & Projective Window Chapter 3. 2 D3D virtual viewpoint Definition: virtual viewpoint is like a camera that was positioned in some where and.
IReport Demo Spring 2008 OEDSA Conference. Report Properties.
11 Working with Images Session Session Overview  Find out more about image manipulation and scaling when drawing using XNA  Start to implement.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
Object Oriented Design COSC 315 Fall 2014 Bridget M. Blodgett.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
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.
Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
1 Original Source : and Problem and Problem Solving.ppt.
3D Models and Meshes Asst. Prof. Rujchai Ung-arunyawee COE, KKU.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
Project Two Adding Web Pages, Links, and Images Define and set a home page Add pages to a Web site Describe Dreamweaver's image accessibility features.
Microsoft® Small Basic Exploring Shapes Estimated time to complete this lesson: 1 hour.
Objective: Students will know the screen parts, tools, and menus of the Fireworks program. Students will be able to create a new document, create basic.
Week 8 - Friday.  What did we talk about last time?  Static methods.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
Playing with Sprites. XNA Game Lifecycle In the faceBall demo program we bounced a smiley face around the graphical display against a background image.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Computer Game Design and Development Collision Detection Havok Destruction.
XNA ● Proprietary Microsoft framework ● C#. Interface.
11 Adding a Bread Bat Session Session Overview  We have created a cheese sprite that bounces around the display  We now need to create a bread.
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.
LO: We’re learning to outline a program using Pseudo Code.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
2D drawing basics For CSE 3902 By: Matt Boggus. Overview 2D coordinate systems Raster images Sprite drawing in XNA.
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
2D Graphics CMT3311. This covers... How to make a transparent sprite How to add a sprite to your project and draw it Properties of sprites and how to.
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.
Week 2 - Monday CS361.
Using and Creating Sprites
2D drawing basics For CSE 3902 By: Matt Boggus.
Chapter 15, Images …a few points
Find the volume of the solid obtained by rotating the region bounded by {image} and {image} about the x-axis. 1. {image}
Disk vs. Shell Method AP Calculus.
Pictures with checkerboard shutter animation (Intermediate)
Player preferences, Loading Scenes, Activating and Enabling
Chapter 15, Images …a few points
2 Timothy 1:2-5 Textured and layered background with title (Advanced)
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
Animation Pages
TEXT FORMAT Textured and layered background with title - Advanced
Collisions with Static Objects
Presentation transcript:

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 for draw on another image. Usually, we’ll use.jpg for background and.png for object on background.

How to include image in project? Fist right click at content. Second choose add Exiting Item. Third choose your image.

Sample Code how to load into content manager. Texture2D exceed; protected override void LoadContent() { exceed = Content.Load (“exceed”); } Type File or folder name

How to assign position? There are two way to assign position. - Vector2 - Rectangle

Rectangle There are two type of Rectangle - DestinationRectangle - SourceRectangle Both type of Rectangle is a parameter in SpriteBatch.Draw() but isn’t a class. We’ll talk detail about DestinationRectangle but you can find more information about SourceRectangle in wiki

DestinationRectangle Rectangle DestinationRectangle = new Rectangle(0,0,300,400); The first two parameter is a x,y position. The second two parameter is size of picture. First of the second two parameter is a width. Second of the second two parameter is a height. Parameter type is int.

Vector2 Vector2 position = new Vector position(0,0); Parameter is a x,y position and parameter type is float.

Which one we should use for assign position? It’s up your design. Vector2 can give position in float that you can assign pass thumbnail stick. Rectangle can give position in int but can assign size of your picture.

Axis in XNA There are two axis in XNA. – One is a axis of display screen. – Two is a axis of picture. Axis of display screen is for assigning position of picture origin on screen. Axis of picture is for assign origin.

Axis Suppose we assign origin on (50,100) screen. And assign origin on (-50,-50) picture X+ Y+ -50 X+ Y+

Assume move picture from x = 50 to x= X+ Y X+ Y+ -50 X+ Y+ 80

Origin Origin is a position that show picture as previous section and we can assign origin from axis of picture. Origin also is used for rotating picture. You can find more information about rotating in wiki.

Collision Detecting There are many collision algorithm. I will show two sample.

Vector2 Collision bool CollisionDetect(Vector2 Player,Vector2 enemy) { float distance = Vector2.DistanceSquared(player,enemy); if(distance*distance < 10f) { return true;} return false; }

Rectangle Collision Bool RectangleCollision(Rectangle Player,Rectangle Enemy) { return !( Player.Bottom > Enemy.Top || Player.Top Enemy.Right) //check case that is not collision and revert it }

Let’s practice more Write a program that picture can move around but picture is not out side screen display.

What’s code we should know? GraphicsDeviceManager graphics; int displayheight = graphics.GraphicsDevice.Viewport.Height; It’s for height of display screen. spriteBatch.Draw(Texture2D,Rectangle,Color ) spriteBatch.Draw(Texture2D,Vector2,Color)

Detecting base-level it’s enough for moving picture around.