It's a
fake pixel editor, I'm using the idea for a small tile editor
// Project: TileEditor2
// Created: 20-07-20
SetErrorMode(2)
SetWindowTitle( "PixelEditor" )
SetWindowAllowResize( 1 ) // allow the user to resize the window
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 )
#constant PixelEditor_GRID_WIDTH = 256 // 16*16
#constant PixelEditor_GRID_HEIGHT = 256 // 16*16
#constant PixelEditor_COLORS_PALETTE = 256 // 256 colors available
SetWindowSize( PixelEditor_GRID_WIDTH, PixelEditor_GRID_HEIGHT, 0 )
SetVirtualResolution( PixelEditor_GRID_WIDTH, PixelEditor_GRID_HEIGHT ) // doesn't have to match the window
SetDisplayAspect( PixelEditor_GRID_WIDTH / PixelEditor_GRID_HEIGHT )
type tPixelEditor
grid as tPixelEditorTile[16,16]
endtype
type tPixelEditorTile
filled as integer
endtype
global x, y, tx, ty as integer
global PixelEditor as tPixelEditor
PixelEditor_Init()
do
PixelEditor_Update()
Sync()
loop
/**
* PixelEditor Functions
*/
function PixelEditor_Init()
for i = 0 to 15 step 1
for j = 0 to 15 step 1
PixelEditor.grid[i,j].filled = 0
next j
next i
endfunction
function PixelEditor_Update()
for i = 0 to 15 step 1
for j = 0 to 15 step 1
x1 = i * 16
y1 = j * 16
x2 = 16 * i + 16
y2 = 16 * j + 16
r = 255
g = 255
b = 255
color = 0xFF000000+(b<<16) + (g<<8) + r
DrawBox(x1, y1, x2, y2, color, color, color, color, PixelEditor.grid[i, j].filled)
next j
next i
if GetPointerState() = 1
x = GetPointerX()
y = GetPointerY()
tx = (x * 16) / PixelEditor_GRID_WIDTH
ty = (y * 16) / PixelEditor_GRID_HEIGHT
if tx > 16 or tx < 0 then exitfunction
if ty > 16 or ty < 0 then exitfunction
PixelEditor.grid[tx, ty].filled = 1
endif
endfunction
http://www.nyan.cat/index.php?cat=pirate