VB.Net and Slow Console

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amzin

    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.SetCurs orPosition(x, y)
    Console.Write(s )
    End Sub

    Sub Setcolor(ByVal fg, ByVal bg)
    Console.Foregro undColor = fg
    Console.Backgro undColor = bg
    End Sub

    For I = 0 To mapwidth
    For J = 0 To mapheight
    Setcolor(Consol eColor.DarkBlue , ConsoleColor.Bl ue)
    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?
  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: VB.Net and Slow Console

    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.SetCurs orPosition(x, y)
    Console.Write(s )
    End Sub
    >
    Sub Setcolor(ByVal fg, ByVal bg)
    Console.Foregro undColor = fg
    Console.Backgro undColor = bg
    End Sub
    >
    For I = 0 To mapwidth
    For J = 0 To mapheight
    Setcolor(Consol eColor.DarkBlue , ConsoleColor.Bl ue)
    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(Consol eColor.DarkBlue , ConsoleColor.Bl ue)
    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(Consol eColor.DarkBlue , ConsoleColor.Bl ue)
    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
    _____
    Göran Anderssons privata hemsida.

    Comment

    • Amzin

      #3
      Re: VB.Net and Slow Console

      On 9 июн, 02:53, Göran Andersson <gu...@guffa.co mwrote:
      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.

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: VB.Net and Slow Console

        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" <nonamer@gmail. comschreef in bericht
        news:ee57a0d6-5d8a-44f1-bdaf-45ba62b62cb5@79 g2000hsk.google groups.com...
        On 9 июн, 02:53, Göran Andersson <gu...@guffa.co mwrote:
        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.

        Comment

        • Amzin

          #5
          Re: VB.Net and Slow Console

          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.

          Comment

          • =?KOI8-R?Q?Go=22ran_Andersson?=

            #6
            Re: VB.Net and Slow Console

            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
            _____
            Göran Anderssons privata hemsida.

            Comment

            Working...