Remove rlua from raylib main repo
Moved to own repo at https://github.com/raysan5/raylib-lua
This commit is contained in:
parent
c4bd214cf0
commit
7bf6a712cc
56 changed files with 0 additions and 8935 deletions
|
|
@ -1,101 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [audio] example - Module playing (streaming)
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MAX_CIRCLES = 64
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)")
|
|
||||||
|
|
||||||
InitAudioDevice() -- Initialize audio device
|
|
||||||
|
|
||||||
local colors = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
|
||||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE }
|
|
||||||
|
|
||||||
-- Creates ome circles for visual effect
|
|
||||||
local circles = {}
|
|
||||||
|
|
||||||
for i = MAX_CIRCLES, 1, -1 do
|
|
||||||
circles[i] = {}
|
|
||||||
circles[i].alpha = 0.0
|
|
||||||
circles[i].radius = GetRandomValue(10, 40)
|
|
||||||
circles[i].position = Vector2(0, 0)
|
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius)
|
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius)
|
|
||||||
circles[i].speed = GetRandomValue(1, 100)/20000.0
|
|
||||||
circles[i].color = colors[GetRandomValue(1, 14)]
|
|
||||||
end
|
|
||||||
|
|
||||||
local xm = LoadMusicStream("resources/audio/mini1111.xm")
|
|
||||||
|
|
||||||
PlayMusicStream(xm)
|
|
||||||
|
|
||||||
local timePlayed = 0.0
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
for i = MAX_CIRCLES, 1, -1 do
|
|
||||||
circles[i].alpha = circles[i].alpha + circles[i].speed
|
|
||||||
circles[i].radius = circles[i].radius + circles[i].speed*10.0
|
|
||||||
|
|
||||||
if (circles[i].alpha > 1.0) then circles[i].speed = circles[i].speed*-1 end
|
|
||||||
|
|
||||||
if (circles[i].alpha <= 0.0) then
|
|
||||||
circles[i].alpha = 0.0
|
|
||||||
circles[i].radius = GetRandomValue(10, 40)
|
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius)
|
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius)
|
|
||||||
circles[i].color = colors[GetRandomValue(1, 14)]
|
|
||||||
circles[i].speed = GetRandomValue(1, 100)/20000.0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get timePlayed scaled to bar dimensions
|
|
||||||
timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2
|
|
||||||
|
|
||||||
UpdateMusicStream(xm) -- Update music buffer with new stream data
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
for i = MAX_CIRCLES, 1, -1 do
|
|
||||||
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Draw time bar
|
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY)
|
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, timePlayed//1, 12, MAROON)
|
|
||||||
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, WHITE)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(xm) -- Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [audio] example - Music playing (streaming)
|
|
||||||
--
|
|
||||||
-- NOTE: This example requires OpenAL Soft library installed
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)")
|
|
||||||
|
|
||||||
InitAudioDevice() -- Initialize audio device
|
|
||||||
|
|
||||||
local music = LoadMusicStream("resources/audio/guitar_noodling.ogg")
|
|
||||||
|
|
||||||
PlayMusicStream(music)
|
|
||||||
|
|
||||||
local framesCounter = 0
|
|
||||||
local timePlayed = 0.0
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
framesCounter = framesCounter + 1
|
|
||||||
|
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4 -- We scale by 4 to fit 400 pixels
|
|
||||||
|
|
||||||
UpdateMusicStream(music) -- Update music buffer with new stream data
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
DrawRectangle(200, 250, 400, 12, LIGHTGRAY)
|
|
||||||
DrawRectangle(200, 250, timePlayed//1, 12, MAROON)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
UnloadMusicStream(music) -- Unload music stream buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [audio] example - Raw audio streaming
|
|
||||||
--
|
|
||||||
-- NOTE: This example requires OpenAL Soft library installed
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MAX_SAMPLES = 20000
|
|
||||||
DEG2RAD = math.pi/180.0
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming")
|
|
||||||
|
|
||||||
InitAudioDevice() -- Initialize audio device
|
|
||||||
|
|
||||||
-- Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
|
|
||||||
local stream = InitAudioStream(22050, 32, 1)
|
|
||||||
|
|
||||||
-- Fill audio stream with some samples (sine wave)
|
|
||||||
local data = {}
|
|
||||||
|
|
||||||
for i = 1, MAX_SAMPLES do
|
|
||||||
data[i] = math.sin(((2*math.pi*i)/2)*DEG2RAD)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
|
|
||||||
-- for that reason, there is a clip everytime audio stream is looped
|
|
||||||
|
|
||||||
PlayAudioStream(stream)
|
|
||||||
|
|
||||||
local totalSamples = MAX_SAMPLES
|
|
||||||
local samplesLeft = totalSamples
|
|
||||||
|
|
||||||
local position = Vector2(0, 0)
|
|
||||||
|
|
||||||
SetTargetFPS(30) -- Set our game to run at 30 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Refill audio stream if required
|
|
||||||
if (IsAudioBufferProcessed(stream)) then
|
|
||||||
local numSamples = 0
|
|
||||||
|
|
||||||
if (samplesLeft >= 4096) then numSamples = 4096
|
|
||||||
else numSamples = samplesLeft end
|
|
||||||
|
|
||||||
UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples)
|
|
||||||
|
|
||||||
samplesLeft = samplesLeft - numSamples
|
|
||||||
|
|
||||||
-- Reset samples feeding (loop audio)
|
|
||||||
if (samplesLeft <= 0) then samplesLeft = totalSamples end
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
-- NOTE: Draw a part of the sine wave (only screen width)
|
|
||||||
for i = 1, GetScreenWidth() do
|
|
||||||
position.x = (i - 1)
|
|
||||||
position.y = 250 + 50*data[i]
|
|
||||||
|
|
||||||
DrawPixelV(position, RED)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseAudioStream(stream) -- Close raw audio stream and delete buffers from RAM
|
|
||||||
|
|
||||||
CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [audio] example - Sound loading and playing
|
|
||||||
--
|
|
||||||
-- NOTE: This example requires OpenAL Soft library installed
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing")
|
|
||||||
|
|
||||||
InitAudioDevice() -- Initialize audio device
|
|
||||||
|
|
||||||
local fxWav = LoadSound("resources/audio/weird.wav") -- Load WAV audio file
|
|
||||||
local fxOgg = LoadSound("resources/audio/tanatana.ogg") -- Load OGG audio file
|
|
||||||
|
|
||||||
SetTargetFPS(60)
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY.SPACE)) then PlaySound(fxWav) end -- Play WAV sound
|
|
||||||
if (IsKeyPressed(KEY.ENTER)) then PlaySound(fxOgg) end -- Play OGG sound
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
UnloadSound(fxWav) -- Unload sound data
|
|
||||||
UnloadSound(fxOgg) -- Unload sound data
|
|
||||||
|
|
||||||
CloseAudioDevice() -- Close audio device
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - 2d camera
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MAX_BUILDINGS = 100
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera")
|
|
||||||
|
|
||||||
local player = Rectangle(400, 280, 40, 40)
|
|
||||||
local buildings = {}
|
|
||||||
local buildColors = {}
|
|
||||||
|
|
||||||
local spacing = 0;
|
|
||||||
|
|
||||||
for i = 1, MAX_BUILDINGS do
|
|
||||||
buildings[i] = Rectangle(0, 0, 0, 0)
|
|
||||||
buildings[i].width = GetRandomValue(50, 200)
|
|
||||||
buildings[i].height = GetRandomValue(100, 800)
|
|
||||||
buildings[i].y = screenHeight - 130 - buildings[i].height
|
|
||||||
buildings[i].x = -6000 + spacing
|
|
||||||
|
|
||||||
spacing = spacing + buildings[i].width
|
|
||||||
|
|
||||||
buildColors[i] = Color(GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255)
|
|
||||||
end
|
|
||||||
|
|
||||||
local camera = Camera2D(Vector2(0, 0), Vector2(0, 0), 0.0, 1.0)
|
|
||||||
|
|
||||||
camera.target = Vector2(player.x + 20, player.y + 20)
|
|
||||||
camera.offset = Vector2(0, 0)
|
|
||||||
camera.rotation = 0.0
|
|
||||||
camera.zoom = 1.0
|
|
||||||
|
|
||||||
SetTargetFPS(60)
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
if (IsKeyDown(KEY.RIGHT)) then
|
|
||||||
player.x = player.x + 2 -- Player movement
|
|
||||||
camera.offset.x = camera.offset.x - 2 -- Camera displacement with player movement
|
|
||||||
elseif (IsKeyDown(KEY.LEFT)) then
|
|
||||||
player.x = player.x - 2 -- Player movement
|
|
||||||
camera.offset.x = camera.offset.x + 2 -- Camera displacement with player movement
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Camera target follows player
|
|
||||||
camera.target = Vector2(player.x + 20, player.y + 20)
|
|
||||||
|
|
||||||
-- Camera rotation controls
|
|
||||||
if (IsKeyDown(KEY.A)) then camera.rotation = camera.rotation - 1
|
|
||||||
elseif (IsKeyDown(KEY.S)) then camera.rotation = camera.rotation + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Limit camera rotation to 80 degrees (-40 to 40)
|
|
||||||
if (camera.rotation > 40) then camera.rotation = 40
|
|
||||||
elseif (camera.rotation < -40) then camera.rotation = -40
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Camera zoom controls
|
|
||||||
camera.zoom = camera.zoom + (GetMouseWheelMove()*0.05)
|
|
||||||
|
|
||||||
if (camera.zoom > 3.0) then camera.zoom = 3.0
|
|
||||||
elseif (camera.zoom < 0.1) then camera.zoom = 0.1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Camera reset (zoom and rotation)
|
|
||||||
if (IsKeyPressed(KEY.R)) then
|
|
||||||
camera.zoom = 1.0
|
|
||||||
camera.rotation = 0.0
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin2dMode(camera)
|
|
||||||
|
|
||||||
DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY)
|
|
||||||
|
|
||||||
for i = 1, MAX_BUILDINGS, 1 do DrawRectangleRec(buildings[i], buildColors[i]) end
|
|
||||||
|
|
||||||
DrawRectangleRec(player, RED)
|
|
||||||
|
|
||||||
DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN)
|
|
||||||
DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN)
|
|
||||||
|
|
||||||
End2dMode()
|
|
||||||
|
|
||||||
DrawText("SCREEN AREA", 640, 10, 20, RED)
|
|
||||||
|
|
||||||
DrawRectangle(0, 0, screenWidth, 5, RED)
|
|
||||||
DrawRectangle(0, 5, 5, screenHeight - 10, RED)
|
|
||||||
DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED)
|
|
||||||
DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED)
|
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5))
|
|
||||||
DrawRectangleLines( 10, 10, 250, 113, BLUE)
|
|
||||||
|
|
||||||
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK)
|
|
||||||
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY)
|
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY)
|
|
||||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY)
|
|
||||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY)
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
--------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - 3d camera first person
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
--------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MAX_COLUMNS = 20
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person")
|
|
||||||
|
|
||||||
-- Define the camera to look into our 3d world (position, target, up vector)
|
|
||||||
local camera = Camera(Vector3(4.0, 2.0, 4.0), Vector3(0.0, 1.8, 0.0), Vector3(0.0, 1.0, 0.0), 60.0)
|
|
||||||
|
|
||||||
-- Generates some random columns
|
|
||||||
local heights = {}
|
|
||||||
local positions = {}
|
|
||||||
local colors = {}
|
|
||||||
|
|
||||||
for i = 1, MAX_COLUMNS do
|
|
||||||
heights[i] = GetRandomValue(1, 12)
|
|
||||||
positions[i] = Vector3(GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15))
|
|
||||||
colors[i] = Color(GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255)
|
|
||||||
end
|
|
||||||
|
|
||||||
local playerPosition = Vector3(4.0, 2.0, 4.0) -- Define player position
|
|
||||||
|
|
||||||
SetCameraMode(camera, CameraMode.FIRST_PERSON) -- Set a first person camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
camera = UpdateCamera(camera) -- Update camera
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin3dMode(camera)
|
|
||||||
|
|
||||||
DrawPlane(Vector3(0.0, 0.0, 0.0), Vector2(32.0, 32.0), LIGHTGRAY) -- Draw ground
|
|
||||||
DrawCube(Vector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, BLUE) -- Draw a blue wall
|
|
||||||
DrawCube(Vector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, LIME) -- Draw a green wall
|
|
||||||
DrawCube(Vector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, GOLD) -- Draw a yellow wall
|
|
||||||
|
|
||||||
-- Draw some cubes around
|
|
||||||
for i = 1, MAX_COLUMNS do
|
|
||||||
DrawCube(positions[i], 2.0, heights[i], 2.0, colors[i])
|
|
||||||
DrawCubeWires(positions[i], 2.0, heights[i], 2.0, MAROON)
|
|
||||||
end
|
|
||||||
|
|
||||||
End3dMode()
|
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5))
|
|
||||||
DrawRectangleLines( 10, 10, 220, 70, BLUE)
|
|
||||||
|
|
||||||
DrawText("First person camera default controls:", 20, 20, 10, BLACK)
|
|
||||||
DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY)
|
|
||||||
DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Initialize 3d camera free
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
--------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
|
|
||||||
|
|
||||||
-- Define the camera to look into our 3d world
|
|
||||||
local camera = {}
|
|
||||||
camera.position = Vector3(10.0, 10.0, 10.0) -- Camera position
|
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
|
|
||||||
camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0 -- Camera field-of-view Y
|
|
||||||
|
|
||||||
local cubePosition = Vector3(0.0, 0.0, 0.0)
|
|
||||||
|
|
||||||
SetCameraMode(camera, CameraMode.FREE) -- Set a free camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
camera = UpdateCamera(camera) -- Update camera
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin3dMode(camera)
|
|
||||||
|
|
||||||
DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
|
|
||||||
DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0)
|
|
||||||
|
|
||||||
End3dMode()
|
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5))
|
|
||||||
DrawRectangleLines( 10, 10, 320, 133, BLUE)
|
|
||||||
|
|
||||||
DrawText("Free camera default controls:", 20, 20, 10, BLACK)
|
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY)
|
|
||||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY)
|
|
||||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY)
|
|
||||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY)
|
|
||||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Initialize 3d mode
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode")
|
|
||||||
|
|
||||||
-- Define the camera to look into our 3d world
|
|
||||||
local camera = {}
|
|
||||||
camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
|
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
|
|
||||||
camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0 -- Camera field-of-view Y
|
|
||||||
|
|
||||||
local cubePosition = Vector3(0.0, 0.0, 0.0)
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
-- TODO: Update your variables here
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin3dMode(camera) -- ERROR: Lua Error: attempt to index a number value (?)
|
|
||||||
|
|
||||||
DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
|
|
||||||
DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0)
|
|
||||||
|
|
||||||
End3dMode()
|
|
||||||
|
|
||||||
DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY)
|
|
||||||
|
|
||||||
DrawFPS(10, 10)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Picking in 3d mode
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")
|
|
||||||
|
|
||||||
-- Define the camera to look into our 3d world
|
|
||||||
local camera = {}
|
|
||||||
camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
|
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
|
|
||||||
camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0 -- Camera field-of-view Y
|
|
||||||
|
|
||||||
local cubePosition = Vector3(0.0, 1.0, 0.0)
|
|
||||||
local cubeSize = Vector3(2.0, 2.0, 2.0)
|
|
||||||
|
|
||||||
local ray = Ray(Vector3(0, 0, 0), Vector3(0, 0, 0)) -- Picking line ray
|
|
||||||
|
|
||||||
local collision = false
|
|
||||||
|
|
||||||
SetCameraMode(camera, CameraMode.FREE) -- Set a free camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
camera = UpdateCamera(camera) -- Update camera
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then
|
|
||||||
-- NOTE: This function is NOT WORKING properly!
|
|
||||||
ray = GetMouseRay(GetMousePosition(), camera)
|
|
||||||
|
|
||||||
-- Check collision between ray and box
|
|
||||||
collision = CheckCollisionRayBox(ray,
|
|
||||||
BoundingBox(Vector3(cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2),
|
|
||||||
Vector3(cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2)))
|
|
||||||
|
|
||||||
--print("collision check:", collision)
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin3dMode(camera)
|
|
||||||
|
|
||||||
if (collision) then
|
|
||||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
|
|
||||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
|
|
||||||
|
|
||||||
DrawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, GREEN)
|
|
||||||
else
|
|
||||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
|
|
||||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
|
|
||||||
end
|
|
||||||
|
|
||||||
DrawRay(ray, MAROON)
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0)
|
|
||||||
|
|
||||||
End3dMode()
|
|
||||||
|
|
||||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY)
|
|
||||||
|
|
||||||
if (collision) then
|
|
||||||
DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30))/2, screenHeight*0.1, 30, GREEN)
|
|
||||||
end
|
|
||||||
|
|
||||||
DrawFPS(10, 10)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Basic window
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set target frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
-- TODO: Update your variables here
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Color selection by mouse (collision detection)
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
NUM_RECTANGLES = 21
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)")
|
|
||||||
|
|
||||||
local colors = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
|
|
||||||
GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
|
|
||||||
GREEN, SKYBLUE, PURPLE, BEIGE }
|
|
||||||
|
|
||||||
local colorsRecs = {} -- Rectangles array
|
|
||||||
local selected = {}
|
|
||||||
|
|
||||||
-- Fills colorsRecs data (for every rectangle)
|
|
||||||
for i = 1, NUM_RECTANGLES do
|
|
||||||
colorsRecs[i] = Rectangle(0, 0, 0, 0)
|
|
||||||
colorsRecs[i].x = 20 + 100*((i-1)%7) + 10*((i-1)%7)
|
|
||||||
colorsRecs[i].y = 60 + 100*((i-1)//7) + 10*((i-1)//7) -- Using floor division: //
|
|
||||||
colorsRecs[i].width = 100
|
|
||||||
colorsRecs[i].height = 100
|
|
||||||
selected[i] = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local mousePoint = Vector2(0, 0)
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
mousePoint = GetMousePosition()
|
|
||||||
|
|
||||||
for i = 1, NUM_RECTANGLES do -- Iterate along all the rectangles
|
|
||||||
if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) then
|
|
||||||
colors[i].a = 120
|
|
||||||
if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then selected[i] = not selected[i] end
|
|
||||||
else colors[i].a = 255 end
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
for i = 1, NUM_RECTANGLES do -- Draw all rectangles
|
|
||||||
DrawRectangleRec(colorsRecs[i], colors[i])
|
|
||||||
|
|
||||||
-- Draw four rectangles around selected rectangle
|
|
||||||
if (selected[i]) then
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE) -- Square top rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE) -- Square left rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE) -- Square right rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE) -- Square bottom rectangle
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Windows drop files
|
|
||||||
--
|
|
||||||
-- This example only works on platforms that support drag & drop (Windows, Linux, OSX)
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files")
|
|
||||||
|
|
||||||
local count = 0
|
|
||||||
local droppedFiles = {}
|
|
||||||
|
|
||||||
SetTargetFPS(60)
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
if (IsFileDropped()) then
|
|
||||||
droppedFiles = GetDroppedFiles()
|
|
||||||
count = #droppedFiles
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
if (count == 0) then DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
|
||||||
else
|
|
||||||
DrawText("Dropped files:", 100, 40, 20, DARKGRAY)
|
|
||||||
|
|
||||||
for i = 0, count-1 do
|
|
||||||
if (i%2 == 0) then DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5))
|
|
||||||
else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3)) end
|
|
||||||
|
|
||||||
DrawText(droppedFiles[i+1], 120, 100 + 40*i, 10, GRAY)
|
|
||||||
end
|
|
||||||
|
|
||||||
DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
ClearDroppedFiles() -- Clear internal buffers
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Gestures Detection
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MAX_GESTURE_STRINGS = 20
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection")
|
|
||||||
|
|
||||||
local touchPosition = Vector2(0, 0)
|
|
||||||
local touchArea = Rectangle(220, 10, screenWidth - 230, screenHeight - 20)
|
|
||||||
|
|
||||||
local gesturesCount = 0
|
|
||||||
local gestureStrings = {}
|
|
||||||
|
|
||||||
for i = 1, MAX_GESTURE_STRINGS do gestureStrings[i] = "" end
|
|
||||||
|
|
||||||
local currentGesture = Gestures.NONE
|
|
||||||
local lastGesture = Gestures.NONE
|
|
||||||
|
|
||||||
--SetGesturesEnabled(0b0000000000001001) -- Enable only some gestures to be detected
|
|
||||||
|
|
||||||
SetTargetFPS(60)
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
lastGesture = currentGesture
|
|
||||||
currentGesture = GetGestureDetected()
|
|
||||||
touchPosition = GetTouchPosition(0)
|
|
||||||
|
|
||||||
if (CheckCollisionPointRec(touchPosition, touchArea) and (currentGesture ~= Gestures.NONE)) then
|
|
||||||
if (currentGesture ~= lastGesture) then
|
|
||||||
-- Store gesture string
|
|
||||||
if (currentGesture == Gestures.TAP) then gestureStrings[gesturesCount] = "GESTURE TAP"
|
|
||||||
elseif (currentGesture == Gestures.DOUBLETAP) then gestureStrings[gesturesCount] = "GESTURE DOUBLETAP"
|
|
||||||
elseif (currentGesture == Gestures.HOLD) then gestureStrings[gesturesCount] = "GESTURE HOLD"
|
|
||||||
elseif (currentGesture == Gestures.DRAG) then gestureStrings[gesturesCount] = "GESTURE DRAG"
|
|
||||||
elseif (currentGesture == Gestures.SWIPE_RIGHT) then gestureStrings[gesturesCount] = "GESTURE SWIPE RIGHT"
|
|
||||||
elseif (currentGesture == Gestures.SWIPE_LEFT) then gestureStrings[gesturesCount] = "GESTURE SWIPE LEFT"
|
|
||||||
elseif (currentGesture == Gestures.SWIPE_UP) then gestureStrings[gesturesCount] = "GESTURE SWIPE UP"
|
|
||||||
elseif (currentGesture == Gestures.SWIPE_DOWN) then gestureStrings[gesturesCount] = "GESTURE SWIPE DOWN"
|
|
||||||
elseif (currentGesture == Gestures.PINCH_IN) then gestureStrings[gesturesCount] = "GESTURE PINCH IN"
|
|
||||||
elseif (currentGesture == Gestures.PINCH_OUT) then gestureStrings[gesturesCount] = "GESTURE PINCH OUT"
|
|
||||||
end
|
|
||||||
|
|
||||||
gesturesCount = gesturesCount + 1
|
|
||||||
|
|
||||||
-- Reset gestures strings
|
|
||||||
if (gesturesCount >= MAX_GESTURE_STRINGS) then
|
|
||||||
for i = 1, MAX_GESTURE_STRINGS do gestureStrings[i] = "\0" end
|
|
||||||
gesturesCount = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawRectangleRec(touchArea, GRAY)
|
|
||||||
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5))
|
|
||||||
|
|
||||||
for i = 1, gesturesCount do
|
|
||||||
if ((i - 1)%2 == 0) then DrawRectangle(10, 30 + 20*(i - 1), 200, 20, Fade(LIGHTGRAY, 0.5))
|
|
||||||
else DrawRectangle(10, 30 + 20*(i - 1), 200, 20, Fade(LIGHTGRAY, 0.3)) end
|
|
||||||
|
|
||||||
if (i < gesturesCount) then DrawText(gestureStrings[i], 35, 36 + 20*(i - 1), 10, DARKGRAY)
|
|
||||||
else DrawText(gestureStrings[i], 35, 36 + 20*(i - 1), 10, MAROON) end
|
|
||||||
end
|
|
||||||
|
|
||||||
DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY)
|
|
||||||
DrawText("DETECTED GESTURES", 50, 15, 10, GRAY)
|
|
||||||
|
|
||||||
if (currentGesture ~= GESTURE_NONE) then DrawCircleV(touchPosition, 30, MAROON) end
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Gamepad input
|
|
||||||
--
|
|
||||||
-- NOTE: This example requires a Gamepad connected to the system
|
|
||||||
-- raylib is configured to work with Xbox 360 gamepad, check raylib.h for buttons configuration
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input")
|
|
||||||
|
|
||||||
local texPs3Pad = LoadTexture("resources/ps3.png")
|
|
||||||
local texXboxPad = LoadTexture("resources/xbox.png")
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set target frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
-- ...
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
if (IsGamepadAvailable(GAMEPAD.PLAYER1)) then
|
|
||||||
DrawText(string.format("GP1: %s", GetGamepadName(GAMEPAD.PLAYER1)), 10, 10, 10, BLACK)
|
|
||||||
|
|
||||||
if (IsGamepadName(GAMEPAD.PLAYER1, "Xbox 360 Controller")) then
|
|
||||||
DrawTexture(texXboxPad, 0, 0, DARKGRAY)
|
|
||||||
|
|
||||||
-- Draw buttons: xbox home
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_HOME)) then DrawCircle(394, 89, 19, RED) end
|
|
||||||
|
|
||||||
-- Draw buttons: basic
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_START)) then DrawCircle(436, 150, 9, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_SELECT)) then DrawCircle(352, 150, 9, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_X)) then DrawCircle(501, 151, 15, BLUE) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_A)) then DrawCircle(536, 187, 15, LIME) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_B)) then DrawCircle(572, 151, 15, MAROON) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_Y)) then DrawCircle(536, 115, 15, GOLD) end
|
|
||||||
|
|
||||||
-- Draw buttons: d-pad
|
|
||||||
DrawRectangle(317, 202, 19, 71, BLACK)
|
|
||||||
DrawRectangle(293, 228, 69, 19, BLACK)
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_UP)) then DrawRectangle(317, 202, 19, 26, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_DOWN)) then DrawRectangle(317, 202 + 45, 19, 26, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_LEFT)) then DrawRectangle(292, 228, 25, 19, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_RIGHT)) then DrawRectangle(292 + 44, 228, 26, 19, RED) end
|
|
||||||
|
|
||||||
-- Draw buttons: left-right back
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_LB)) then DrawCircle(259, 61, 20, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_RB)) then DrawCircle(536, 61, 20, RED) end
|
|
||||||
|
|
||||||
-- Draw axis: left joystick
|
|
||||||
DrawCircle(259, 152, 39, BLACK)
|
|
||||||
DrawCircle(259, 152, 34, LIGHTGRAY)
|
|
||||||
DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_X)*20),
|
|
||||||
152 - (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_Y)*20), 25, BLACK)
|
|
||||||
|
|
||||||
-- Draw axis: right joystick
|
|
||||||
DrawCircle(461, 237, 38, BLACK)
|
|
||||||
DrawCircle(461, 237, 33, LIGHTGRAY)
|
|
||||||
DrawCircle(461 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RIGHT_X)*20),
|
|
||||||
237 - (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RIGHT_Y)*20), 25, BLACK)
|
|
||||||
|
|
||||||
-- Draw axis: left-right triggers
|
|
||||||
DrawRectangle(170, 30, 15, 70, GRAY)
|
|
||||||
DrawRectangle(604, 30, 15, 70, GRAY)
|
|
||||||
DrawRectangle(170, 30, 15, (((1.0 + GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LT))/2.0)*70), RED)
|
|
||||||
DrawRectangle(604, 30, 15, (((1.0 + GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RT))/2.0)*70), RED)
|
|
||||||
|
|
||||||
--DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LT)), 10, 40, 10, BLACK)
|
|
||||||
--DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RT)), 10, 60, 10, BLACK)
|
|
||||||
elseif (IsGamepadName(GAMEPAD.PLAYER1, "PLAYSTATION(R)3 Controller")) then
|
|
||||||
DrawTexture(texPs3Pad, 0, 0, DARKGRAY)
|
|
||||||
|
|
||||||
-- Draw buttons: ps
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_PS)) then DrawCircle(396, 222, 13, RED) end
|
|
||||||
|
|
||||||
-- Draw buttons: basic
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_SELECT)) then DrawRectangle(328, 170, 32, 13, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_START)) then DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_TRIANGLE)) then DrawCircle(557, 144, 13, LIME) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_CIRCLE)) then DrawCircle(586, 173, 13, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_CROSS)) then DrawCircle(557, 203, 13, VIOLET) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_SQUARE)) then DrawCircle(527, 173, 13, PINK) end
|
|
||||||
|
|
||||||
-- Draw buttons: d-pad
|
|
||||||
DrawRectangle(225, 132, 24, 84, BLACK)
|
|
||||||
DrawRectangle(195, 161, 84, 25, BLACK)
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_UP)) then DrawRectangle(225, 132, 24, 29, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_DOWN)) then DrawRectangle(225, 132 + 54, 24, 30, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_LEFT)) then DrawRectangle(195, 161, 30, 25, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_RIGHT)) then DrawRectangle(195 + 54, 161, 30, 25, RED) end
|
|
||||||
|
|
||||||
-- Draw buttons: left-right back buttons
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_L1)) then DrawCircle(239, 82, 20, RED) end
|
|
||||||
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_R1)) then DrawCircle(557, 82, 20, RED) end
|
|
||||||
|
|
||||||
-- Draw axis: left joystick
|
|
||||||
DrawCircle(319, 255, 35, BLACK)
|
|
||||||
DrawCircle(319, 255, 31, LIGHTGRAY)
|
|
||||||
DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_LEFT_X)*20),
|
|
||||||
255 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_LEFT_Y)*20), 25, BLACK)
|
|
||||||
|
|
||||||
-- Draw axis: right joystick
|
|
||||||
DrawCircle(475, 255, 35, BLACK)
|
|
||||||
DrawCircle(475, 255, 31, LIGHTGRAY)
|
|
||||||
DrawCircle(475 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_RIGHT_X)*20),
|
|
||||||
255 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_RIGHT_Y)*20), 25, BLACK)
|
|
||||||
|
|
||||||
-- Draw axis: left-right triggers
|
|
||||||
DrawRectangle(169, 48, 15, 70, GRAY)
|
|
||||||
DrawRectangle(611, 48, 15, 70, GRAY)
|
|
||||||
DrawRectangle(169, 48, 15, (((1.0 - GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_L2))/2.0)*70), RED)
|
|
||||||
DrawRectangle(611, 48, 15, (((1.0 - GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_R2))/2.0)*70), RED)
|
|
||||||
else
|
|
||||||
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY)
|
|
||||||
|
|
||||||
-- TODO: Draw generic gamepad
|
|
||||||
end
|
|
||||||
|
|
||||||
DrawText(string.format("DETECTED AXIS [%i]:", GetGamepadAxisCount(GAMEPAD.PLAYER1)), 10, 50, 10, MAROON)
|
|
||||||
|
|
||||||
for i = 1, GetGamepadAxisCount(GAMEPAD.PLAYER1) do -- Iterate along all the rectangles
|
|
||||||
DrawText(string.format("AXIS %i: %.02f", i, GetGamepadAxisMovement(GAMEPAD.PLAYER1, i)), 20, 70 + 20*i, 10, DARKGRAY)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (GetGamepadButtonPressed() ~= -1) then DrawText(string.format("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED)
|
|
||||||
else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY) end
|
|
||||||
else
|
|
||||||
DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY)
|
|
||||||
|
|
||||||
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
UnloadTexture(texPs3Pad) -- Unload gamepad texture
|
|
||||||
UnloadTexture(texXboxPad) -- Unload gamepad texture
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Keyboard input
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
|
|
||||||
|
|
||||||
local ballPosition = Vector2(screenWidth/2, screenHeight/2)
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set target frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
if (IsKeyDown(KEY.RIGHT)) then ballPosition.x = ballPosition.x + 0.8 end
|
|
||||||
if (IsKeyDown(KEY.LEFT)) then ballPosition.x = ballPosition.x - 0.8 end
|
|
||||||
if (IsKeyDown(KEY.UP)) then ballPosition.y = ballPosition.y - 0.8 end
|
|
||||||
if (IsKeyDown(KEY.DOWN)) then ballPosition.y = ballPosition.y + 0.8 end
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY)
|
|
||||||
|
|
||||||
DrawCircleV(ballPosition, 50, MAROON)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Mouse input
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input")
|
|
||||||
|
|
||||||
local ballPosition = Vector2(-100.0, -100.0)
|
|
||||||
local ballColor = DARKBLUE
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set target frames-per-second
|
|
||||||
-----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
ballPosition = GetMousePosition()
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then ballColor = MAROON
|
|
||||||
elseif (IsMouseButtonPressed(MOUSE.MIDDLE_BUTTON)) then ballColor = LIME
|
|
||||||
elseif (IsMouseButtonPressed(MOUSE.RIGHT_BUTTON)) then ballColor = DARKBLUE
|
|
||||||
end
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawCircleV(ballPosition, 40, ballColor)
|
|
||||||
|
|
||||||
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] examples - Mouse wheel
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel")
|
|
||||||
|
|
||||||
local boxPositionY = screenHeight/2 - 40
|
|
||||||
local scrollSpeed = 4 -- Scrolling speed in pixels
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set target frames-per-second
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
boxPositionY = boxPositionY - (GetMouseWheelMove()*scrollSpeed)
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON)
|
|
||||||
|
|
||||||
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY)
|
|
||||||
DrawText(string.format("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Oculus Rift CV1
|
|
||||||
--
|
|
||||||
-- NOTE: Example requires linkage with LibOVR
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 1080
|
|
||||||
local screenHeight = 600
|
|
||||||
|
|
||||||
-- NOTE: screenWidth/screenHeight should match VR device aspect ratio
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift")
|
|
||||||
|
|
||||||
-- NOTE: If device is not available, it fallbacks to default device (simulator)
|
|
||||||
InitVrDevice(VrDevice.OCULUS_RIFT_CV1) -- Init VR device (Oculus Rift CV1)
|
|
||||||
|
|
||||||
-- Define the camera to look into our 3d world
|
|
||||||
local camera = {}
|
|
||||||
camera.position = Vector3(5.0, 5.0, 5.0) -- Camera position
|
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
|
|
||||||
camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 60.0 -- Camera field-of-view Y
|
|
||||||
|
|
||||||
local cubePosition = Vector3(0.0, 0.0, 0.0)
|
|
||||||
|
|
||||||
SetTargetFPS(90) -- Set our game to run at 90 frames-per-second
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
UpdateVrTracking()
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY.SPACE)) then ToggleVrMode() end
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
Begin3dMode(camera)
|
|
||||||
|
|
||||||
DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
|
|
||||||
DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0)
|
|
||||||
|
|
||||||
End3dMode()
|
|
||||||
|
|
||||||
DrawFPS(10, 10)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
CloseVrDevice() -- Close VR device
|
|
||||||
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Generate random values
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values")
|
|
||||||
|
|
||||||
local framesCounter = 0 -- Variable used to count frames
|
|
||||||
|
|
||||||
local randValue = GetRandomValue(-8, 5) -- Get a random integer number between -8 and 5 (both included)
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
framesCounter = framesCounter + 1
|
|
||||||
|
|
||||||
-- Every two seconds (120 frames) a new random value is generated
|
|
||||||
if (((framesCounter/120)%2) == 1) then
|
|
||||||
randValue = GetRandomValue(-8, 5)
|
|
||||||
framesCounter = 0
|
|
||||||
end
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON)
|
|
||||||
|
|
||||||
DrawText(string.format("%i", randValue), 360, 180, 80, LIGHTGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
----------------------------------------------------------------------------------------
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
--
|
|
||||||
-- raylib [core] example - Storage save/load values
|
|
||||||
--
|
|
||||||
-- This example has been created using raylib 1.6 (www.raylib.com)
|
|
||||||
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
--
|
|
||||||
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
|
|
||||||
--
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- NOTE: Storage positions must start with 0, directly related to file memory layout
|
|
||||||
STORAGE_SCORE = 0
|
|
||||||
STORAGE_HISCORE = 1
|
|
||||||
|
|
||||||
-- Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
local screenWidth = 800
|
|
||||||
local screenHeight = 450
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values")
|
|
||||||
|
|
||||||
local score = 0
|
|
||||||
local hiscore = 0
|
|
||||||
|
|
||||||
local framesCounter = 0
|
|
||||||
|
|
||||||
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Main game loop
|
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
|
||||||
-- Update
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
if (IsKeyPressed(KEY.R)) then
|
|
||||||
score = GetRandomValue(1000, 2000)
|
|
||||||
hiscore = GetRandomValue(2000, 4000)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY.ENTER)) then
|
|
||||||
StorageSaveValue(STORAGE_SCORE, score)
|
|
||||||
StorageSaveValue(STORAGE_HISCORE, hiscore)
|
|
||||||
elseif (IsKeyPressed(KEY.SPACE)) then
|
|
||||||
-- NOTE: If requested position could not be found, value 0 is returned
|
|
||||||
score = StorageLoadValue(STORAGE_SCORE)
|
|
||||||
hiscore = StorageLoadValue(STORAGE_HISCORE)
|
|
||||||
end
|
|
||||||
|
|
||||||
framesCounter = framesCounter + 1
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Draw
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
BeginDrawing()
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE)
|
|
||||||
|
|
||||||
DrawText(string.format("SCORE: %i", score), 280, 130, 40, MAROON)
|
|
||||||
DrawText(string.format("HI-SCORE: %i", hiscore), 210, 200, 50, BLACK)
|
|
||||||
|
|
||||||
DrawText(string.format("frames: %i", framesCounter), 10, 10, 20, LIME)
|
|
||||||
|
|
||||||
DrawText("Press R to generate random numbers", 220, 40, 20, LIGHTGRAY)
|
|
||||||
DrawText("Press ENTER to SAVE values", 250, 310, 20, LIGHTGRAY)
|
|
||||||
DrawText("Press SPACE to LOAD values", 252, 350, 20, LIGHTGRAY)
|
|
||||||
|
|
||||||
EndDrawing()
|
|
||||||
---------------------------------------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
-- De-Initialization
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
CloseWindow() -- Close window and OpenGL context
|
|
||||||
-------------------------------------------------------------------------------------------
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue