-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGame1.cs
108 lines (99 loc) · 4.38 KB
/
Game1.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace GordonWare
{
/// <summary>
/// This is the main type for your game.
/// Please do not modify this or any other class in your pull request, but
/// feel free to change it in order to experiment or just add your minigame
/// to the minigame rotation in order to test it.
/// In order to create a minigame, you have to create a new file with your
/// minigame's name as a title such as "MiniGameName.cs" in the Games folder.
/// You can copy the content of the file "TemplateGame" in this new file.
/// This class should herit from the MiniGame class, you can refer to the
/// MiniGame class and other sample mini games such as KeyboardGame or DabGame to
/// get more specifications.
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public SpriteFont RouliFont;
public const int screenWidth = 1280;
public const int screenHeight = 720;
public List<MiniGame> miniGames;
public Game1()
{
Content.RootDirectory = "Content";
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
}
/// <summary>
/// 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.
/// </summary>
protected override void Initialize()
{
// If you want the game to only play your minigame in order to test it, please remove every other game and add only yours to MiniGameManager
//MiniGameManager.AddMiniGame(new TemplateGame());
MiniGameManager.AddMiniGame(new PizzaGame());
MiniGameManager.AddMiniGame(new KeyboardGame());
MiniGameManager.AddMiniGame(new DabGame());
MiniGameManager.AddMiniGame(new TaupeGame());
MiniGameManager.AddMiniGame(new BananeGame());
MiniGameManager.AddMiniGame(new GordonMinerGame());
MiniGameManager.AddMiniGame(new ChooseServiceGame());
MiniGameManager.AddMiniGame(new RecognitionGame());
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
RouliFont = Content.Load<SpriteFont>("Rouli");
MiniGameManager.LoadContent(Content); // This will call the LoadContent function of your minigame class
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
Input.Update(gameTime);
MiniGameManager.Update(gameTime); // This will call your minigame's update function for you
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
MiniGameManager.Draw(spriteBatch); // And this will call your minigame's draw function!
spriteBatch.End();
base.Draw(gameTime);
}
}
}