You're approaching this from the wrong angle anyway.
What you need to do with a console and plotting characters is different than the way you're used to with graphical screens.
For instance your 2d-gfx rendering loop would be like so:
Code: Select all
Repeat
flipbuffers()
clearscreen()
;loop through and draw everything
drawtext(....
drawsprite(...
delay(5)
Forever
But with a console thats very inefficient and pointless. What you do is if you need a change, track those changes and immediately draw that change. You have no 'rendering loop' persay.
You just clear the character you need to update by locating, then printing a space. Or you just print the character that it needs to be changed to if its not being cleared.
Example:
Code: Select all
Repeat
if inkey()="J" ;move left
consolelocate(playerx,playery)
print(" ") ;clear old position
playerx - 1
consolelocate(playerx,playery)
print("P") ;draw new pos
elseif inkey()="L" ;move right
consolelocate(playerx,playery)
print(" ") ;clear old position
playerx + 1
consolelocate(playerx,playery)
print("P") ;draw new pos
endif
delay(5)
Forever
[edit]
Also, if you really need to draw the way you are thinking then you should buffer the drawing. For example:
Code: Select all
Protected X.c, Y.c
For Y.c = 0 To #Console_Height
buf.s=""
For X.c = 0 To #Console_Width
if X = #Console_Width
buf + Console(X.c, Y.c)\Char
ConsoleLocate(0, Y.c)
Print(Chr(Console(X.c, Y.c)\Char.c))
else
buf + Console(X.c, Y.c)\Char
endif
Next
Next
This would need more consideration to handle colors but should be a similar piece of code. You should not run this code in a 'rendering loop' either. You still will want to track changes.
Also consider making a macro to handle color changes and location and printing all in one step. You may want to add code to see if the color needs changing and only call ConsoleColor if the color is different:
Code: Select all
Macro PrintChar(string,x,y,color)
ConsoleColor(color)
ConsoleLocate(x,y)
Print(string)
EndMacro
Macro PrintCharAndClear(string,x,y,color,oldx,oldy)
ConsoleColor(color)
Consolelocate(oldx,oldy)
print(" ")
ConsoleLocate(x,y)
Print(string)
EndMacro