1 / 26

Quixo 3D: Game Programming in .NET Quixo3D.UI

Quixo 3D: Game Programming in .NET Quixo3D.UI. Mike Hodnick www.kindohm.com Jason Bock www.jasonbock.net Twin Cities Code Camp - October 27, 2007. On the docket…. Mike.hodnick@gmail.com www.kindohm.com. Show the game Strategy for drawing the board Third party tools

Sharon_Dale
Télécharger la présentation

Quixo 3D: Game Programming in .NET Quixo3D.UI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quixo 3D: Game Programming in .NETQuixo3D.UI Mike Hodnick www.kindohm.com Jason Bock www.jasonbock.net Twin Cities Code Camp - October 27, 2007

  2. On the docket… Mike.hodnick@gmail.com www.kindohm.com • Show the game • Strategy for drawing the board • Third party tools • Strategy for game piece behavior • Neat features • Improvements • Giveaways… National Quixo3D Team Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  3. Show the game demo Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  4. Strategy for drawing the board • WPF App • Use WPF 3D features • Cube grid of game pieces Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  5. Y 4 3 2 1 0 X 2 3 4 0 1 Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  6. Y Piece Size = 1x1 X Translation = X CoordinateY Translation = Y Coordinate 4 3 2 1 0 X 2 3 4 0 1 Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  7. Y Piece Size = 1x1 X Translation = X Coordinate * X SpacingY Translation = Y Coordinate * Y Spacing 4 3 2 1 0 X 2 3 4 0 1 Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  8. Strategy for drawing the board code Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  9. Third Party Tools • 3DTools • www.codeplex.com/3DTools • Trackball decorator • Petzold.Media3D • Charles Petzold (www.charlespetzold.com) • 3D model generation Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  10. Using the Trackball decorator • Reference the _3DTools CLR namespace in your XAML: • Wrap the Trackball around a Viewport3D in XAML: xmlns:tools=“clr-namespace:_3DTools;assembly=3DTools” <tools:TrackballDecorator> <Viewport3D /></tools:TrackballDecorator> Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  11. Leveraging Petzold.Media3D • CubeMesh • Creates a cube • Used to represent an empty game piece • TorusMesh • Creates a “donut” • Used to represent a placed “O” game piece • SolidText • Creates 3D text • Used to represent a placed “X” game piece • Used for axis labels • WirePath • Draws lines in 3D space • Used to outline a valid source piece • Cylinder • Used for X,Y,Z axes Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  12. Petzold.Media3D code Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  13. Strategy for game piece behavior • GamePieceVisual class (GamePieceVisual:ModelVisual3D) • A composite visual model containing: • Cube mesh geometry • Torus mesh geometry • 3D Text visual model • Wireframe visual model • Changes appearance based on public properties: • Highlighted (mouse-overs) • IsValidSource (shows wireframe, indicates it can be clicked) • HighlightedAsValidSource (shows that you clicked it) • HighlightedAsValidDestination (shows you can click it) • PieceType (shows/hides the cube, torus, or text geometries/models) Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  14. Game piece composite model challenges • Cube and torus are “geometries” • SolidText and wireframe are “visual models” • Hit testing when an empty or “O” piece is shown will result in the GamePieceVisual being returned • Hit testing when an “X” piece is shown will return a PlanarText object that is rendered by SolidText • Hit testing when the wireframe is shown will return a ModelVisual3D object. Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  15. GamePieceVisual : ModelVisual3D Hit testing produces a ModelVisual3D! Content Children Model3DGroup xModel : ModelVisual3D wireFrame: ModelVisual3D emptyModel : GeometryModel3D oModel : GeometryModel3D When these visuals are shown, they themselves are the first ModelVisual3D objects found in the tree. When these geometries are shown, GamePieceVisual is the first ModelVisual3D found up the tree. Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  16. GamePieceVisual hit testing: code code Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  17. GamePieceVisual UI Effects • Highlighting: change scale and color • Select as valid source or destination: change color • Show winning lines: change scale • System.Windows.Media.Animation.Animatable • Brush (SolidColorBrush) • ScaleTransform3D • Animation Types • DoubleAnimation • ColorAnimation Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  18. Animation examples • void AnimateBrushColor(SolidColorBrush brush) • { • Color startColor = Colors.Blue; • Color endColor = Colors.Red; • TimeSpan duration = TimeSpan.FromMilleseconds(200); • ColorAnimation animation = new ColorAnimation(startColor, endColor, duration); • brush.BeginAnimation(SolidColorBrush.ColorProperty, animation); • } • void AnimateScale(ScaleTransform3D scale) • { • double startScale = 1; • double endScale = 1.5; • TimeSpan duration = TimeSpan.FromSeconds(2); • DoubleAnimation animation = new DoubleAnimation(startScale, endScale, duration); • scale.BeginAnimation(ScaleTransform3D.ScaleXProperty, animation); • scale.BeginAnimation(ScaleTransform3D.ScaleYProperty, animation); • scale.BeginAnimation(ScaleTransform3D.ScaleZProperty, animation); • } Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  19. UI Effects: code code Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  20. Neat Features • Move history data binding • Axes • Trackball enabling/disabling Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  21. Future Improvements • Make the game (framework, engine, UI, tests, etc.) size-agnostic • Create a Game class Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  22. Future Improvements • Algorithm optimizations • Parallel computations (FX/System.Concurrency?) • Trimming the tree • Opening book Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  23. Future Improvements • Algorithm optimizations (con’t) • Principal variation • Transposition tables • Iterative deepening • Evaluation improvements (genetic algorithms?) Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  24. Future UI Improvements • Multi-threading • Skinning and configuration • Use of dependency properties • VS 2005 vs. 2008 • Board and piece representation • “Up direction” • Support “undo” Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  25. Resources • http://www.codeplex.com/3DTools • http://www.charlespetzold.com • http://www.kindohm.com/technical/toc.htm • http://rhizohm.net/irhetoric/ • http://blogs.msdn.com/wpf3d/ Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

  26. Quixo3D: Game Programming in .NET Jason Bock – http://www.jasonbock.net Mike Hodnick – http://www.kindohm.com Quixo3D.UI - Twin Cities Code Camp - 2007.10.27

More Related