-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d971de9
Showing
7 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# exclude bin andobj directorys | ||
/bin | ||
/obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace MIST; | ||
using SadConsole; | ||
using SadRogue.Primitives; | ||
|
||
|
||
internal class GameObject | ||
{ | ||
public Point Position { get; private set; } | ||
|
||
public ColoredGlyph Appearance { get; set; } | ||
|
||
public IScreenSurface hostingSurface { get; set; } | ||
|
||
public GameObject(ColoredGlyph appearance, Point position, IScreenSurface surface) | ||
{ | ||
Appearance = appearance; | ||
Position = position; | ||
hostingSurface = surface; | ||
} | ||
|
||
public void Draw() | ||
{ | ||
Appearance.CopyAppearanceTo( hostingSurface.Surface[Position]); | ||
hostingSurface.IsDirty = true; | ||
} | ||
|
||
public void MoveTo(Point newPosition) | ||
{ | ||
Position = newPosition; | ||
} | ||
|
||
public void TryToMove(int dx, int dy, Map map) | ||
{ | ||
// check if the position is within the map | ||
if (Position.X + dx >= 0 && Position.X + dx < map.MapArray.Width && Position.Y + dy >= 0 && Position.Y + dy < map.MapArray.Height) | ||
{ | ||
// if it goes into a wall, don't move, else move | ||
if (map.MapArray[Position.X + dx, Position.Y + dy] != Map.TileType.Wall) | ||
{ | ||
MoveTo(new Point(Position.X + dx, Position.Y + dy)); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="GoRogue" Version="2.6.4" /> | ||
<PackageReference Include="SadConsole" Version="9.2.2" /> | ||
<PackageReference Include="SadConsole.Host.MonoGame" Version="9.2.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MIST", "MIST.csproj", "{EF9BE569-8C4E-4CA5-A487-8AC7F78AE0D7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EF9BE569-8C4E-4CA5-A487-8AC7F78AE0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EF9BE569-8C4E-4CA5-A487-8AC7F78AE0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EF9BE569-8C4E-4CA5-A487-8AC7F78AE0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EF9BE569-8C4E-4CA5-A487-8AC7F78AE0D7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {D0F32144-7B9D-40A8-880A-09D08737A2C8} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using GoRogue.MapViews; | ||
using SadRogue.Primitives; | ||
using GoRogue; | ||
using SadConsole; | ||
|
||
namespace MIST | ||
{ | ||
|
||
internal class Map | ||
{ | ||
|
||
public ArrayMap2D<TileType>? MapArray; | ||
|
||
public ArrayMap2D<bool>? ExploredArray; | ||
|
||
public ArrayMap2D<bool>? VisbleArray; | ||
public readonly ColoredGlyph WALL = new ColoredGlyph(Color.AnsiBlue, Color.DarkBlue, '#'); | ||
public readonly ColoredGlyph FLOOR = new ColoredGlyph(Color.DarkBlue, Color.Black, '.'); | ||
|
||
public readonly ColoredGlyph UNDEFINED = new ColoredGlyph(Color.White, Color.Black, '?'); | ||
|
||
/// <summary> | ||
/// a emun for what tile type it is | ||
/// </summary> | ||
public enum TileType | ||
{ | ||
Floor, | ||
Wall | ||
} | ||
|
||
/// <summary> | ||
/// a 2d array of TileTypes for maps | ||
/// <param name="Width">the width of the map</param> | ||
/// <param name="Height">the height of the map</param> | ||
/// </summary> | ||
public Map(int width, int height) | ||
{ | ||
MapArray = new ArrayMap2D<TileType>(width, height); | ||
} | ||
|
||
/// <summary> | ||
/// generates a map with a border and random tiles | ||
/// <param name="Width">the width of the map</param> | ||
/// <param name="Height">the height of the map</param> | ||
/// </summary> | ||
public Map GenerateMap(int Width, int Height) | ||
{ | ||
var map = new Map(Width, Height); | ||
Random random = new Random(); | ||
for (int x = 0; x < this.MapArray.Width; x++) | ||
{ | ||
for (int y = 0; y < this.MapArray.Height; y++) | ||
{ | ||
// Generate a random tile | ||
TileType tileType = TileType.Floor; | ||
|
||
// 20% chance of a wall | ||
if (random.Next(100) < 20) | ||
{ | ||
tileType = TileType.Wall; | ||
} | ||
|
||
// If it's a border tile, set it as a wall | ||
if (x == 0 || x == this.MapArray.Width - 1 || y == 0 || y == this.MapArray.Height - 1) | ||
{ | ||
tileType = TileType.Wall; | ||
} | ||
|
||
// Set the tile in the map | ||
map.SetTile(x,y, tileType); | ||
} | ||
} | ||
return map; | ||
} | ||
/// <summary> | ||
/// sets a tile in the map | ||
/// </summary> | ||
/// <param name="x">the x coordinate to set the tile </param> | ||
/// <param name="y">the y coordinate to set the tile</param> | ||
/// <param name="tileType">what type of tile should be set</param> | ||
private void SetTile(int x, int y, TileType tileType) | ||
{ | ||
// Set the tile in the map | ||
this.MapArray[x, y] = tileType; | ||
} | ||
|
||
public void DrawArray( CellSurface surface) | ||
{ | ||
for (int x = 0; x < this.MapArray.Width; x++) | ||
{ | ||
for (int y = 0; y < this.MapArray.Height; y++) | ||
{ | ||
if (TileType.Floor == this.MapArray[x, y]) | ||
{ | ||
surface.SetCellAppearance(x, y, FLOOR); | ||
} | ||
else if (TileType.Wall == this.MapArray[x, y]) | ||
{ | ||
surface.SetCellAppearance(x, y, WALL); | ||
} | ||
else | ||
{ | ||
surface.SetCellAppearance(x, y, UNDEFINED); | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
| ||
using System; | ||
using GoRogue.GameFramework; | ||
using SadConsole; | ||
using SadConsole.Input; | ||
using SadRogue.Primitives; | ||
using Console = SadConsole.Console; | ||
|
||
namespace MIST | ||
{ | ||
class Program | ||
{ | ||
|
||
public const int Width = 80; | ||
public const int Height = 25; | ||
|
||
public static Console startingConsole = (Console)GameHost.Instance.Screen; | ||
|
||
public static GameObject player = new GameObject(new ColoredGlyph(Color.White, Color.Black, '@'), new Point(0, 0), startingConsole); | ||
|
||
public static Map map = new Map(Width, Height); | ||
|
||
public static int movetimer = 0; | ||
|
||
|
||
static void Main(string[] args) | ||
{ | ||
SadConsole.Settings.WindowTitle = "MIST"; | ||
|
||
// Setup the engine and create the main window. | ||
SadConsole.Game.Create(Width, Height); | ||
|
||
// Hook the start event so we can add consoles to the system. | ||
SadConsole.Game.Instance.OnStart = Init; | ||
|
||
// Start the game. | ||
SadConsole.Game.Instance.Run(); | ||
SadConsole.Game.Instance.Dispose(); | ||
} | ||
|
||
private static void Init() | ||
{ | ||
var mapSurface = new CellSurface(Width, Height); | ||
map = map.GenerateMap(Width, Height); | ||
var keyboard = new Keyboard(); | ||
|
||
SadConsole.Game.Instance.FrameUpdate += (sender, args) => | ||
{ | ||
startingConsole.Clear(); | ||
map.DrawArray(mapSurface); | ||
mapSurface.Copy(startingConsole.Surface); | ||
player.Draw(); | ||
|
||
var inputprocessed = processInput(keyboard); | ||
|
||
// see if we did an input | ||
if (inputprocessed) | ||
{ | ||
System.Console.WriteLine("input processed"); | ||
} | ||
|
||
}; | ||
} | ||
|
||
private static bool processInput(Keyboard keyboard) | ||
{ | ||
var processed = false; | ||
|
||
// update keyboard input | ||
keyboard.Update(TimeSpan.Zero); | ||
|
||
// move player with numbpad | ||
var dx = 0; | ||
var dy = 0; | ||
|
||
|
||
if (keyboard.IsKeyDown(Keys.NumPad4)) | ||
{ | ||
dx = -1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad6)) | ||
{ | ||
dx = 1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad8)) | ||
{ | ||
dy = -1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad2)) | ||
{ | ||
dy = 1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad1)) | ||
{ | ||
dx = -1; | ||
dy = 1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad3)) | ||
{ | ||
dx = 1; | ||
dy = 1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad7)) | ||
{ | ||
dx = -1; | ||
dy = -1; | ||
processed = true; | ||
} | ||
else if (keyboard.IsKeyDown(Keys.NumPad9)) | ||
{ | ||
dx = 1; | ||
dy = -1; | ||
processed = true; | ||
} | ||
|
||
if (processed) | ||
{ | ||
// move player if the movetimer expired | ||
if (movetimer > 0) | ||
{ | ||
movetimer--; | ||
} | ||
else | ||
{ | ||
player.TryToMove(dx, dy, map); | ||
movetimer = 5; | ||
} | ||
|
||
} | ||
|
||
return processed; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## MIST | ||
MIST is a roguelike game written in C#, using the `Sadconsole` library. | ||
this is the official repo of this game. | ||
|
||
install the game. you can download it [here](https://github.com/jossse69/MIST/releases). | ||
(NOTE EXTRIMATELY ALPHA VERSION) | ||
|
||
# controls | ||
use numberpad to move. | ||
*more controls to come* | ||
|
||
# license | ||
MIT License, it can be found [here](https://github.com/jossse69/MIST/blob/main/LICENSE). | ||
|
||
# credits | ||
* [jossse69](https://github.com/jossse69) (original author) |