Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview / Introduction to our work in Silverlight Developing with the Silverlight 2 Framework Design of the Concept / Storyboards Architecture Game Logic.

Similar presentations


Presentation on theme: "Overview / Introduction to our work in Silverlight Developing with the Silverlight 2 Framework Design of the Concept / Storyboards Architecture Game Logic."— Presentation transcript:

1

2 Overview / Introduction to our work in Silverlight Developing with the Silverlight 2 Framework Design of the Concept / Storyboards Architecture Game Logic Scrolling Game Board Player Movement Collision Detection Media - Animation / Sounds Tools and Techniques

3

4 Compelling Cross-Platform User Experience Flexible object-oriented model Fully managed code to improve encapsulation and centralization Declarative presentation language (Xaml) Role specific tools Rapid application development

5

6

7

8 Create level treatments and script Sketch and storyboard main game element Character, Prop, Backgrounds, Levels… Illustrate and Animate game elements Design Game screen Intro, Level Chooser, Game Won, Game Lost

9

10 Visual Studio 2008 Expression Design 1.0 Expression Blend 2 Adobe Illustrator Flash MX TileStudio Wacom Tablets

11

12 Users loads Page.xaml from Launcher.xap User downloads our Intro.xap Using reflection we load Assembly Begin downloading our Game.xap Display MiniClip intro Display our loading screen Load our Main.xaml into Page.xaml

13 Launcher.xap (<140k) AppManifest.xmlLauncher.dll System.Xml.Linq.dll (123k) Intro.xap (<50k) AppManifest.xmlIntro.dllAudio\miniS1.mp3Audio\miniS2.mp3Images\minilogoGlow.png Game.xap (<4mb) AppManifest.xmlGame.dllScreens….Tiles..Sounds…

14 void Page_Loaded(object sender, RoutedEventArgse) { LayoutRoot.Children.Add(_preLoader); Uri addressUri = new Uri("ClientBin/MiniclipIdent.xap", UriKind.Relative); System.Net.WebClient wc = new System.Net.WebClient(); wc.BaseAddress = baseUri; wc.OpenReadCompleted += new OpenReadCompletedEventHandler(IdentDownloaded); wc.OpenReadAsync(addressUri);... }

15 void IdentDownloaded(object sender, System.Net.OpenReadCompletedEventArgse) {... foreach (XElement setting in myAssemblies) { uncompressedFile = Application.GetResourceStream(sri, new Uri(setting.Attribute("Source").Value, UriKind.Relative)); AssemblyPartap = new AssemblyPart(); Assembly a = ap.Load(uncompressedFile.Stream); }

16 View Renders the models Receives input from users and fires events to the controller. View Renders the models Receives input from users and fires events to the controller. Controller Responding to interactions within the view and translates these inputs into actions performed by the model Controller Responding to interactions within the view and translates these inputs into actions performed by the model Model Manages the behavior and state of an application. Encompasses all of the business logic. Notifies the view of changes Model Manages the behavior and state of an application. Encompasses all of the business logic. Notifies the view of changes

17

18

19 Instantiates our collision detection Attaches event handlers for keyboard and board events Board events control EVERYTHING They by acting upon the appropriate model. Player Teleported Paddles animated Item picked up Projectile Deflected

20 public void playerTeleported() { Teleport source = gameModel.getPlayer().getOnTeleport(); Teleport destination = source.getLinkedTeleport(); if (destination.getMaintainDirection()) { //reset the teleport data gameModel.getPlayer().setOnTeleport(null); //continue animating the player MovementDescriptor nextLocation = getNextDirectedLocationMultiple (gameModel.getPlayer().getDirection()); gameModel.getPlayer().setNewLocation(nextLocation); view.animatePlayerJump(nextLocation); } else view.scrollPlayerReturn(); //scroll over to the exit }

21 A board is a multi-dimensional map of tiles each placed at a different z layer. Each of our tiles is a UserControl that exhibit specific collision behavior

22 Through our use of layers, we can maximize our efficiency of collision detection by ignoring tiles that are not at the same z- index. Secondly, we can allow tiles to be stacked to maximize the reusability of tiles.

23 To achieve tiles at multiple layers, we uses a single parent canvas with a series of sibling canvases. Each tile at the same z layer, is inserted into one of these canvases. In most situations the player is located in the middle layer.

24 Our boards are defined in XML, generated by a open source tool called TileStudio Each board consists of a series of 40x40 tiles positioned in a grid (max 100x100 tiles). Our game screen is scrolling and only displays about 10 tiles across by 14 tiles high

25

26 private void buildBoard(object sender, GameEventArgsgea) { BoardDatanextBoard = _gameConfig.getSpecificBoard(gea.TargetLevel); //pull the definition of the board out of the assembly Stream s = this.GetType().Assembly. GetManifestResourceStream(namespacePrefix + nextBoard.filename); string boardXml = new StreamReader(s).ReadToEnd(); gameModel = new GameDefintion(boardXml); playerScore = new PlayerStats(nextBoard); view.Board = gameModel; collider = new Collisions(gameModel); }

27 Each of our tiles has a corresponding Model which maintains its logical state. Position (x,y,z), Rotation, Orientation… Each model exposes methods to calculate the appropriate reaction to game events.

28

29 When the game begins, our game board immediately renders each tile for that level, setting each tiles visibility to collapsed. We divide our level into a series of screens; each screen is comprised of 10x14 tiles. A timer begins (Game tick) which will be used to control tile visibility.

30 Based on the position of the player, we visualize a screen of tiles one tile larger then our screen dimensions.

31 The player is always centered on the screen. To give the perception that the player is moving, the entire board animates in opposite direction to the player. Keyboard mappings Space bar – Fires a projectile Ctrl – Activates a tile (player picks up a prop) Left, Right, Up and Down – Player moves

32 Once per game tick, we evaluate if a new screen of tiles need to be visualized based on the movement of the player.

33 When the gun is fired, the scrolling board follows the projectile to its destination, upon impact (stick or deflection), the view animates back to the players original location

34

35 Collisions occur when a player is asked to consume an adjacent tile occupied by an existing tile at its same z-layer. Each time the appropriate movement key is pressed, a method in our board controller is fired, in turn calling a method within our collision detection class. This method checks to see if a tile at the same z-index is blocking the movement.

36 When a player attempts to move to an adjacent tile, that tile determine the effect of the collision.

37 To expedite the process of finding the next blocking tile, a generic collection is constructed that will hold a reference to each tile model within its relationship to the game board. Through the use of polymorphism we can quickly allow each tile to determine its reaction to a collision. Through the use of polymorphism we can quickly allow each tile to determine its reaction to a collision.

38 private List [][] gameGrid = new List [gameModel.getRows()][]; for (inti=0; i

39

40 Silverlight uses a property-based animation model. A model which is time based. Silverlight can only modify the value of a property over an interval of time. In essence, it you set the initial state, the final state, and the duration of your animation then Silverlight will calculates the frame rate.

41 Using this technique a series of frames are stacked at the same X,Y. Key frames are created toggling the opacity of the current and previous frame.

42 Using this technique, each frame is positioned adjacent to each other within a single canvas. A canvas clip is defined the width and height of a single frame. Key frames are created moving the canvas strip from right to left

43

44 There are numerous situations where we use a combination of Frame-By-Frame animations within a time-based animation. Player movement Firing of Projectile Deflection of Projectile

45

46 All of our sounds are managed in a single sound factory (singleton). Extracts sounds from game assembly using app.manifest and an audio xml config file This configfile defines our LeadIn / LeadOuts for sound loops Controls the muting of sounds Centralizes access to our generic sound dictionary

47

48 © 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.

49


Download ppt "Overview / Introduction to our work in Silverlight Developing with the Silverlight 2 Framework Design of the Concept / Storyboards Architecture Game Logic."

Similar presentations


Ads by Google