diff options
| author | jussi | 2022-02-18 18:27:10 +0200 |
|---|---|---|
| committer | jussi | 2022-02-18 18:27:10 +0200 |
| commit | 6e4fdd3b3ae4e4656e151f098c40cfe551a36e8c (patch) | |
| tree | 37e30d371ebd44dfc8bab0d33c26f0294bda5ae4 /examples/pixelated/main.lua | |
| parent | 345cc1d5aa3b3c97e2cce453dc65a62c3e05427b (diff) | |
| download | reilua-enhanced-6e4fdd3b3ae4e4656e151f098c40cfe551a36e8c.tar.gz reilua-enhanced-6e4fdd3b3ae4e4656e151f098c40cfe551a36e8c.tar.bz2 reilua-enhanced-6e4fdd3b3ae4e4656e151f098c40cfe551a36e8c.zip | |
Added initial files.
Diffstat (limited to 'examples/pixelated/main.lua')
| -rw-r--r-- | examples/pixelated/main.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/pixelated/main.lua b/examples/pixelated/main.lua new file mode 100644 index 0000000..c0de666 --- /dev/null +++ b/examples/pixelated/main.lua @@ -0,0 +1,55 @@ +local tex = -1 +local pos = { 32, 32 } +local speed = 60.0 +local sound = -1 +local monitor = 0 +local mPos = RL_GetMonitorPosition( monitor ) +local mSize = RL_GetMonitorSize( monitor ) +local framebuffer = -1 +local res = { 320, 180 } +local scale = 5 +local winSize = { res[1] * scale, res[2] * scale } + +function init() + RL_SetWindowState( FLAG_WINDOW_RESIZABLE ) + RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } ) + RL_SetWindowSize( winSize ) + tex = RL_LoadTexture( RL_GetBasePath().."../resources/images/cat.png" ) + -- Create framebuffer. + framebuffer = RL_LoadRenderTexture( res ) +end + +function process( delta ) + if RL_IsKeyDown( KEY_RIGHT ) then + pos[1] = pos[1] + delta * speed + elseif RL_IsKeyDown( KEY_LEFT ) then + pos[1] = pos[1] - delta * speed + end + + if RL_IsKeyDown( KEY_UP ) then + pos[2] = pos[2] - delta * speed + elseif RL_IsKeyDown( KEY_DOWN ) then + pos[2] = pos[2] + delta * speed + end + + if RL_IsWindowResized() then + winSize = RL_GetWindowSize() + end +end + +function draw() + RL_ClearBackground( { 0, 0, 0 } ) + + RL_BeginTextureMode( framebuffer ) + RL_ClearBackground( { 100, 150, 100 } ) + RL_DrawPixel( { 100, 100 }, { 255, 50, 100 } ) + RL_DrawLine( { 120, 100 }, { 140, 150 }, 2.4, { 255, 150, 255 } ) + RL_DrawRectangle( { 200, 120, 40, 50 }, { 100, 170, 255 } ) + RL_DrawTexturePro( tex, { 166, 138, 128, 128 }, { pos[1], pos[2], 128, 128 }, { 16, 16 }, 0.0, WHITE ) + RL_DrawText( 0, "Cat MIAU!!", { 16, 32 }, 10, 1, { 255, 180, 155 } ) + RL_EndTextureMode() + + RL_SetTextureSource( TEXTURE_SOURCE_RENDER_TEXTURE ) + RL_DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, { 255, 255, 255 } ) + RL_SetTextureSource( TEXTURE_SOURCE_TEXTURE ) +end |
