local Q=require("\114\097\121\108\105\098")local z=512 local p=512 local U=32 local j=32 Q.SetTraceLogLevel(Q.LOG_WARNING)Q.SetConfigFlags(Q.FLAG_VSYNC_HINT)Q.InitWindow(z,p,"\109\121 \051\050\120\051\050 \103\097\109\101\047\100\101\109\111")local W=Q.LoadRenderTexture(U,j)Q.SetTextureFilter(W.texture,Q.TEXTURE_FILTER_POINT)Q.SetTargetFPS(60)while not Q.WindowShouldClose()do local z=math.min(Q.GetScreenWidth()/U,Q.GetScreenHeight()/j)Q.BeginDrawing()Q.BeginTextureMode(W)Q.ClearBackground(Q.WHITE)Q.DrawTextEx(Q.GetFontDefault(),"\072\101\108\108\111",Q.Vector2(4,0),(Q.GetFontDefault()).baseSize,1,Q.Color(0,64,255,255))Q.DrawTextEx(Q.GetFontDefault(),"\105\116\'\115",Q.Vector2(8,10),(Q.GetFontDefault()).baseSize,1,Q.Color(0,64,255,255))Q.DrawTextEx(Q.GetFontDefault(),"\114\097\121\108\117\097",Q.Vector2(0,20),(Q.GetFontDefault()).baseSize,1,Q.Color(0,64,255,255))Q.EndTextureMode()Q.DrawTexturePro(W.texture,Q.Rectangle(0,0,W.texture.width,-W.texture.height),Q.Rectangle((Q.GetScreenWidth()-U*z)*.5,(Q.GetScreenHeight()-j*z)*.5,U*z,j*z),Q.Vector2(0,0),0,Q.WHITE)for z=0,Q.GetScreenWidth(),16 do Q.DrawRectangle(z,0,4,Q.GetScreenHeight(),Q.BLACK)end for z=0,Q.GetScreenHeight(),16 do Q.DrawRectangle(0,z,Q.GetScreenWidth(),4,Q.BLACK)end Q.EndDrawing()end Q.UnloadRenderTexture(W)Q.CloseWindow()
--[[
raylib 32x32 game/demo competition

Competition consist in developing a videogame in a 32x32 pixels screen size.

RULES:

 1) Use only raylib (and included libraries), no external libraries allowed
 2) The submission should consist of just one source file
 3) Render your game/demo to a 32x32 pixels render texture,
    show what you could do with a 32x32 RGB LED matrix!
 4) No external resources, you CAN only create them programmatically,
 5) Game/demo can be 2D or 3D, choose wisely
 5) Shaders (if used) should be included in the source as string (char *)
    and loaded with LoadShaderCode()
 6) Code must compile and execute in PLATFORM_DESKTOP (Windows, Linux, macOS)


LICENSE: zlib/libpng

Copyright (c) 2020 <TODO: participant_name> (<TODO: participant_github_name>)

This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:

 1. The origin of this software must not be misrepresented; you must not claim that you
 wrote the original software. If you use this software in a product, an acknowledgment
 in the product documentation would be appreciated but is not required.

 2. Altered source versions must be plainly marked as such, and must not be misrepresented
 as being the original software.

 3. This notice may not be removed or altered from any source distribution.
]]

local rl = require("raylib")

local windowWidth = 512
local windowHeight = 512
local gameScreenWidth = 32
local gameScreenHeight = 32

rl.SetTraceLogLevel(rl.LOG_WARNING)
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(windowWidth, windowHeight, "my 32x32 game/demo")

local target = rl.LoadRenderTexture(gameScreenWidth, gameScreenHeight)
rl.SetTextureFilter(target.texture, rl.TEXTURE_FILTER_POINT)

rl.SetTargetFPS(60)

while not rl.WindowShouldClose() do
  local scale = math.min(rl.GetScreenWidth() / gameScreenWidth, rl.GetScreenHeight() / gameScreenHeight)

  rl.BeginDrawing()

  rl.BeginTextureMode(target)
  rl.ClearBackground(rl.WHITE)
  rl.DrawTextEx(
    rl.GetFontDefault(),
    "Hello",
    rl.Vector2(4, 0),
    rl.GetFontDefault().baseSize,
    1,
    rl.Color(0, 64, 255, 255)
  )
  rl.DrawTextEx(
    rl.GetFontDefault(),
    "it's",
    rl.Vector2(8, 10),
    rl.GetFontDefault().baseSize,
    1,
    rl.Color(0, 64, 255, 255)
  )
  rl.DrawTextEx(
    rl.GetFontDefault(),
    "raylua",
    rl.Vector2(0, 20),
    rl.GetFontDefault().baseSize,
    1,
    rl.Color(0, 64, 255, 255)
  )

  rl.EndTextureMode()

  rl.DrawTexturePro(
    target.texture,
    rl.Rectangle(0, 0, target.texture.width, -target.texture.height),
    rl.Rectangle(
      (rl.GetScreenWidth() - gameScreenWidth * scale) * 0.5,
      (rl.GetScreenHeight() - gameScreenHeight * scale) * 0.5,
      gameScreenWidth * scale,
      gameScreenHeight * scale
    ),
    rl.Vector2(0, 0),
    0,
    rl.WHITE
  )

  for x = 0, rl.GetScreenWidth(), 16 do
    rl.DrawRectangle(x, 0, 4, rl.GetScreenHeight(), rl.BLACK)
  end

  for y = 0, rl.GetScreenHeight(), 16 do
    rl.DrawRectangle(0, y, rl.GetScreenWidth(), 4, rl.BLACK)
  end
  rl.EndDrawing()
end

rl.UnloadRenderTexture(target)

rl.CloseWindow()
