-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTicTacToe.cs
66 lines (57 loc) · 1.99 KB
/
TicTacToe.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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Diagnostics;
using System.Collections.Generic;
namespace TicTacToe {
public class TicTacToe : Game {
public GraphicsDeviceManager _graphics;
public SpriteBatch _spriteBatch;
public KeyboardState _keyboard_last;
public StateMachine _fsm;
public TicTacToe()
: base() {
_graphics = new GraphicsDeviceManager(this);
_fsm = new StateMachine(this);
Content.RootDirectory = "Content";
}
protected override void Initialize() {
base.Initialize();
_keyboard_last = Keyboard.GetState();
IsMouseVisible = true;
}
protected override void LoadContent() {
Primitives.LoadContent(GraphicsDevice, Content);
_fsm.LoadContent(Content);
_spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void UnloadContent() {
}
protected override void Update(GameTime gameTime) {
MouseMgr.Update(Mouse.GetState());
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed
|| Keyboard.GetState().IsKeyDown(Keys.Escape)) {
Exit();
}
_fsm.Update(gameTime);
_keyboard_last = Keyboard.GetState();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
_spriteBatch.Begin(
SpriteSortMode.FrontToBack,
BlendState.AlphaBlend,
SamplerState.AnisotropicWrap,
null,
null,
null,
null);
_fsm.Draw(gameTime, _spriteBatch);
_spriteBatch.End();
}
}
}