From fd6fa4e5cebbe3edb65d50c78dcc8a97ce98ce64 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Mon, 11 Dec 2017 22:02:13 +0100 Subject: First commit --- Penguloon/Main.cs | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Penguloon/Main.cs (limited to 'Penguloon/Main.cs') diff --git a/Penguloon/Main.cs b/Penguloon/Main.cs new file mode 100644 index 0000000..b2844fc --- /dev/null +++ b/Penguloon/Main.cs @@ -0,0 +1,121 @@ +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Input.Touch; + +using Android.Content.Res; + +namespace Penguloon +{ + /// + /// This is the main type for your game. + /// + public class Main : Game + { + private GraphicsDeviceManager _graphics; + private SpriteBatch _spriteBatch; + private Resources _resources; + + public GraphicsDeviceManager Graphics + { + get => _graphics; + set => _graphics = value; + } + + public SpriteBatch SpriteBatch + { + get => _spriteBatch; + set => _spriteBatch = value; + } + + public Resources Resources + { + get => _resources; + set => _resources = value; + } + + public Main(Resources resources) + { + Resources = resources; + Graphics = new GraphicsDeviceManager(this); + Content.RootDirectory = "Content"; + + Graphics.IsFullScreen = true; + Graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + SceneManager.Initialize(this); + StaticUIValues.Initialize(this); + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + SpriteBatch = new SpriteBatch(GraphicsDevice); + + ContentManager.LoadContent(this); + + // TODO: use this.Content to load your game content here + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// game-specific content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + ContentManager.DisposeContent(); + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + TouchLocation[] touchLocations = TouchPanel.GetState().ToArray(); + + SceneManager.Update(delta, touchLocations); + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + GraphicsDevice.Clear(Color.Black); + + SpriteBatch.Begin(); + + SceneManager.Draw(delta); + + SpriteBatch.End(); + + base.Draw(gameTime); + } + } +} -- cgit v1.2.3-70-g09d2