Advertisement
saluxx

not done

Oct 3rd, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication12
  8. {
  9. class Program
  10. {
  11. public static int x = 77; //Vi kommer använda de här variablerna för att uppdatera spelarens verision
  12. public static int y = 22;
  13. public static int x1 = 2;
  14. public static int y1 = 2;
  15. public static int point = 0;
  16. public static Random rnd = new Random();
  17. public static int position = rnd.Next(1, 4);
  18.  
  19. //När man gör något public static gör man så att man kan komma åt och ändra värdena på dessa variabler ifrån andra ställen.
  20.  
  21.  
  22. public static string player = ("☺");
  23. public static string enemy = ("☠");
  24.  
  25.  
  26. public static ConsoleKeyInfo tangent;
  27. static void Main(string[] args)
  28. {
  29. Console.ForegroundColor = ConsoleColor.Yellow;
  30. Ritautspelaren();
  31. Ritautenemy();
  32. while (0 < 100)
  33. {
  34. Flyttaspelaren(); // här skriver jag en funktion för att flytta min spelare
  35. Attack();
  36. Map();
  37. Ritautspelaren(); // här gör jag en funktion som ritar ut spelaren efter den har flyttats
  38. Ritautenemy();
  39.  
  40.  
  41.  
  42. }
  43. }
  44. public static void Flyttaspelaren()
  45. {
  46. tangent = Console.ReadKey();
  47.  
  48. // Här inne kommer jag ha koden för att flytta min spelare
  49. //För att kunna komma åt min position alltså mitt X och Y måste jag göra dessa public static
  50. if (100 > 0)
  51. {
  52. if (tangent.Key == ConsoleKey.A)
  53. {
  54. x--;
  55. }
  56. else if (tangent.Key == ConsoleKey.D)
  57. {
  58. x++;
  59. }
  60. else if (tangent.Key == ConsoleKey.W)
  61. {
  62. y--;
  63. }
  64. else if (tangent.Key == ConsoleKey.S)
  65. {
  66. y++;
  67. }
  68. else if (tangent.Key == ConsoleKey.UpArrow)
  69. {
  70. y1--;
  71. }
  72. else if (tangent.Key == ConsoleKey.DownArrow)
  73. {
  74. y1++;
  75. }
  76. else if (tangent.Key == ConsoleKey.LeftArrow)
  77. {
  78. x1--;
  79. }
  80. else if (tangent.Key == ConsoleKey.RightArrow)
  81. {
  82. x1++;
  83. }
  84.  
  85. }
  86. else
  87. {
  88. }
  89. if (x == 1)
  90. {
  91. x = 2;
  92. }
  93. else if (y == 1)
  94. {
  95. y = 2;
  96. }
  97. else if (x == 78)
  98. {
  99. x = 77;
  100. }
  101. else if (y == 23)
  102. {
  103. y = 22;
  104. }
  105. else if (x1 == 1)
  106. {
  107. x1 = 2;
  108. }
  109. else if (y1 == 1)
  110. {
  111. y1 = 2;
  112. }
  113. else if (x1 == 78)
  114. {
  115. x1 = 77;
  116. }
  117. else if (y1 == 23)
  118. {
  119. y1 = 22;
  120. }
  121.  
  122. }
  123.  
  124.  
  125.  
  126. public static void Map()
  127. {
  128. Console.SetCursorPosition(0, 0);
  129. Console.WriteLine("A");
  130. }
  131.  
  132. public static void Attack()
  133. {
  134.  
  135. if (x == x1 && y == y1)
  136. {
  137.  
  138. x = 79;
  139. y = 23;
  140. x1 = 0;
  141. y1 = 0;
  142. point = 1;
  143. Console.WriteLine(point);
  144. }
  145.  
  146. }
  147. private static void Ritautspelaren()
  148. {
  149. Console.Clear();
  150. Console.SetCursorPosition(x, y);
  151. Console.ForegroundColor = ConsoleColor.Green;
  152. Console.Write(player);
  153. Console.ResetColor();
  154. }
  155.  
  156.  
  157. private static void Ritautenemy()
  158. {
  159. Console.SetCursorPosition(x1, y1);
  160. Console.ForegroundColor = ConsoleColor.Red;
  161. Console.WriteLine(enemy);
  162. Console.ResetColor();
  163.  
  164.  
  165. }
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement