-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapRenderer.cs
More file actions
88 lines (66 loc) · 2.41 KB
/
MapRenderer.cs
File metadata and controls
88 lines (66 loc) · 2.41 KB
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
using HLMapFileLoader;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace HLMapFileLoader.Example
{
public class Game1 : Game
{
private List<Mesh> meshes;
private Camera camera;
private BasicEffect effect;
private SpriteFont arial12Font;
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
meshes = new List<Mesh>();
graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 600;
}
protected override void Initialize()
{
effect = new BasicEffect(GraphicsDevice);
camera = new Camera(this);
Components.Add(camera);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
arial12Font = Content.Load<SpriteFont>("Arial12Font");
List<Brush> brushes = Map.Load(@"Content\game.map", Content);
foreach (Brush brush in brushes)
{
meshes.Add(new Mesh(GraphicsDevice, brush));
}
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
foreach (Mesh mesh in meshes)
{
mesh.Draw(effect, camera);
}
spriteBatch.Begin();
spriteBatch.DrawString(arial12Font, "Move: W, A, S, D\nUpwards:SPACE\nDownwards:SHIFT\nRotate: UP, DOWN, LEFT, RIGHT", new Vector2(5, 5), Color.Black);
spriteBatch.End();
base.Draw(gameTime);
}
}
}