Adilol

Movement in C# -> needs to come to C++

Sep 6th, 2011
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Movements : Info
  10.     {
  11.         public void Action()
  12.         {
  13.  
  14.             //This cleans up player after it moves
  15.             Console.SetCursorPosition(x, y);
  16.             Console.Write("   ");
  17.             x = x + xspeed;
  18.             y = y + yspeed;
  19.  
  20.             //this is the control input from the player
  21.             if (Console.KeyAvailable)
  22.             {
  23.                 ConsoleKeyInfo Keyinfo = Console.ReadKey(true);
  24.                 switch (Keyinfo.Key)
  25.                 {
  26.                     case ConsoleKey.W:
  27.                         y = y - 1;
  28.                         figure = "^.^";
  29.                         break;
  30.                     case ConsoleKey.S:
  31.                         y = y + 1;
  32.                         figure = "v.v";
  33.                         break;
  34.                     case ConsoleKey.A:
  35.                         x = x - 1;
  36.                         figure = "<.<";
  37.                         break;
  38.                     case ConsoleKey.D:
  39.                         x = x + 1;
  40.                         figure = ">.>";
  41.                         break;
  42.                     case ConsoleKey.T:
  43.                         pla.Screen();
  44.                         break;
  45.                 }
  46.                 if (x > 77)
  47.                 {
  48.                     x = 77;
  49.                 }
  50.                 if (y >= 23)
  51.                 {
  52.                     y = 23;
  53.                 }
  54.                 if (x < 1)
  55.                 {
  56.                     x = 1;
  57.                 }
  58.                 if (y <= 4)
  59.                 {
  60.                     y = 4;
  61.                 }
  62.                 if (location == 3)
  63.                 {
  64.                     Random waten = new Random(DateTime.Now.Millisecond);
  65.                     Thread.Sleep(5);
  66.                     int we = waten.Next(1, 101);
  67.  
  68.                     Random fi = new Random();
  69.                     int n = fi.Next(1, 101);
  70.                     if (n <= 1)
  71.                     {
  72.                         Console.Clear();
  73.                         Console.SetCursorPosition(25, 11);
  74.                         Console.Write("An Enemy Stops you in your tracks!");
  75.                         Thread.Sleep(1500);
  76.                         Console.Clear();
  77.                         if (we <= 90)
  78.                         {
  79.                             fight = 4;
  80.                             bat.Battle();
  81.                         }
  82.                         else
  83.                         {
  84.                             fight = 1;
  85.                             bat.Battle();
  86.                         }
  87.                     }
  88.                 }
  89.  
  90.                 if (location == 4)
  91.                 {
  92.                     Random waten = new Random(DateTime.Now.Millisecond);
  93.                     Thread.Sleep(5);
  94.                     int we = waten.Next(1, 101);
  95.  
  96.                     Random fi = new Random();
  97.                     int n = fi.Next(1, 101);
  98.                     if (n <= 2)
  99.                     {
  100.                         Console.Clear();
  101.                         Console.SetCursorPosition(25, 11);
  102.                         Console.Write("An Enemy Stops you in your tracks!");
  103.                         Thread.Sleep(1500);
  104.                         Console.Clear();
  105.                         if (we <= 90)
  106.                         {
  107.                             fight = 1;
  108.                             bat.Battle();
  109.                         }
  110.                         else
  111.                         {
  112.                             fight = 2;
  113.                             bat.Battle();
  114.                         }
  115.                     }
  116.                 }
  117.             }
  118.  
  119.  
  120.  
  121.             //this draws the player on to screen
  122.             Console.SetCursorPosition(x, y);
  123.             Console.ForegroundColor = ConsoleColor.Green;
  124.             Console.Write(figure);
  125.             Console.ForegroundColor = ConsoleColor.White;
  126.  
  127.             //this controls game speed
  128.             Thread.Sleep(20);
  129.  
  130.             if (location == 5)
  131.             {
  132.                 Console.SetCursorPosition(1, 1);
  133.                 Console.WriteLine("Location: Stone City Gates     T. View Status     ");
  134.                 Console.Write("_____________________________________________________________________\n");
  135.  
  136.                 //draw inn
  137.                 Console.ForegroundColor = ConsoleColor.DarkGray;
  138.                 Console.SetCursorPosition(30, 4);
  139.                 Console.Write("Bad Omen Inn");
  140.                 Console.ForegroundColor = ConsoleColor.White;
  141.  
  142.                 //draw town square
  143.                 Console.ForegroundColor = ConsoleColor.Gray;
  144.                 Console.SetCursorPosition(4, 10);
  145.                 Console.Write("Town Square");
  146.                 Console.ForegroundColor = ConsoleColor.White;
  147.  
  148.                 //draw castle
  149.                 Console.ForegroundColor = ConsoleColor.Yellow;
  150.                 Console.SetCursorPosition(60, 10);
  151.                 Console.Write("Castle");
  152.                 Console.ForegroundColor = ConsoleColor.White;
  153.  
  154.                 //draw gates
  155.                 Console.ForegroundColor = ConsoleColor.Cyan;
  156.                 Console.SetCursorPosition(35, 20);
  157.                 Console.Write("Gates");
  158.                 Console.ForegroundColor = ConsoleColor.White;
  159.  
  160.             }
  161.  
  162.             if (location == 6)
  163.             {
  164.                 Console.SetCursorPosition(1, 1);
  165.                 Console.WriteLine("Location: Stone City's Square     T. View Status     ");
  166.                 Console.Write("_____________________________________________________________________\n");
  167.  
  168.                 //draw inn
  169.                 Console.SetCursorPosition(20, 6);
  170.                 Console.Write("Weapon Shop");
  171.  
  172.  
  173.                 Console.SetCursorPosition(20, 17);
  174.                 Console.Write("Armor Shop");
  175.  
  176.  
  177.                 Console.SetCursorPosition(50, 17);
  178.                 Console.Write("Magic Shop");
  179.  
  180.                 Console.SetCursorPosition(50, 6);
  181.                 Console.Write("Kosh's House");
  182.  
  183.                 Console.SetCursorPosition(70, 10);
  184.                 Console.Write("GO BACK");
  185.  
  186.             }
  187.  
  188.             if (location == 7)
  189.             {
  190.                 Console.SetCursorPosition(1, 1);
  191.                 Console.WriteLine("Location: Stone City's Castle     T. View Status     ");
  192.                 Console.Write("_____________________________________________________________________\n");
  193.  
  194.                 //draw inn
  195.                 Console.SetCursorPosition(40, 7);
  196.                 Console.Write("Castle");
  197.  
  198.  
  199.                 Console.SetCursorPosition(1, 7);
  200.                 Console.Write("G\n O\n\n B\n A\n C\n K");
  201.             }
  202.  
  203.  
  204.             if (location == 4)
  205.             {
  206.                 Console.SetCursorPosition(1, 1);
  207.                 Console.WriteLine("Location: Cave Moor     T. View Status     ");
  208.                 Console.Write("_____________________________________________________________________\n");
  209.  
  210.                 //this draws man
  211.                 if (killedman == 0)
  212.                 {
  213.                     Console.SetCursorPosition(4, 10);
  214.                     Console.Write("Misterious Man");
  215.                 }
  216.                 if (killedman == 1 & openedchest == 0)
  217.                 {
  218.                     Console.SetCursorPosition(4, 10);
  219.                     Console.Write("Chest");
  220.                 }
  221.                 if (questsemicompleted5 == 1 & killedguard == 0)
  222.                 {
  223.                     Console.SetCursorPosition(35, 5);
  224.                     Console.Write("Guard");
  225.                 }
  226.                 Console.SetCursorPosition(65, 11);
  227.                 Console.Write("go back");
  228.  
  229.  
  230.             }
  231.             if (location == 3)
  232.             {
  233.                 //this draws HUD
  234.                 Console.SetCursorPosition(1, 1);
  235.                 Console.WriteLine("Location: South-East Warren     T. View Status     ");
  236.                 Console.Write("_____________________________________________________________________\n");
  237.  
  238.                 //this draws cave moor
  239.  
  240.                 Console.ForegroundColor = ConsoleColor.DarkCyan;
  241.                 Console.SetCursorPosition(1, 15);
  242.                 ma.LocationNames();
  243.                 Console.Write(cavemoorname);
  244.                 Console.ForegroundColor = ConsoleColor.White;
  245.  
  246.                 //this draws stone city
  247.                 Console.ForegroundColor = ConsoleColor.Yellow;
  248.                 Console.SetCursorPosition(20, 4);
  249.                 ma.LocationNames();
  250.                 Console.Write(stonecityname);
  251.                 Console.ForegroundColor = ConsoleColor.White;
  252.  
  253.                 //this draws shang
  254.                 Console.ForegroundColor = ConsoleColor.Cyan;
  255.                 Console.SetCursorPosition(60, 14);
  256.                 Console.Write("Shang City");
  257.                 Console.ForegroundColor = ConsoleColor.White;
  258.  
  259.             }
  260.             if (location == 1)
  261.             {
  262.                 //this draws HUD
  263.                 Console.SetCursorPosition(1, 1);
  264.                 Console.WriteLine("Location: Shang Gates     T. View Status");
  265.                 Console.Write("_____________________________________________________________________\n");
  266.  
  267.  
  268.                 //this draws gates
  269.                 Console.SetCursorPosition(1, 15);
  270.                 Console.ForegroundColor = ConsoleColor.Cyan;
  271.                 Console.Write("Gates");
  272.                 Console.ForegroundColor = ConsoleColor.White;
  273.  
  274.                 //this draws gatekeeper
  275.                 Console.SetCursorPosition(1, 7);
  276.                 Console.ForegroundColor = ConsoleColor.Yellow;
  277.                 Console.Write("Gatekeeper");
  278.                 Console.ForegroundColor = ConsoleColor.White;
  279.  
  280.                 //this draws town square
  281.                 Console.SetCursorPosition(60, 10);
  282.                 Console.ForegroundColor = ConsoleColor.Gray;
  283.                 Console.Write("Town Square");
  284.                 Console.ForegroundColor = ConsoleColor.White;
  285.             }
  286.  
  287.             if (location == 2)
  288.             {
  289.                
  290.                 //this draws HUD
  291.                 Console.SetCursorPosition(1, 1);
  292.                 Console.WriteLine("Location: Shang's Town Square     T. View Status");
  293.                 Console.Write("_____________________________________________________________________");
  294.  
  295.                 //this draws go back
  296.                 Console.SetCursorPosition(1, 7);
  297.                 Console.Write("G\n O\n\n B\n A\n C\n K");
  298.  
  299.  
  300.                 //this draws generalstore
  301.                 Console.SetCursorPosition(5, 4);
  302.                 Console.ForegroundColor = ConsoleColor.Gray;
  303.                 Console.Write("General Store");
  304.                 Console.ForegroundColor = ConsoleColor.White;
  305.  
  306.                 //this draws weapon shop
  307.                 Console.SetCursorPosition(30, 4);
  308.                 Console.ForegroundColor = ConsoleColor.Red;
  309.                 Console.Write("Weapon shop");
  310.                 Console.ForegroundColor = ConsoleColor.White;
  311.  
  312.                 //this draws armor shop
  313.                 Console.SetCursorPosition(50, 4);
  314.                 Console.ForegroundColor = ConsoleColor.White;
  315.                 Console.Write("Armor Shop");
  316.  
  317.                 //this draws pawnshop
  318.                 Console.SetCursorPosition(20, 20);
  319.                 Console.ForegroundColor = ConsoleColor.Gray;
  320.                 Console.Write("Pawn Shop");
  321.                 Console.ForegroundColor = ConsoleColor.White;
  322.  
  323.  
  324.                 //this draws sun's inn
  325.                 Console.SetCursorPosition(50, 12);
  326.                 Console.ForegroundColor = ConsoleColor.Yellow;
  327.                 Console.Write("Sun's Inn");
  328.                 Console.ForegroundColor = ConsoleColor.White;
  329.             }
  330.         }
  331.     }
  332. }
Advertisement
Add Comment
Please, Sign In to add comment