You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.8 KiB
79 lines
2.8 KiB
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<SoundEffect>("MenuMusic"), 0.5f, "menu", false),
|
|
new Sound(Content.Load<SoundEffect>("Hit"), 0.5f, "Music", true),
|
|
new Sound(Content.Load<SoundEffect>("shot"), 0.5f, "Shot", true),
|
|
new Sound(Content.Load<SoundEffect>("Explosion"), 0.5f, "Explosion", true),
|
|
new Sound(Content.Load<SoundEffect>("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<Texture2D>("player"), Content.Load<Texture2D>("bullet"));
|
|
AS = new AllAst(PL);
|
|
AS.asTextures = new Texture2D[]{
|
|
Content.Load<Texture2D>("asteroid"),
|
|
};
|
|
vars.ThePixel = Content.Load<Texture2D>("ThePixel");
|
|
vars.Font = Content.Load<SpriteFont>("Arial");
|
|
vars.PowerUpTex = new Texture2D[]{
|
|
Content.Load<Texture2D>("Powerup"),
|
|
};
|
|
vars.Scens = new Scenes(this, _spriteBatch);
|
|
vars.explosionsheet = Content.Load<Texture2D>("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;
|
|
} |