class module_Basic
{
Screen = null;
INKEY = [] ;
locate = 0;
Dispose()
{
this.Screen.Dispose();
}
constructor()
{
this.Screen = new Screen(Z_BASIC);
this.pen(1);
}
cls()
{
this.Screen.ctx.clearRect(0, 0, this.Screen.canvas.width, this.locate);
this.locate = 0 ;
}
pen(color)
{
let rgba = µB.$Config.Color2Hex(color);
this.Screen.ctx.fillStyle = rgba ;
this.Screen.ctx.strokeStyle = rgba ;
}
print(text)
{
if( (this.locate+this.Screen.line_height) > this.Screen.height )
{ this.Screen.Clear();
this.locate = 0;
}
this.Screen.ctx.fillText(text, 32, this.locate) ;
this.locate += this.Screen.line_height ;
}
trace(text)
{
General.Trace(text) ;
}
timer()
{
return new Date().getTime()/1000;
}
microtimer()
{
return performance.now();
}
hours()
{ return new Date().getHours();
}
minutes()
{ return new Date().getMinutes();
}
seconds()
{ return new Date().getSeconds();
}
hex(color)
{
let re = 0 ;
if( typeof color == 'string' && color.substring(0,1) == "#" )
{ re = parseInt(color.substring(1),16);
}
else if( ! isNaN(color) )
{ re = color * 1 ;
}
return isNaN(re) ? 0 : re ;
}
key(code)
{
return this.INKEY[code];
}
format_microtime(timer)
{
return this.format_time(timer,true);
}
format_time(timer, display_ms)
{
let seconds = Math.floor(timer) ;
let mn = Zero(Math.floor(seconds/60),2);
let ss = Zero(seconds % 60,2);
if( display_ms )
{ let milli = timer - seconds ;
ss += "." + Zero(Math.round(milli*100));
}
return mn + ":" + ss ;
}
};