Rob Miles Microsoft MVP University of Hull Fun Programming with Visual Studio.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Dan Waters, Academic Relations Manager, Microsoft.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Payroll and HR Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Co- location Mass Market Managed Hosting ISV Hosting.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Multitenant Model Request/Response General Model.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Announcing Demo Announcing.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Session 1.
travel Suru Windows 7 Release NET 4.0 / Surface 2.0 Release Multi-Touch Controls Multi-Touch API Surface Multi-Touch Controls & API Surface.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
 Frank Savage Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
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.
WinHEC /22/2017 © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
Video Ad CPM Display Ad CPM $0 $25 $50 Source: Bain/IAB Benchmarking Study 2008 Average CPM Marketers love video! Video commands.
Connect with life Connect with life
NEXT: Overview – Sharing skills & code.
11 Adding Sounds Session 7.1. Session Overview  Find out how to capture and manipulate sound on a Windows PC  Show how sound is managed as an item of.
FonePlus Hugh Teegan Architect Mobile Devices Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Building Social Games for Windows 8 with Windows Azure Name Title Microsoft Corporation.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Ian Ellison-Taylor General Manager Microsoft Corporation PC27.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”
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.
customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Feature: Void Historical/Open Transaction Updates © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
11 Computers, C#, XNA, and You Session 1.1. Session Overview  Find out what computers are all about ...and what makes a great programmer  Discover.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
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.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
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.

MIX 09 5/29/ :31 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Возможности Excel 2010, о которых следует знать
Title of Presentation 12/2/2018 3:48 PM
28 days.
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
Presentation transcript:

Rob Miles Microsoft MVP University of Hull Fun Programming with Visual Studio

3 Agenda Fun Programming with Visual Studio Writing Silly Games for Fun A Silly Game Demo Writing Silly Games using Visual Studio The XNA Framework Creating games in C# Writing games for Windows Phone Writing Silly Games for Profit The Creators Club and Indie Games

4 The Video Game Business Bigger than the movies? GTA4 sales topped half a billion dollars in its first week of release, 5 times the earnings of the Iron Man movie Set to grow even more? It is now easy (and cheap) to write a game in your bedroom and make it available to every Xbox Live subscriber in the world

5 Games that are very silly and sociable Easy to create and understand Based on examples in: Learn Programming Now! with Microsoft® XNA™ Game Studio 3.0 by Rob Miles

6 “Hide the Gamepad” Rob Miles

7 Sample XNA 2D game: “Hot Salad Death” We are going to consider a simple “casual” game The player guides the cheese around with the bread, hitting the tomatoes but avoiding the peppers and tangerines This is a simple, 2D, sprite based game

8 “Hot Salad Death” Rob Miles

9 Computer Game Constructions Every game that has ever been written does these things: 1.Initialise all the resources at the start This is where the “Loading” screen comes from 2.Repeatedly runs the game loop: a)Update the game world read the controllers, update the state and position of the things in the game b)Draw the game word for the player to see Display the game elements on the screen

10 Starting with our Cheese To begin writing our game we can make some cheese bounce around the screen To draw some cheese the game needs to remember two things The picture to draw The position on the screen to draw it This is the basis of a sprite Texture2D cheeseTexture; Rectangle cheeseRectangle; Texture2D cheeseTexture; Rectangle cheeseRectangle;

11 Games and Resources Modern games contain thousands of content items: Pictures Sounds 3D models Scripts A game has to manage all these items so that the program can find and use them cheeseTexture = Content.Load ("Cheese"); cheeseTexture = Content.Load ("Cheese");

12 Loading the Cheese Texture LoadContent is called when the game starts It loads the content and makes it available for use in the game It loads the cheese texture from the Content Manager It creates a rectangle to bound and position the sprite It should scale the rectangle to match the display dimensions protected override void LoadContent() { cheeseTexture = Content.Load ("Cheese"); cheeseRectangle = new Rectangle (0, 0, 100,100); } protected override void LoadContent() { cheeseTexture = Content.Load ("Cheese"); cheeseRectangle = new Rectangle (0, 0, 100,100); }

13 Drawing the Game World Now we have our cheese we want to draw it for the player to see The game contains a Draw method that is called to draw the game display on the screen We need to add some code to tell draw to put the cheese on the screen The draw commands are batched up before being sent to the graphics hardware Creating a Bank Class

14 XNA Game Drawing protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(cheeseTexture, cheeseRectangle, Color.White ); spriteBatch.End(); base.Draw(gameTime); }

15 “Drawing Cheese” Rob Miles

16 Making things move with the Update method At the moment the cheese is always drawn at the same place We need to make it move about the screen Games do this by having an Update behaviour In a racing game this would mean moving all the cars on the track, checking for collisions etc In a shooting game this would mean moving all the players, checking to see if any bullets have hit anything etc

17 Stupid XNA Game Update We have two integer variables that hold the speed of our cheese int cheeseXSpeed = 3; int cheeseYSpeed = 3; protected override void Update() { cheeseRectangle.X = cheeseRectangle.X + cheeseXSpeed; cheeseRectangle.Y = cheeseRectangle.Y + cheeseYSpeed; } int cheeseXSpeed = 3; int cheeseYSpeed = 3; protected override void Update() { cheeseRectangle.X = cheeseRectangle.X + cheeseXSpeed; cheeseRectangle.Y = cheeseRectangle.Y + cheeseYSpeed; }

18 “Moving Cheese” Rob Miles

19 Adding some Bounce to the Cheese We want the cheese to bounce off the edge of the screen We can do this by changing the sign of the speed value protected override void Update() { cheeseRectangle.X = cheeseRectangle.X + cheeseXSpeed; if (cheeseRectangle.X < 0 || cheeseRectangle.Right > GraphicsDevice.Viewport.Width) { cheeseXSpeed *= -1; } protected override void Update() { cheeseRectangle.X = cheeseRectangle.X + cheeseXSpeed; if (cheeseRectangle.X < 0 || cheeseRectangle.Right > GraphicsDevice.Viewport.Width) { cheeseXSpeed *= -1; }

20 “Bouncing Cheese” Rob Miles

21 Creating a bread bat Now we need to create a bat texture and then allow the player to control it XNA provides support for keyboard and XBOX 360 gamepad You can plug a wired gamepad into an PC and it will just work You can also get a USB adapter so you can use wireless gamepads The gamepad buttons can be tested during the Update method

22 Using the Thumbstick DPad GamePadState padState = GamePad.GetState(PlayerIndex.One); if (padState.IsConnected) { if (padState.DPad.Left == ButtonState.Pressed) { breadRectangle.X = breadRectangle.X - breadSpeed; } if (padState.DPad.Right == ButtonState.Pressed) { breadRectangle.X = breadRectangle.X + breadSpeed; } }

23 Using the Thumbstick DPad int padXSpeed = 10; int padYSpeed = 10; if (padState.IsConnected) { breadRectangle.X += (int) (padState.ThumbSticks.Left.X * padXSpeed); breadRectangle.Y -= (int) (padState.ThumbSticks.Left.Y * padYSpeed); }

24 Hitting the Cheese This code reverses the vertical direction of the cheese when it hits the bread It works by detecting when the cheese and bread rectangles intersect This is a very simple kind of collision detection if ( breadRectangle.Intersects(cheeseRectangle)) { cheeseYSpeed *= -1; } if ( breadRectangle.Intersects(cheeseRectangle)) { cheeseYSpeed *= -1; }

25 Adding Sound // Sound effect variable SoundEffect ding; // Load the sound effect content in LoadContent // Sound effects are WAV files which are played from memory ding = Content.Load ("Ding"); // Play the sound effect when the bread hits the cheese if ( breadRectangle.Intersects(cheeseRectangle)) { cheeseYSpeed *= -1; ding.Play(); }

26 Playing Music // Song variable Song music; // Load the song content in LoadContent // Music can be an MP3 or WMA file // Also have access to the media content on the device music = Content.Load ("Music"); // Play the song using the Media Player MediaPlayer.Play(music);

27 XNA and Windows Phone Windows Phone 7 provides an XNA environment that supports both 2D and 3D games These are developed using exactly the same environment Games can be stored and run from the device

28 “Windows Phone Starlight” Rob Miles

29 Windows Phone 7 Game Development Games are controlled using the Accelerometer and the multi-touch input There is no physical controller as such Windows Phone provides X, Y and Z values for acceleration and four points of multi-touch In this respect it is similar to the Zune HD device Although Zune HD only supports 2D XNA and you develop for the platform using Visual Studio 2008 and XNA 3.1

30 “Zune HD Album Juggler” Rob Miles

31 Getting Started with XNA All the software is free: Visual Studio 2010 Express Edition XNA Game Studio 4.0 (when it is released) – use the Windows Phone SDK for now Games can be run on the XBOX 360 You need to join the "Creators Club" in order to do this Students can get free membership through DreamSpark Visit robmiles.com for details on how to get started

32 Selling your Games You can put your XNA games onto Xbox Live All Xbox Live subscribers are able to download and play XNA games you have written You can even charge money for them Windows Phone will have its own marketplace

33 Summary The XNA Framework provides a very powerful environment for game creation Write games for your Xbox or PC in C# using Visual Studio – can also target Windows Phone You should all be writing games It is easy to do It is fun! You might make some money!

34 Resources XNA Creators Club: DreamSpark Microsoft XNA blogs All the sample code and resource links: Very Silly Games and book links:

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.