[問題] 請問console速度

看板C_Sharp作者 (╴△╴)時間15年前 (2011/03/21 14:34), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
剛學C# 想在console裡作一行行掃描下來的純文字圖像遊戲 可是速度很慢不知有甚麼改善方法?? 感謝@@ ====================== using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("please input the key control for 上:"); System.ConsoleKeyInfo a = Console.ReadKey(); Console.WriteLine("key for 下:"); System.ConsoleKeyInfo b = Console.ReadKey(); Console.WriteLine("key for 左:"); System.ConsoleKeyInfo c = Console.ReadKey(); Console.Write("key for 右:"); System.ConsoleKeyInfo d = Console.ReadKey(); int t = 1; int j = 10; int i = 10; int h = 22; int w = 77; string[,] map = new string[w, h]; for (int y = 0; y <= h - 1; y++) { for (int x = 0; x <= w - 1; x++) { map[x, y] = " "; } } string[,] screen= map; screen[i, j] = "囧"; for (int y = 0; y <= j; y++) { Console.WriteLine(); for (int x = 0; x <= i; x++) { Console.Write(screen[x, y]); } } screen= map; while (t >= 0) {screen= map; ConsoleKeyInfo z = Console.ReadKey(); if (z == a) { j = j - 1; if (j >= 24) { j = 0; } screen[i, j] = "囧"; screen[i, j-1] = "大"; for (int y = 0; y <= j; y++) { Console.WriteLine(); for (int x = 0; x <= i; x++) { Console.Write(screen[x, y]); } } } else if (z == b) { j++; if (j == -2) { j = 22; } screen[i, j] = "囧"; screen[i, j - 1] = "大"; for (int y = 0; y <= j; y++) { Console.WriteLine(); for (int x = 0; x <= i; x++) { Console.Write(screen[x, y]); } } } else if (z == c) { i = i - 1; if (i == -1) { i = w; } screen[i, j] = "囧"; screen[i, j - 1] = "大"; for (int y = 0; y <= j; y++) { Console.WriteLine(); for (int x = 0; x <= i; x++) { Console.Write(screen[x, y]); } } } else if (z == d) { i++; if (i == w + 1) { i = 0; } screen[i, j] = "囧"; screen[i, j - 1] = "大"; for (int y = 0; y <= j; y++) { Console.WriteLine(); for (int x = 0; x <= i; x++) { Console.Write(screen[x, y]); } } } else { Console.WriteLine("erro"); } t++; } } } } ============ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.192 ※ 編輯: ofz 來自: 140.112.4.192 (03/21 14:48)

03/21 15:48, , 1F
一個文字畫面全部畫完了(在buffer),再一次貼到console.
03/21 15:48, 1F
※ 編輯: ofz 來自: 140.112.4.181 (03/22 19:59)
文章代碼(AID): #1DXl5rkm (C_Sharp)