-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainGame.cs
74 lines (59 loc) · 2.03 KB
/
MainGame.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using TexturePackerLoader;
namespace BCEngine;
public class MainGame : Game
{
GraphicsDeviceManager graphics;
public SpriteBatch spriteBatch;
public SpriteRender spriteRender;
public GameState gameState;
public Rectangle Screen;
public MainGame()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferHeight=450;
graphics.PreferredBackBufferWidth=800;
graphics.ApplyChanges();
Screen = new Rectangle();
Screen.Width = graphics.PreferredBackBufferWidth;
Screen.Height = graphics.PreferredBackBufferHeight;
Content.RootDirectory = "Content";
IsMouseVisible = true;
gameState = new BCEngine.GameState(this);
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
IsMouseVisible=true;
gameState.changeScene(GameState.SceneType.Gameplay);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
spriteRender = new SpriteRender(spriteBatch);
// TODO: use this.Content to load your game content here
AssetManager.Load(Content);
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
if(gameState.currentScene!=null){
gameState.currentScene.Update(gameTime);
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
if(gameState.currentScene!=null){
gameState.currentScene.Draw(gameTime);
}
base.Draw(gameTime);
}
}