-
Notifications
You must be signed in to change notification settings - Fork 0
/
Terrain.cs
50 lines (46 loc) · 1.35 KB
/
Terrain.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace _1Pixor
{
class Terrain : Tile
{
public enum Type { Rock, Hole_Top, Hole_Bot, Air };
public Type getType { get; private set; }
public Terrain(Rectangle rec, GraphicsDevice gd, Type t) : base(rec, gd)
{
this.getType = t;
if (t == Type.Air)
{
base.color = Color.White;
}
if (t == Type.Rock)
{
base.color = Color.Gray;
}
if (t == Type.Hole_Bot)
{
base.color = Color.Purple;
}
if (t == Type.Hole_Top)
{
base.color = Color.Blue;
}
}
public static void terrainDraw(Terrain[,,] t, int lvl, int nbrWidth, int nbrHeight, SpriteBatch sp, GraphicsDevice gd)
{
Texture2D p = new Texture2D(gd, 1, 1, true, SurfaceFormat.Color);
p.SetData(new[] { Color.White });
for (int i = 0; i < nbrWidth; i++)
{
for (int j = 0; j < nbrHeight; j++)
{
sp.Draw(p, t[lvl, i, j].rec, t[lvl, i, j].color);
}
}
}
}
}