I am trying to use DrawBox/Line to draw a grid that will scale to varying resolutions.
So i Draw a box to cover the screens resolution and then draw lines across and down the screen then use GetImage() to create a sprite
Here's the problem;
It appears that drawing the lines doesn't draw a line but draws transparency through the box.
If you look at the code the lines should be
red but they end up being the colour of the background. It's very weird!
// Project: test59
// Created: 2019-07-10
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test59" )
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( 30, 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
grid = CreateGrid()
do
Print( ScreenFPS() )
Sync()
loop
function CreateGrid()
size as float
i as float
w as float
h as float
s as integer
img as integer
vh as float
vw as float
SetClearColor(0x70, 0x70, 0x70)
ClearScreen()
w = GetWindowWidth()
h = GetWindowHeight()
vw = GetVirtualWidth()
vh = GetVirtualHeight()
SetVirtualResolution(w, h)
size = w / 16
DrawBox(0, 0, w, h, 0x909090, 0x909090, 0x909090, 0x909090, 1)
for i=0 to w step size
DrawLine(i, 0, i, h, 0x0000ff, 0x0000ff)
next
for i=h to 0 step -size
DrawLine(0, i, w, i, 0x0000ff, 0x0000ff)
next
render()
img = GetImage(0, 0, w, h)
SetImageMinFilter( img, 0 )
SetImageMagFilter( img, 0 )
s = CreateSprite(img)
SetVirtualResolution(vw, vh)
SetSpriteSize(s, GetVirtualWidth(), GetVirtualHeight())
ClearScreen()
endfunction s