Hey fellas,
I've attached a win32 and win64 Console plugin for AGK2, as I have not managed to find one.
This Plugin can open a console window in win32 applications in order to write stuff:
Nice for debugging, if you do not want to bloat your render screen with text and print.
You are also able to write chars to a specific area in the console,
so you can build some serious debug screens with updating values.
Version 1.0 (x32)
Download:
https://forum.thegamecreators.com/attachment/82639
Version 1.1 (x32)
Download:
https://forum.thegamecreators.com/attachment/82644
Version 1.2 (x64 support from here on)
Download:
https://forum.thegamecreators.com/attachment/82649
Version 1.3 (console handle commands)
Download:
https://forum.thegamecreators.com/attachment/82681
The command set:
Console.Init(int MaxLines,CloseableFlag) - initialize the console in agk - Maxlines: maxial lines in the console to be shown
Console.SetTitle(String$) - set a title for the console
Console.SetColor(int color) - set text color (0-255)
Console.Clear() - similar to cls, can also apply the background color, when setColor is used
Console.SetString(int px, int py,String$) - set a specific text on a specific position in the console
Console.PrintCon(String$) - writes a string to the console
Console.SetSize(x,y) - Sets the console window size, as far as windows lets you
Console.SetVisible(state) - toggles console visibility
Console.Version() - prints the version of this plugin to console
Console.SetPosition(x,y) - Sets the console window position
Console.SetBufferSize(x,y) - Sets the console buffer size
Console.Close() - closes the console
Console.SetHandle(int) - Sets console handle to write to
int = Console.GetHandle() - Get current console handle
I am trying to keep it as simple as possible, in order to port it to all possible platforms later on.
Maybe I could also do a mac and linux version aswell.
It can be as easy as:
Quote: "
#import_plugin Console
Console.Init(20,0)
do
Console.SetString(1,1,"FPS: "+str(ScreenFPS(),4))
sync()
loop
"
to add a console.
Example Code (1.0):
#import_plugin Console
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ConsolePlugin" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
Console.Init(30)
Console.SetTitle("Console")
line as integer
tick as integer
// this will set a new color and update the whole screen in order to apply it
Console.SetColor(46)
Console.Clear()
maxtick=600
Console.SetChar(1,2,"Soon the regular example starts, be prepared")
do
if GetRawKeyState(27)
Console.SetChar(1,1,"Yes. Now its pressed ")
else
Console.SetChar(1,1,"[ESC] key pressed? No, not yet")
endif
Console.SetChar(54,2,str(tick)+"/"+str(maxtick))
inc tick
if GetRawKeyPressed(13) then Console.Clear()
if tick>maxtick
maxtick=60
inc line
color = mod(line,255)
Console.SetColor(color)
Console.PrintCon("")
Console.PrintCon("Multi color Console Output in AGK for Windows x32")
Console.PrintCon("Made by Jack - alex04.schmidt@gmail.com Line: "+str(line*4-1) + " color: "+str(color))
Console.PrintCon("")
tick = 0
endif
Print( ScreenFPS() )
Sync()
loop
Example Code (1.1 and later):
// Project: ConsolePlugin
// Created: 21.10.2018
#import_plugin Console // load console plugin
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ConsolePlugin" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// dumb count system
line as integer
tick as integer
maxtick=800
// console commands:
Console.Init(20,0) // maximal 100 lines, no window close option
Console.SetTitle("Console")
Console.SetColor(46) // sets bg to green and text to yellow
Console.Clear() // clear sreen and apply color sheme
Console.SetString(0,1,"====================================================================") // some static text
Console.SetString(1,4,"Soon the color text routine starts, be prepared") // some static text
Console.Version() // print console Version to console
Console.SetSize(80,20) // set custom console size, as far as you can push it, limits are very strict
Console.SetBufferSize(80,18) // set custom console buffer size
do
if GetRawKeyPressed(32) // Press SPACE to toggle console visibility
s=1-s
Console.SetVisible(s)
endif
if line<1 // initial 'static console'
if GetRawKeyState(27) // Press ESC Key to toggle display text
Console.SetString(1,3,"[ESC] Yes. Now its pressed äüö") // overwrite previous used chars by using space key
else
Console.SetString(1,3,"[ESC] key pressed? No, not yet ")
endif
Console.SetString(57,4,str(tick)+" / "+str(maxtick)) // continous update
Console.SetString(57,3,"FPS: "+str(ScreenFPS(),3)) // continous update
endif
if GetRawKeyPressed(13) then Console.Clear() // clear console by pressing ENTER
inc tick
if tick>maxtick
maxtick=60
inc line
color = mod(line,255)
Console.SetColor(color)
Console.PrintCon("")
Console.PrintCon("Multi color Console Output in AGK for Windows x32")
Console.PrintCon("Made by Jack - alex04.schmidt@gmail.com Line: "+str(line*4-1) + " color: "+str(color))
Console.PrintCon("")
tick = 0
endif
Print( ScreenFPS() )
Sync()
loop
quit:
Console.Close() // closes a console, frees allocation
end
return
Enjoy!
Please report any bugs or feature requests here.