aboutsummaryrefslogtreecommitdiff
path: root/Bitspace
diff options
context:
space:
mode:
Diffstat (limited to 'Bitspace')
-rw-r--r--Bitspace/Bitspace.sln25
-rw-r--r--Bitspace/Bitspace/App.config6
-rw-r--r--Bitspace/Bitspace/Biome.cs32
-rw-r--r--Bitspace/Bitspace/Bitspace.csproj56
-rw-r--r--Bitspace/Bitspace/Mob.cs112
-rw-r--r--Bitspace/Bitspace/Program.cs129
-rw-r--r--Bitspace/Bitspace/Properties/AssemblyInfo.cs36
7 files changed, 396 insertions, 0 deletions
diff --git a/Bitspace/Bitspace.sln b/Bitspace/Bitspace.sln
new file mode 100644
index 0000000..68c9347
--- /dev/null
+++ b/Bitspace/Bitspace.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28803.156
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bitspace", "Bitspace\Bitspace.csproj", "{9F5B200F-8C1E-4825-8115-34403E972FA0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9F5B200F-8C1E-4825-8115-34403E972FA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F5B200F-8C1E-4825-8115-34403E972FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F5B200F-8C1E-4825-8115-34403E972FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F5B200F-8C1E-4825-8115-34403E972FA0}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {BE10168B-3DC4-4185-A000-881F5746FEDC}
+ EndGlobalSection
+EndGlobal
diff --git a/Bitspace/Bitspace/App.config b/Bitspace/Bitspace/App.config
new file mode 100644
index 0000000..ecdcf8a
--- /dev/null
+++ b/Bitspace/Bitspace/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
+ </startup>
+</configuration>
diff --git a/Bitspace/Bitspace/Biome.cs b/Bitspace/Bitspace/Biome.cs
new file mode 100644
index 0000000..396e37e
--- /dev/null
+++ b/Bitspace/Bitspace/Biome.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Game
+{
+ class Biome
+ {
+ private string name;
+ private char floor; //floor literally what the mobs "step on"
+ private ConsoleColor color;
+
+ public string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
+ public char Floor
+ {
+ set { floor = value; }
+ get { return floor; }
+ }
+
+ public ConsoleColor Color
+ {
+ set { color = value; }
+ get { return color; }
+ }
+ }
+}
diff --git a/Bitspace/Bitspace/Bitspace.csproj b/Bitspace/Bitspace/Bitspace.csproj
new file mode 100644
index 0000000..bec126c
--- /dev/null
+++ b/Bitspace/Bitspace/Bitspace.csproj
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{9F5B200F-8C1E-4825-8115-34403E972FA0}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Game</RootNamespace>
+ <AssemblyName>Game</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Biome.cs" />
+ <Compile Include="Mob.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/Bitspace/Bitspace/Mob.cs b/Bitspace/Bitspace/Mob.cs
new file mode 100644
index 0000000..113a424
--- /dev/null
+++ b/Bitspace/Bitspace/Mob.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Game
+{
+ class Mob
+ {
+ //Mobile objects = Mobs
+
+ private ushort health;
+ private ushort maxHealth;
+
+ private ushort armour;
+ private ushort maxArmour;
+
+ private byte lungCapacity; //determines how long can the mob stay in the water before it "drowns"
+ private byte maxLungCapacity;
+
+ private string name;
+ private char body; //the body is the character that represents the mob
+ private ConsoleColor color;
+
+ private int xPos;
+ private int yPos;
+
+ public void Print() //prints the mob's char in it's corresponding position
+ {
+ Console.SetCursorPosition(XPos, YPos);
+ Console.ForegroundColor = Color;
+ Console.Write(Body);
+ }
+
+ public void PrintStats() //prints the mob's stats, i.e. health, armour, lung capacity, only used for player
+ {
+ Console.WriteLine();
+ Console.ForegroundColor = ConsoleColor.Gray;
+ Console.WriteLine($"Health: {Health} | Armour: {Armour} | {new string('o', LungCapacity)}");
+ }
+
+ public ushort Health
+ {
+ set { health = value; }
+ get { return health; }
+ }
+
+ public ushort MaxHealth
+ {
+ set { maxHealth = value; }
+ get { return maxHealth; }
+ }
+
+
+ public ushort Armour
+ {
+ set { armour = value; }
+ get { return armour; }
+ }
+
+ public ushort MaxArmour
+ {
+ set { maxArmour = value; }
+ get { return maxArmour; }
+ }
+
+
+ public byte LungCapacity
+ {
+ set { lungCapacity = value; }
+ get { return lungCapacity; }
+ }
+
+ public byte MaxLungCapacity
+ {
+ set { maxLungCapacity = value; }
+ get { return maxLungCapacity; }
+ }
+
+
+ public string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
+
+ public char Body
+ {
+ set { body = value; }
+ get { return body; }
+ }
+
+ public ConsoleColor Color
+ {
+ set { color = value; }
+ get { return color; }
+ }
+
+ public int XPos
+ {
+ set { xPos = value; }
+ get { return xPos; }
+ }
+
+ public int YPos
+ {
+ set { yPos = value; }
+ get { return yPos; }
+ }
+ }
+}
diff --git a/Bitspace/Bitspace/Program.cs b/Bitspace/Bitspace/Program.cs
new file mode 100644
index 0000000..80b73a6
--- /dev/null
+++ b/Bitspace/Bitspace/Program.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Game
+{
+ class Program
+ {
+ //collection of all biomes
+ private static Dictionary<string, Biome> biomeDict = new Dictionary<string, Biome>
+ {
+ { "Grass land", new Biome { Name = "Grass land",Floor = ',', Color = ConsoleColor.Green} },
+ { "Water", new Biome { Name = "Water",Floor = '-', Color = ConsoleColor.Blue } },
+ { "Rocks", new Biome { Name = "Rocks",Floor = '.', Color = ConsoleColor.Gray} }
+ };
+
+ //collection of all mobs
+ private static Dictionary<string, Mob> mobDict = new Dictionary<string, Mob>
+ {
+ { "Player", new Mob {Name = "Player", Color = ConsoleColor.White, Body = '@', MaxHealth = 100, Health = 100, MaxLungCapacity = 10, LungCapacity = 10} },
+ { "Smiley", new Mob {Name = "Smiley", Color = ConsoleColor.Magenta, Body = 'U', MaxHealth = 5, Health = 5, MaxLungCapacity = 5, LungCapacity = 5} },
+ { "Smiley1", new Mob {Name = "Smiley1", Color = ConsoleColor.Magenta, Body = 'U', MaxHealth = 5, Health = 5, MaxLungCapacity = 5, LungCapacity = 5} },
+ { "Smiley2", new Mob {Name = "Smiley2", Color = ConsoleColor.Magenta, Body = 'U', MaxHealth = 5, Health = 5, MaxLungCapacity = 5, LungCapacity = 5} }
+ };
+
+ static void Main(string[] args)
+ {
+ Console.BackgroundColor = ConsoleColor.Black;
+ Console.WriteLine("Please input map height (width will be double the number)");
+ int s = int.Parse(Console.ReadLine()); Console.CursorVisible = false;
+
+ string[] map = new string[s];
+ MapGenerate(map);
+
+ while (true)
+ {
+ ReWriteScreen(map);
+ Thread.Sleep(70);
+
+ if (Console.KeyAvailable) // checkes if the player has pressed any key
+ {
+ var keyPressed = Console.ReadKey().Key;
+
+ //changes player position depending on pressed key
+ switch (keyPressed)
+ {
+ case ConsoleKey.UpArrow: if (mobDict["Player"].YPos > 0) mobDict["Player"].YPos--; break;
+ case ConsoleKey.DownArrow: if (mobDict["Player"].YPos < map.Length - 1) mobDict["Player"].YPos++; break;
+ case ConsoleKey.LeftArrow: if (mobDict["Player"].XPos > 0) mobDict["Player"].XPos--; break;
+ case ConsoleKey.RightArrow: if (mobDict["Player"].XPos < map.Length * 2 - 1) mobDict["Player"].XPos++; break;
+ }
+ }
+
+ //chooses random movement for mobs (that arent player)
+ var rndDirection = new Random();
+ foreach (var mob in mobDict.Values.Where(m => m.Name != "Player"))
+ {
+ switch (rndDirection.Next(6))
+ {
+ case 1: if (mob.YPos > 0) mob.YPos--; break;
+ case 2: if (mob.YPos < map.Length - 1) mob.YPos++; break;
+ case 3: if (mob.XPos > 0) mob.XPos--; break;
+ case 4: if (mob.XPos < map.Length * 2 - 1) mob.XPos++; break;
+ case 5: break; //this is for the mob to do nothing, so it can just stay where it is
+ }
+ }
+
+ //damage-regeneation mechanism, at the moment you only get damaged in water, program crashes when player dies
+ for (int i = 0; i < mobDict.Count; i++)
+ {
+ var mob = mobDict.ElementAt(i).Value;
+
+ if (map[mob.YPos][0].Equals(biomeDict["Water"].Floor))
+ {
+ if (mob.LungCapacity > 0) mob.LungCapacity--;
+ else mob.Health--;
+ }
+ else
+ {
+ if (mob.LungCapacity < mob.MaxLungCapacity) mob.LungCapacity++;
+ if (mob.Health < mob.MaxHealth) mob.Health++;
+ }
+
+ if (mob.Health == 0) mobDict.Remove(mob.Name);
+ }
+ }
+ }
+
+ private static void MapGenerate(string[] map)
+ {
+ Random rnd = new Random();
+
+ //map is composed of rows and every row is a different biome
+ for (int i = 0; i < map.Length; i++)
+ {
+ Biome currBiome = biomeDict.ElementAt(rnd.Next(biomeDict.Count)).Value;
+
+ map[i] = new string(currBiome.Floor, map.Length * 2);
+ }
+ }
+
+ private static void ReWriteScreen(string[] map)
+ {
+ Console.Clear();
+
+ //Prints the map
+ for (int i = 0; i < map.Length; i++)
+ {
+ Console.ForegroundColor = biomeDict.Values.ToList().Find(x => x.Floor == map[i][0]).Color;
+ Console.WriteLine(map[i]);
+ }
+
+ //Prints mobs in their positions
+ foreach(var mob in mobDict.Values)
+ {
+ mob.Print();
+ }
+
+ //Prints the player status, i.e. health, armour, lung capacity (it's made with a string of "bubbles")
+ Console.SetCursorPosition(0, map.Length + 1);
+ mobDict["Player"].PrintStats();
+
+ Console.CursorVisible = false;
+ }
+ }
+}
diff --git a/Bitspace/Bitspace/Properties/AssemblyInfo.cs b/Bitspace/Bitspace/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f2d1094
--- /dev/null
+++ b/Bitspace/Bitspace/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Game")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Game")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9f5b200f-8c1e-4825-8115-34403e972fa0")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]