using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Audio; using System; namespace Asteroids; public class Game1 : Game { private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; public Player PL; public AllAst AS; public Game1() { AudioEn.MasterVolume = 0.5f; vars.ScreenSize = new Vector2(1920, 1080); _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; _graphics.IsFullScreen = true; _graphics.PreferredBackBufferHeight = (int)vars.ScreenSize.Y; _graphics.PreferredBackBufferWidth = (int)vars.ScreenSize.X; _graphics.ApplyChanges(); } protected override void Initialize() { AudioEn.Sounds = new Sound[]{ new Sound(Content.Load("MenuMusic"), 0.5f, "menu", false), new Sound(Content.Load("Hit"), 0.5f, "Music", true), new Sound(Content.Load("shot"), 0.5f, "Shot", true), new Sound(Content.Load("Explosion"), 0.5f, "Explosion", true), new Sound(Content.Load("Hit"), 0.5f, "Hit", true), }; AudioEn.Initialize(this); base.Initialize(); } protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); vars.PlayArea = new Rectangle((int)vars.ScreenSize.X/2-300, 50, 600, (int)vars.ScreenSize.Y-100); PL = new Player(Content.Load("player"), Content.Load("bullet")); AS = new AllAst(PL); AS.asTextures = new Texture2D[]{ Content.Load("asteroid"), }; vars.ThePixel = Content.Load("ThePixel"); vars.Font = Content.Load("Arial"); vars.PowerUpTex = new Texture2D[]{ Content.Load("Powerup"), }; vars.Scens = new Scenes(this, _spriteBatch); vars.explosionsheet = Content.Load("ExplosionIMG"); } protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.LeftAlt) && Keyboard.GetState().IsKeyDown(Keys.F4)) Exit(); AudioEn.Update(gameTime); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { vars.Scens.draw(gameTime); base.Draw(gameTime); } } public static class vars { public static Vector2 ScreenSize; public static Rectangle PlayArea; public static Texture2D[] PowerUpTex; public static SpriteFont Font; public static int Points; public static Texture2D ThePixel; public static Scenes Scens; public static Texture2D explosionsheet; }