473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

VB.Net and Slow Console

Hello. I'm writing roguelike using VB.NET. It has very slow
console output. Is there any methods to make it work faster?

For example,

Sub PlaceAt(ByVal s As String, ByVal x As Integer, ByVal y As
Integer)
Console.SetCursorPosition(x, y)
Console.Write(s)
End Sub

Sub Setcolor(ByVal fg, ByVal bg)
Console.ForegroundColor = fg
Console.BackgroundColor = bg
End Sub

For I = 0 To mapwidth
For J = 0 To mapheight
Setcolor(ConsoleColor.DarkBlue, ConsoleColor.Blue)
PlaceAt(things(map(I, J)).image, I, J)
Next
Next

When mapwidth=80 and mapheight=25 (standard console) screen fills with
coloured symbols in 2 seconds or more (Vista/XP). Is there workaround?
Jun 27 '08 #1
5 1439
Amzin wrote:
Hello. I'm writing roguelike using VB.NET. It has very slow
console output. Is there any methods to make it work faster?

For example,

Sub PlaceAt(ByVal s As String, ByVal x As Integer, ByVal y As
Integer)
Console.SetCursorPosition(x, y)
Console.Write(s)
End Sub

Sub Setcolor(ByVal fg, ByVal bg)
Console.ForegroundColor = fg
Console.BackgroundColor = bg
End Sub

For I = 0 To mapwidth
For J = 0 To mapheight
Setcolor(ConsoleColor.DarkBlue, ConsoleColor.Blue)
PlaceAt(things(map(I, J)).image, I, J)
Next
Next

When mapwidth=80 and mapheight=25 (standard console) screen fills with
coloured symbols in 2 seconds or more (Vista/XP). Is there workaround?
Doesn't the console remember the color for more than one write? Move the
setting of the color outside the loop:

Setcolor(ConsoleColor.DarkBlue, ConsoleColor.Blue)
For I = 0 To mapwidth
For J = 0 To mapheight
PlaceAt(things(map(I, J)).image, I, J)
Next
Next

Then perhaps putting together a string for a complete line instead of
writing each character by themselves:

Setcolor(ConsoleColor.DarkBlue, ConsoleColor.Blue)
For J = 0 To mapheight
Dim line As New Char(mapwidth - 1)
For I = 0 To mapwidth
line(I) = things(map(I, J)).image.Chars(0)
Next
PlaceAt(New String(line), 0, J)
Next
--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #2
On 9 июн, 02:53, Göran Andersson <gu...@guffa.comwrote:
Doesn't the console remember the color for more than one write? Move the
setting of the color outside the loop:
Hello, Goran!
It not the case, unfortunately. My real application needs different
colors in each cell or like that - thats why I did insert colouring
into the inner cycle.
Jun 27 '08 #3
Amzin,

As the solution from Goran or things like that are not possible, then I
assume that you have to accept that you are doing something that needs an
extreme fast (expensive) video board to get a little bit more speed.

You ask for a solution for the speed and then you start to give all kind of
other obstructions which have nothing to do with your first question.

-Cor

"Amzin" <no*****@gmail.comschreef in bericht
news:ee**********************************@79g2000h sk.googlegroups.com...
On 9 июн, 02:53, Göran Andersson <gu...@guffa.comwrote:
Doesn't the console remember the color for more than one write? Move the
setting of the color outside the loop:
Hello, Goran!
It not the case, unfortunately. My real application needs different
colors in each cell or like that - thats why I did insert colouring
into the inner cycle.

Jun 27 '08 #4
On 9 ÉÀÎ, 08:12, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nlwrote:
Amzin,

As the solution from Goran or things like that are not possible, then I
assume that you have to accept that you are doing something that needs an
extreme fast (expensive) video board to get a little bit more speed.
Nevermind and thank you for your post. When I was using Qbasic any
text output was smooth and fast. My video card was very slow in those
times. As I can see Console class itself IS extremely slow. I'm trying
to use WinApi now instead.

Thank you.
Jun 27 '08 #5
Amzin wrote:
When I was using Qbasic any
text output was smooth and fast. My video card was very slow in those
times. As I can see Console class itself IS extremely slow. I'm trying
to use WinApi now instead.
Console output is always slow, and has always been. I am pretty sure
that what QBasic did to get fast output was to circumvent the console
(the standard output stream), and write directly to video memory. I know
that Turbo Pascal used that method.

--
Go"ran Andersson
_____
http://www.guffa.com
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim W | last post by:
This is a cross-post from the .NET group since it looks like it may not be ..NET. New information since the original post is that is the wireless network is enabled and connected the socket...
0
by: F. Hall | last post by:
If I read a bitmap image from one file and save it to another the save operation is slow unless I draw on the image. In other words, Image inputImage = Image.FromFile( @"c:\temp\source.bmp" );...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
11
by: Brett | last post by:
Hi. I wrote a program in C that spends most of its time doing integer arithmetic (on a data set loaded at run time), with a negligible amount of I/O. I compiled it with lcc-win32 as a console...
11
by: nico | last post by:
Hello I have write this program that retrieve all directory and subdirectory recursively of a given directory given in parameter. For each directory, the script find all user permission for the...
29
by: Roy Gourgi | last post by:
Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than...
5
by: Jim W | last post by:
I have an ASP.NET app that has very slow connect times using TCPClient, or the Socket class, or even calling a COM object that uses C socket calls on certain similar XP SP2 boxes. On those...
0
by: selvialagar | last post by:
i did a program in vc++.net for ICMP communication using sockets.But when i execute it i received a very slow response...is there any configuration to be made on the server..or any other thing?.. i...
12
by: Eps | last post by:
Hi there, I am doing the following, this is a List of audio files. this.Where(p =p.Album == AnAudioFileObject.Album).Select(s => s.Artist).Distinct().Count() 1; The aim is to determine...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.