Fixed examples.

This commit is contained in:
jussi
2023-10-29 19:45:18 +02:00
parent fcd2d2d8b5
commit 992310fb90
18 changed files with 62 additions and 54 deletions

View File

@@ -83,7 +83,7 @@ function RL.draw()
end
RL.DrawRectangle( { 0, 0, screenWidth, 40 }, RL.BLACK)
RL.DrawText( 0, "bunnies: " .. #bunnies, { 120, 10 }, 20, 2, RL.GREEN )
RL.DrawText( 0, "batched draw calls: " .. math.ceil( 1 + #bunnies / MAX_BATCH_ELEMENTS ), { 320, 10 }, 20, 2, RL.RED )
RL.DrawText( RL.defaultFont, "bunnies: " .. #bunnies, { 120, 10 }, 20, 2, RL.GREEN )
RL.DrawText( RL.defaultFont, "batched draw calls: " .. math.ceil( 1 + #bunnies / MAX_BATCH_ELEMENTS ), { 320, 10 }, 20, 2, RL.RED )
RL.DrawFPS( { 10, 10 } )
end

View File

@@ -100,5 +100,5 @@ function RL.draw()
RL.ClearBackground( RL.RED )
end
RL.DrawText( 0, text, textPos, 20, 2, RL.BLACK )
RL.DrawText( RL.defaultFont, text, textPos, 20, 2, RL.BLACK )
end

View File

@@ -68,5 +68,5 @@ function RL.draw()
text = text.."\nPress T to toggle target visible.\nVisible: "..tostring( targetVisible )
RL.DrawText( 0, text, { 16, 16 }, 30, 4, RL.WHITE )
RL.DrawText( RL.defaultFont, text, { 16, 16 }, 30, 4, RL.WHITE )
end

View File

@@ -26,7 +26,7 @@ function RL.init()
local mSize = RL.GetMonitorSize( monitor )
local winSize = { 1920, 1080 }
RL.GuiSetFont( 0 )
RL.GuiSetFont( RL.defaultFont )
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowSize( winSize )

View File

@@ -13,7 +13,7 @@ function RL.init()
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
image = RL.GenImageColor( winSize[1], winSize[2], RL.WHITE )
image = RL.GenImageColor( winSize, RL.WHITE )
-- Test changing working directory.
RL.ChangeDirectory( RL.GetBasePath().."../resources" )
catImage = RL.LoadImage( RL.GetWorkingDirectory().."/images/cat.png" )
@@ -24,14 +24,14 @@ function RL.init()
RL.ImageDrawRectangle( image, { 120, 64, 32, 64 }, RL.BLUE )
RL.ImageDrawRectangleLines( image, { 160, 64, 32, 64 }, 2.0, RL.BLUE )
RL.ImageDraw( image, catImage, { 143, 25, 230, 250 }, { 200, 200, 230, 250 }, RL.WHITE )
RL.ImageDrawTextEx( image, 0, "Hello", { 300, 32 }, 48.0, 1.0, RL.WHITE )
RL.ImageDrawTextEx( image, RL.defaultFont, "Hello", { 300, 32 }, 48.0, 1.0, RL.WHITE )
local src = { 80, 70, 96, 96 }
catCopy = RL.ImageFromImage( catImage, src )
RL.ImageDraw( image, catCopy, src, { 600, 200, src[3], src[4] }, RL.WHITE )
textImage = RL.ImageText( 0, "Cat", 10, 4, RL.WHITE )
textImage = RL.ImageText( RL.defaultFont, "Cat", 10, 4, RL.WHITE )
local imageSize = RL.GetImageSize( textImage )
RL.ImageDraw( image, textImage, { 0, 0, imageSize[1], imageSize[2] }, { 250, 40, imageSize[1], imageSize[2] }, RL.WHITE )

View File

@@ -4,7 +4,8 @@ local speed = 60.0
local monitor = 0
local mPos = RL.GetMonitorPosition( monitor )
local mSize = RL.GetMonitorSize( monitor )
local framebuffer = -1
local framebuffer = nil
local framebufferTex = nil
local res = { 320, 180 }
local scale = 5
local winSize = { res[1] * scale, res[2] * scale }
@@ -17,6 +18,7 @@ function RL.init()
tex = RL.LoadTexture( RL.GetBasePath().."../resources/images/cat.png" )
-- Create framebuffer.
framebuffer = RL.LoadRenderTexture( res )
framebufferTex = RL.GetRenderTextureTexture( framebuffer )
end
function RL.process( delta )
@@ -46,9 +48,9 @@ function RL.draw()
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, RL.WHITE )
RL.DrawText( 0, "Cat MIAU!!", { 16, 32 }, 10, 1, { 255, 180, 155 } )
RL.DrawText( RL.defaultFont, "Cat MIAU!!", { 16, 32 }, 10, 1, { 255, 180, 155 } )
RL.DrawTriangle( { 0, 32 }, { 32, 16 }, { 0, 0 }, RL.RED )
RL.EndTextureMode()
RL.DrawTexturePro( framebuffer, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, { 255, 255, 255 } )
RL.DrawTexturePro( framebufferTex, { 0, 0, res[1], -res[2] }, { 0, 0, winSize[1], winSize[2] }, { 0, 0 }, 0.0, { 255, 255, 255 } )
end

View File

@@ -116,5 +116,5 @@ function RL.draw()
RL.DrawSphereWires( point.pos, point.radius, 3, 8, point.color )
RL.EndMode3D()
RL.DrawText( 0, debugText, { 10, 10 }, 30, 4, RL.WHITE )
RL.DrawText( RL.defaultFont, debugText, { 10, 10 }, 30, 4, RL.WHITE )
end

View File

@@ -121,7 +121,7 @@ function RL.draw()
RL.DrawCircle( ball.pos, ball.radius, RL.WHITE )
-- Draw scire
RL.DrawText( 0, playerLeft.score, { 50, 10 }, 40, 2, RL.WHITE )
local rightTextSize = RL.MeasureText( 0, playerRight.score, 40, 2 )
RL.DrawText( 0, playerRight.score, { winSize[1] - 50 - rightTextSize[1], 10 }, 40, 2, RL.WHITE )
RL.DrawText( RL.defaultFont, playerLeft.score, { 50, 10 }, 40, 2, RL.WHITE )
local rightTextSize = RL.MeasureText( RL.defaultFont, playerRight.score, 40, 2 )
RL.DrawText( RL.defaultFont, playerRight.score, { winSize[1] - 50 - rightTextSize[1], 10 }, 40, 2, RL.WHITE )
end

View File

@@ -126,7 +126,7 @@ function RL.draw()
RL.DrawCircle( ball.pos, ball.radius, RL.WHITE )
-- Draw score.
RL.DrawText( 0, tostring( playerLeft.score ), { 50, 10 }, 40, 2, RL.WHITE )
local rightTextSize = Vec2:new( RL.MeasureText( 0, tostring( playerRight.score ), 40, 2 ) )
RL.DrawText( 0, tostring( playerRight.score ), { winSize.x - 50 - rightTextSize.x, 10 }, 40, 2, RL.WHITE )
RL.DrawText( RL.defaultFont, tostring( playerLeft.score ), { 50, 10 }, 40, 2, RL.WHITE )
local rightTextSize = Vec2:new( RL.MeasureText( RL.defaultFont, tostring( playerRight.score ), 40, 2 ) )
RL.DrawText( RL.defaultFont, tostring( playerRight.score ), { winSize.x - 50 - rightTextSize.x, 10 }, 40, 2, RL.WHITE )
end

View File

@@ -53,7 +53,7 @@ function RL.draw()
RL.DrawGrid( 8, 1 )
RL.DrawRay( ray, { 255, 100, 100 } )
RL.DrawMesh( sphereMesh, 0, RL.MatrixIdentity() )
RL.DrawMesh( sphereMesh, RL.defaultMaterial, RL.MatrixIdentity() )
RL.DrawSphereWires( rayCol.point, 0.05, 4, 8, RL.BLUE )
RL.DrawLine3D( rayCol.point, RL.Vector3Add( rayCol.point, rayCol.normal ), RL.GREEN )
RL.EndMode3D()

View File

@@ -40,7 +40,7 @@ Gui = {
},
mouseButton = RL.MOUSE_BUTTON_LEFT,
font = 0,
font = RL.defaultFont,
fontSize = 20,
padding = 2,
spacing = 4,

View File

@@ -215,7 +215,7 @@ function RL.draw()
drawApple()
if gameState == STATE.OVER then
RL.DrawText( 0, "Press Enter to\nrestart", { 10, 10 }, 10, 2, RL.WHITE )
RL.DrawText( RL.defaultFont, "Press Enter to\nrestart", { 10, 10 }, 10, 2, RL.WHITE )
end
RL.EndTextureMode()