From 0b4278e9ee3a76cd8f3e1cb52a4b182018147b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A6=D1=8B=D1=80=D0=BA=D0=BE=D0=B2=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B9?= Date: Mon, 10 Oct 2016 21:31:00 +0300 Subject: [PATCH] First interactive things --- theGame/Game.cs | 23 +++++++++++++++ theGame/Item.cs | 21 +++++++++++++ theGame/PlayerCraft.cs | 12 ++++++++ theGame/Program.cs | 67 ++++++++++++++++++++++++++++++++++++++++++ theGame/theGame.csproj | 3 ++ 5 files changed, 126 insertions(+) create mode 100644 theGame/Game.cs create mode 100644 theGame/Item.cs create mode 100644 theGame/PlayerCraft.cs diff --git a/theGame/Game.cs b/theGame/Game.cs new file mode 100644 index 0000000..2cef6fa --- /dev/null +++ b/theGame/Game.cs @@ -0,0 +1,23 @@ +using System; +namespace theGame +{ + public class Game + { + public bool GameOver; + + private int hitCount; + + public PlayerCraft playerCraft; + + public Game() + { + this.GameOver = false; + + this.hitCount = 0; + + this.playerCraft = new PlayerCraft(); + playerCraft.positionX = 10; + playerCraft.positionY = 12; + } + } +} diff --git a/theGame/Item.cs b/theGame/Item.cs new file mode 100644 index 0000000..3a21234 --- /dev/null +++ b/theGame/Item.cs @@ -0,0 +1,21 @@ +using System; +namespace theGame +{ + public class Item + { + public int positionX; + public int positionY; + + public int sizeWidth; + public int sizeHeight; + + public Item() + { + sizeWidth = 0; + sizeHeight = 0; + + positionX = 0; + positionY = 0; + } + } +} diff --git a/theGame/PlayerCraft.cs b/theGame/PlayerCraft.cs new file mode 100644 index 0000000..d388804 --- /dev/null +++ b/theGame/PlayerCraft.cs @@ -0,0 +1,12 @@ +using System; +namespace theGame +{ + public class PlayerCraft : Item + { + int Health; + public PlayerCraft() + { + Health = 100; + } + } +} diff --git a/theGame/Program.cs b/theGame/Program.cs index 6d56fc2..b051f07 100644 --- a/theGame/Program.cs +++ b/theGame/Program.cs @@ -7,6 +7,73 @@ namespace theGame public static void Main(string[] args) { Console.WriteLine("Hello World!"); + Console.WriteLine("Hello World!"); + Console.WriteLine("Hello World!"); + + Game game = new Game(); + + System.Threading.Thread th = new System.Threading.Thread(GetKeys); + th.Start(game); + + while (game.GameOver != true) + { + System.Threading.Thread.Sleep(100); + + Console.SetWindowSize(80, 25); + Console.Clear(); + + for (int i = 0; i < 20; i++) + { + int lineNumber = i + 1; + bool line_printed = false; + + if (lineNumber == 1 || lineNumber == 20) + { + Console.WriteLine("|---"); + line_printed = true; + } + + if (game.playerCraft.positionY == i) + { + Console.WriteLine("| ###"); + line_printed = true; + } + + if (!line_printed) + { + Console.WriteLine("|"); + } + } + } + } + + public static void GetKeys(object game_object) + { + Game game = new Game(); + game.GameOver = true; + + if (game_object is Game) + { + game = (Game)game_object; + } + + ConsoleKeyInfo key_info = Console.ReadKey(true); + while (key_info.Key != ConsoleKey.Q) + { + + if (key_info.Key != ConsoleKey.UpArrow) + { + game.playerCraft.positionY += 1; + } + + if (key_info.Key != ConsoleKey.DownArrow) + { + game.playerCraft.positionY -= 1; + } + + key_info = Console.ReadKey(true); + } + game.GameOver = true; } } } diff --git a/theGame/theGame.csproj b/theGame/theGame.csproj index 4d6329b..482331d 100644 --- a/theGame/theGame.csproj +++ b/theGame/theGame.csproj @@ -34,6 +34,9 @@ + + + \ No newline at end of file