{"id":544,"date":"2013-10-30T21:36:07","date_gmt":"2013-10-30T20:36:07","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=544"},"modified":"2013-11-16T14:01:09","modified_gmt":"2013-11-16T13:01:09","slug":"vb-net-and-xna-article-1","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=544","title":{"rendered":"VB.Net and XNA : Article 1 (skeleton class)"},"content":{"rendered":"<p>First of all, and this is where beginners could get confused, there is no form in an XNA VB.Net app.<br \/>\nYou actually need a module with a main sub calling the run method of your XNA class.<\/p>\n<p>You need to make a class that will inherit from Inherits Microsoft.Xna.Framework.Game and in there you will have to override a couple of methods.<\/p>\n<p>The basic steps\/methods are<br \/>\n1-initialise variables in <strong>Initialize<\/strong><br \/>\n2-load your content (audio, fonts, textures) in <strong>loadcontent<\/strong><br \/>\n3-put your update logic in <strong>update <\/strong>(check inputs, set new coordinates for a sprite, etc)<br \/>\n4-(re)draw your window in <strong>draw<\/strong> <\/p>\n<p>And thats basically it, you are ready to take advantage of all the classes and methods of the XNA framework \ud83d\ude42<\/p>\n<p>Next article will show a working XNA app.<\/p>\n<p>To make it easy on you, at the end of this article is a template project for vs2013 : copy the zip file in C:\\Users\\username\\Documents\\Visual Studio 2013\\Templates\\ProjectTemplates and VS2013 will propose you to create a XNA project from scratch.<\/p>\n<p>See below for a skeleton class.<\/p>\n<p><code><br \/>\nImports Microsoft.Xna.Framework<br \/>\nImports Microsoft.Xna.Framework.Graphics<br \/>\nImports Microsoft.Xna.Framework.Audio<br \/>\nImports Microsoft.Xna.Framework.Content<br \/>\nImports Microsoft.Xna.Framework.Media<br \/>\nImports Microsoft.Xna.Framework.Input<\/p>\n<p>Public Class Game<br \/>\n    Inherits Microsoft.Xna.Framework.Game<br \/>\n    'Fields in our game graphic manager etc'<br \/>\n    Dim graphics As GraphicsDeviceManager<\/p>\n<p>    Public Sub New()<br \/>\n        graphics = New GraphicsDeviceManager(Me)<br \/>\n        Window.Title = \"Test\"<br \/>\n        graphics.PreferredBackBufferHeight = 300<br \/>\n        graphics.PreferredBackBufferWidth = 300<br \/>\n    End Sub<\/p>\n<p>    Protected Overrides Sub Initialize()<br \/>\n        'TODO: Add your initialization logic here'<br \/>\n        '...<br \/>\n        MyBase.Initialize()<br \/>\n    End Sub<\/p>\n<p>    Protected Overrides Sub LoadContent()<br \/>\n        MyBase.LoadContent()<br \/>\n        ' TODO: use this.Content to load your game content here'<br \/>\n        '...<br \/>\n    End Sub<\/p>\n<p>    Protected Overrides Sub UnloadContent()<br \/>\n        MyBase.UnloadContent()<br \/>\n        'TODO: Unload any non ContentManager content here'<br \/>\n    End Sub<\/p>\n<p>    Protected Overrides Sub Update(ByVal gameTime As Microsoft.Xna.Framework.GameTime)<br \/>\n        'Allows the game to exit'<br \/>\n        If GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed Then<br \/>\n            Me.Exit()<br \/>\n        End If<br \/>\n        'TODO: Add your update logic here'<br \/>\n        '...<br \/>\n        MyBase.Update(gameTime)<br \/>\n    End Sub<\/p>\n<p>    Protected Overrides Sub Draw(ByVal gameTime As Microsoft.Xna.Framework.GameTime)<br \/>\n        GraphicsDevice.Clear(Color.CornflowerBlue)<br \/>\n        'TODO: Add your drawing code here'<br \/>\n        '...<br \/>\n        MyBase.Draw(gameTime)<br \/>\n    End Sub<br \/>\nEnd Class<br \/>\n<\/code><\/p>\n<p><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/10\/XNA_BASE.zip\">VS2013 template<\/a><\/p>\n<p><a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/10\/xna0.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/10\/xna0-300x190.png\" alt=\"xna0\" width=\"300\" height=\"190\" class=\"alignnone size-medium wp-image-597\" srcset=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/10\/xna0-300x190.png 300w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2013\/10\/xna0.png 816w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First of all, and this is where beginners could get confused, there is no form in an XNA VB.Net app. You actually need a module with a main sub calling the run method of your XNA class. You need to make a class that will inherit from Inherits Microsoft.Xna.Framework.Game and in there you will have <a href='https:\/\/labalec.fr\/erwan\/?p=544' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,35],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-xna","category-34-id","category-35-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=544"}],"version-history":[{"count":8,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/544\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}