summaryrefslogtreecommitdiff
path: root/examples/2D_camera
diff options
context:
space:
mode:
authorjussi2023-04-06 12:31:37 +0300
committerjussi2023-04-06 12:31:37 +0300
commit2526c9732e7ea35bc9ed3e43a4db77b7e6364c5a (patch)
tree825775577403d9341045571adb266173513c4bbd /examples/2D_camera
parent198a74c0aa27389c062c47bc29187c58a9d6c4a1 (diff)
downloadreilua-enhanced-2526c9732e7ea35bc9ed3e43a4db77b7e6364c5a.tar.gz
reilua-enhanced-2526c9732e7ea35bc9ed3e43a4db77b7e6364c5a.tar.bz2
reilua-enhanced-2526c9732e7ea35bc9ed3e43a4db77b7e6364c5a.zip
All global variables and functions are not in global RL table. doc_parser creates also ReiLua_API.lua.
Diffstat (limited to 'examples/2D_camera')
-rw-r--r--examples/2D_camera/main.lua58
1 files changed, 29 insertions, 29 deletions
diff --git a/examples/2D_camera/main.lua b/examples/2D_camera/main.lua
index b23d606..c47ba18 100644
--- a/examples/2D_camera/main.lua
+++ b/examples/2D_camera/main.lua
@@ -7,62 +7,62 @@ local cameraSpeed = 100.0
local cameraRotSpeed = 100.0
local cameraZoomSpeed = 10.0
-function init()
+function RL.init()
local monitor = 0
- local mPos = RL_GetMonitorPosition( monitor )
- local mSize = RL_GetMonitorSize( monitor )
- local winSize = RL_GetScreenSize()
+ local mPos = RL.GetMonitorPosition( monitor )
+ local mSize = RL.GetMonitorSize( monitor )
+ local winSize = RL.GetScreenSize()
- RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
- RL_SetWindowState( FLAG_VSYNC_HINT )
- RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
- RL_SetWindowTitle( "Camera 2D" )
+ 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 } )
+ RL.SetWindowTitle( "Camera 2D" )
- tileTexture = RL_LoadTexture( RL_GetBasePath().."../resources/images/tiles.png" )
- camera = RL_CreateCamera2D()
- RL_SetCamera2DOffset( camera, { winSize[1] / 2, winSize[2] / 2 } )
+ tileTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/tiles.png" )
+ camera = RL.CreateCamera2D()
+ RL.SetCamera2DOffset( camera, { winSize[1] / 2, winSize[2] / 2 } )
end
-function process( delta )
+function RL.process( delta )
-- Move.
- if RL_IsKeyDown( KEY_RIGHT ) then
+ if RL.IsKeyDown( RL.KEY_RIGHT ) then
cameraPos[1] = cameraPos[1] + cameraSpeed * delta
- elseif RL_IsKeyDown( KEY_LEFT ) then
+ elseif RL.IsKeyDown( RL.KEY_LEFT ) then
cameraPos[1] = cameraPos[1] - cameraSpeed * delta
end
- if RL_IsKeyDown( KEY_DOWN ) then
+ if RL.IsKeyDown( RL.KEY_DOWN ) then
cameraPos[2] = cameraPos[2] + cameraSpeed * delta
- elseif RL_IsKeyDown( KEY_UP ) then
+ elseif RL.IsKeyDown( RL.KEY_UP ) then
cameraPos[2] = cameraPos[2] - cameraSpeed * delta
end
-- Rotate.
- if RL_IsKeyDown( string.byte( "E" ) ) then -- Or RL_IsKeyDown( KEY_E )
+ if RL.IsKeyDown( string.byte( "E" ) ) then -- Or RL.IsKeyDown( KEY_E )
cameraRot = cameraRot + cameraRotSpeed * delta
- elseif RL_IsKeyDown( string.byte( "Q" ) ) then
+ elseif RL.IsKeyDown( string.byte( "Q" ) ) then
cameraRot = cameraRot - cameraRotSpeed * delta
end
-- Zoom.
- if RL_IsKeyDown( string.byte( "R" ) ) then
+ if RL.IsKeyDown( string.byte( "R" ) ) then
cameraZoom = cameraZoom + cameraZoomSpeed * delta
- elseif RL_IsKeyDown( string.byte( "F" ) ) then
+ elseif RL.IsKeyDown( string.byte( "F" ) ) then
cameraZoom = cameraZoom - cameraZoomSpeed * delta
end
end
-function draw()
- RL_ClearBackground( RAYWHITE )
- RL_SetCamera2DTarget( camera, cameraPos )
- RL_SetCamera2DRotation( camera, cameraRot )
- RL_SetCamera2DZoom( camera, cameraZoom )
+function RL.draw()
+ RL.ClearBackground( RL.RAYWHITE )
+ RL.SetCamera2DTarget( camera, cameraPos )
+ RL.SetCamera2DRotation( camera, cameraRot )
+ RL.SetCamera2DZoom( camera, cameraZoom )
- RL_BeginMode2D( camera )
+ RL.BeginMode2D( camera )
-- Draw wall.
for y = 0, 4 do
for x = 0, 6 do
- RL_DrawTextureRec( tileTexture, { 0, 0, 32, 32 }, { x * 32, y * 32 }, WHITE )
+ RL.DrawTextureRec( tileTexture, { 0, 0, 32, 32 }, { x * 32, y * 32 }, RL.WHITE )
end
end
-- Draw hero.
- RL_DrawTextureRec( tileTexture, { 3 * 32, 0, 32, 32 }, { cameraPos[1] - 16, cameraPos[2] - 16 }, WHITE )
- RL_EndMode2D()
+ RL.DrawTextureRec( tileTexture, { 3 * 32, 0, 32, 32 }, { cameraPos[1] - 16, cameraPos[2] - 16 }, RL.WHITE )
+ RL.EndMode2D()
end