RL.config and InitWindow.
This commit is contained in:
@@ -15,8 +15,6 @@ local WALL_MESH_HEIGHT = math.tan( RL.DEG2RAD * ( 90 - SHADOW_FOV / 2 ) ) * LIGH
|
||||
print( "WALL_MESH_HEIGHT", WALL_MESH_HEIGHT )
|
||||
|
||||
local monitor = 0
|
||||
local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
|
||||
local winScale = 1
|
||||
local winSize = Vector2:new( RESOLUTION.x * winScale, RESOLUTION.y * winScale )
|
||||
|
||||
@@ -87,6 +85,9 @@ local function createShadowMesh()
|
||||
end
|
||||
|
||||
function RL.init()
|
||||
local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
|
||||
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetWindowSize( winSize )
|
||||
|
||||
@@ -10,33 +10,6 @@ Gui = require( "gui" )
|
||||
Calculator = require( "calculator" )
|
||||
FileExplorer = require( "file_explorer" )
|
||||
|
||||
-- Textures.
|
||||
|
||||
-- Note that textures are global.
|
||||
CancelTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cancel.png" )
|
||||
BackTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/previous-button.png" )
|
||||
FolderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/open-folder.png" )
|
||||
FilesTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/files.png" )
|
||||
BorderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_border.png" )
|
||||
BgrTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_bgr.png" )
|
||||
|
||||
RL.GenTextureMipmaps( CancelTexture )
|
||||
RL.GenTextureMipmaps( BackTexture )
|
||||
RL.GenTextureMipmaps( FolderTexture )
|
||||
RL.GenTextureMipmaps( FilesTexture )
|
||||
RL.GenTextureMipmaps( BorderTexture )
|
||||
RL.GenTextureMipmaps( BgrTexture )
|
||||
|
||||
RL.SetTextureFilter( CancelTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BackTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( FolderTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( FilesTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BorderTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BgrTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
|
||||
RL.SetTextureWrap( BorderTexture, RL.TEXTURE_WRAP_REPEAT )
|
||||
RL.SetTextureWrap( BgrTexture, RL.TEXTURE_WRAP_REPEAT )
|
||||
|
||||
-- End of calculator definition.
|
||||
|
||||
local calculator = nil
|
||||
@@ -72,6 +45,32 @@ function RL.init()
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetWindowSize( winSize )
|
||||
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
-- Textures.
|
||||
|
||||
-- Note that textures are global.
|
||||
CancelTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/cancel.png" )
|
||||
BackTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/previous-button.png" )
|
||||
FolderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/open-folder.png" )
|
||||
FilesTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/files.png" )
|
||||
BorderTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_border.png" )
|
||||
BgrTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_bgr.png" )
|
||||
|
||||
RL.GenTextureMipmaps( CancelTexture )
|
||||
RL.GenTextureMipmaps( BackTexture )
|
||||
RL.GenTextureMipmaps( FolderTexture )
|
||||
RL.GenTextureMipmaps( FilesTexture )
|
||||
RL.GenTextureMipmaps( BorderTexture )
|
||||
RL.GenTextureMipmaps( BgrTexture )
|
||||
|
||||
RL.SetTextureFilter( CancelTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BackTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( FolderTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( FilesTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BorderTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetTextureFilter( BgrTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
|
||||
RL.SetTextureWrap( BorderTexture, RL.TEXTURE_WRAP_REPEAT )
|
||||
RL.SetTextureWrap( BgrTexture, RL.TEXTURE_WRAP_REPEAT )
|
||||
|
||||
initGui()
|
||||
end
|
||||
|
||||
@@ -4,11 +4,7 @@ package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||
|
||||
Vec2 = require( "vector2" )
|
||||
|
||||
local monitor = 0
|
||||
local mPos = Vec2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local mSize = Vec2:newT( RL.GetMonitorSize( monitor ) )
|
||||
local winSize = Vec2:newT( RL.GetScreenSize() )
|
||||
|
||||
local winSize = Vec2:new()
|
||||
local polygon = {
|
||||
texture = -1,
|
||||
texcoords = {
|
||||
@@ -30,6 +26,11 @@ local polygon = {
|
||||
}
|
||||
|
||||
function RL.init()
|
||||
local monitor = 0
|
||||
local mPos = Vec2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local mSize = Vec2:newT( RL.GetMonitorSize( monitor ) )
|
||||
winSize = Vec2:newT( RL.GetScreenSize() )
|
||||
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } )
|
||||
|
||||
@@ -6,18 +6,16 @@ Rect = require( "rectangle" )
|
||||
local dstRec = Rect:new( 100.0, 100.0, 8.0, 8.0 )
|
||||
local origin = Vec2:new( 0.0, 0.0 )
|
||||
local stretched = true
|
||||
|
||||
-- local ninePatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH }
|
||||
-- local nPatchTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/ui_border.png" )
|
||||
|
||||
local ninePatchInfo = { source = { 0, 0, 96, 96 }, left = 32, top = 32, right = 32, bottom = 32, layout = RL.NPATCH_NINE_PATCH }
|
||||
-- local ninePatchInfo = { source = { 0, 0, 96, 96 }, left = 32, top = 32, right = 32, bottom = 32, layout = RL.NPATCH_THREE_PATCH_VERTICAL }
|
||||
-- local ninePatchInfo = { source = { 0, 0, 96, 96 }, left = 32, top = 32, right = 32, bottom = 32, layout = RL.NPATCH_THREE_PATCH_HORIZONTAL }
|
||||
local nPatchTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/nPatch.png" )
|
||||
local nPatchTexture = nil
|
||||
|
||||
function RL.init()
|
||||
RL.SetWindowTitle( "N-Patches" )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
|
||||
nPatchTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/nPatch.png" )
|
||||
end
|
||||
|
||||
function RL.update( delta )
|
||||
|
||||
@@ -12,11 +12,11 @@ local GRAVITY = 6
|
||||
local JUMP_STR = 3
|
||||
local WALK_ANIM_SPEED = 12
|
||||
|
||||
local tex = RL.LoadTexture( RL.GetBasePath().."../resources/images/arcade_platformerV2.png" )
|
||||
local tex = nil
|
||||
local res = Vec2:new( 160, 144 )
|
||||
local winScale = 5
|
||||
local winSize = res:scale( winScale )
|
||||
local framebuffer = RL.LoadRenderTexture( res )
|
||||
local framebuffer = nil
|
||||
local monitor = 0
|
||||
local tilemap = {
|
||||
size = Vec2:new( res.x / TILE_SIZE, res.y / TILE_SIZE ),
|
||||
@@ -80,21 +80,24 @@ local function createMap()
|
||||
tilemap.tiles[1][8] = 6
|
||||
end
|
||||
|
||||
function RL.init()
|
||||
function RL.config()
|
||||
RL.SetConfigFlags( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetConfigFlags( RL.FLAG_VSYNC_HINT )
|
||||
RL.InitWindow( winSize, "Platformer" )
|
||||
|
||||
local monitorPos = Vec2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vec2:newT( RL.GetMonitorSize( monitor ) )
|
||||
|
||||
RL.SetWindowTitle( "Platformer" )
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetWindowSize( winSize )
|
||||
RL.SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } )
|
||||
end
|
||||
|
||||
function RL.init()
|
||||
createMap()
|
||||
|
||||
tex = RL.LoadTexture( RL.GetBasePath().."../resources/images/arcade_platformerV2.png" )
|
||||
framebuffer = RL.LoadRenderTexture( res )
|
||||
end
|
||||
|
||||
local function isTileWall( pos )
|
||||
-- if RL.CheckCollisionPointRec( { pos.x, pos.y }, { 0, 0, tilemap.size.x - 1, tilemap.size.y - 1 } ) then
|
||||
if RL.CheckCollisionPointRec( { pos.x, pos.y }, { 0, 0, tilemap.size.x, tilemap.size.y } ) then
|
||||
return 0 < tilemap.tiles[ pos.x + 1 ][ pos.y + 1 ]
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local camera = -1
|
||||
local sphereMesh = -1
|
||||
local camera = nil
|
||||
local sphereMesh = nil
|
||||
local ray = { { 0.5, 0, 4 }, { 0.1, 0, -1 } }
|
||||
local rayCol = {}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ Gui = Raygui:new()
|
||||
local grid = {}
|
||||
local windowbox = {}
|
||||
local tabBar = {}
|
||||
local texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/gradient.png" )
|
||||
local textureRect = Rect:new( 0, 0, RL.GetTextureSize( texture )[1], RL.GetTextureSize( texture )[2] )
|
||||
local texture = nil
|
||||
local textureRect = Rect:new()
|
||||
|
||||
local function closeTab( self, id )
|
||||
local splits = Util.split( tabBar.text, ";" )
|
||||
@@ -55,6 +55,9 @@ function RL.init()
|
||||
|
||||
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_LINE_SPACING, 20 )
|
||||
|
||||
texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/gradient.png" )
|
||||
textureRect = Rect:new( 0, 0, RL.GetTextureSize( texture )[1], RL.GetTextureSize( texture )[2] )
|
||||
|
||||
local label = Gui:Label(
|
||||
Rect:new( 16, 16, 64, 32 ),
|
||||
"Cat"
|
||||
|
||||
@@ -13,8 +13,6 @@ local STATE = { TITLE = 0, GAME = 1, OVER = 2 } -- Enum.
|
||||
-- Resources
|
||||
local framebuffer = nil
|
||||
local monitor = 0
|
||||
local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
|
||||
local winScale = 6
|
||||
local winSize = Vector2:new( RESOLUTION.x * winScale, RESOLUTION.y * winScale )
|
||||
local gameState = STATE.GAME
|
||||
@@ -69,16 +67,22 @@ local function setApplePos()
|
||||
end
|
||||
end
|
||||
|
||||
-- Config.
|
||||
|
||||
function RL.config()
|
||||
RL.SetConfigFlags( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetConfigFlags( RL.FLAG_VSYNC_HINT )
|
||||
RL.InitWindow( winSize, "Snake" )
|
||||
RL.SetWindowIcon( RL.LoadImage( RL.GetBasePath().."../resources/images/apple.png" ) )
|
||||
|
||||
local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) )
|
||||
RL.SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } )
|
||||
end
|
||||
|
||||
-- Init.
|
||||
|
||||
function RL.init()
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetWindowSize( winSize )
|
||||
RL.SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } )
|
||||
RL.SetWindowTitle( "Snake" )
|
||||
RL.SetWindowIcon( RL.LoadImage( RL.GetBasePath().."../resources/images/apple.png" ) )
|
||||
|
||||
framebuffer = RL.LoadRenderTexture( RESOLUTION )
|
||||
grassTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/grass.png" )
|
||||
snakeTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/snake.png" )
|
||||
|
||||
Reference in New Issue
Block a user