Use rl.new instead of ffi.new in examples.

This commit is contained in:
TSnake41 2020-05-08 01:54:08 +02:00
parent 9707ec75bc
commit 8ffc943ee8
5 changed files with 15 additions and 26 deletions

View File

@ -36,8 +36,6 @@ applications, and to alter it and redistribute it freely, subject to the followi
3. This notice may not be removed or altered from any source distribution.
]]
local ffi = require "ffi"
local windowWidth = 512
local windowHeight = 512
local gameScreenWidth = 32
@ -59,20 +57,20 @@ while not rl.WindowShouldClose() do
rl.BeginTextureMode(target)
rl.ClearBackground(rl.WHITE)
rl.DrawTextEx(rl.GetFontDefault(), "Hello", ffi.new("Vector2", 4, 0), rl.GetFontDefault().baseSize, 1, ffi.new("Color", 0, 64, 255, 255))
rl.DrawTextEx(rl.GetFontDefault(), "it's", ffi.new("Vector2", 8, 10), rl.GetFontDefault().baseSize, 1, ffi.new("Color", 0, 64, 255, 255))
rl.DrawTextEx(rl.GetFontDefault(), "raylua", ffi.new("Vector2", 0, 20), rl.GetFontDefault().baseSize, 1, ffi.new("Color", 0, 64, 255, 255))
rl.DrawTextEx(rl.GetFontDefault(), "Hello", rl.new("Vector2", 4, 0), rl.GetFontDefault().baseSize, 1, rl.new("Color", 0, 64, 255, 255))
rl.DrawTextEx(rl.GetFontDefault(), "it's", rl.new("Vector2", 8, 10), rl.GetFontDefault().baseSize, 1, rl.new("Color", 0, 64, 255, 255))
rl.DrawTextEx(rl.GetFontDefault(), "raylua", rl.new("Vector2", 0, 20), rl.GetFontDefault().baseSize, 1, rl.new("Color", 0, 64, 255, 255))
rl.EndTextureMode()
rl.DrawTexturePro(
target.texture,
ffi.new("Rectangle", 0, 0, target.texture.width, -target.texture.height),
ffi.new("Rectangle",
rl.new("Rectangle", 0, 0, target.texture.width, -target.texture.height),
rl.new("Rectangle",
(rl.GetScreenWidth() - gameScreenWidth * scale) * 0.5,
(rl.GetScreenHeight() - gameScreenHeight * scale) * 0.5,
gameScreenWidth * scale, gameScreenHeight * scale
), ffi.new("Vector2", 0, 0), 0, rl.WHITE
), rl.new("Vector2", 0, 0), 0, rl.WHITE
)
for x=0,rl.GetScreenWidth(),16 do

View File

@ -1,5 +1,3 @@
local ffi = require "ffi"
local screenWidth = 800
local screenHeight = 450

View File

@ -1,5 +1,4 @@
local ffi = require "ffi"
local lua_color = ffi.new("Color", 3, 3, 128, 255)
local lua_color = rl.new("Color", 3, 3, 128, 255)
local width, height = 800, 450

View File

@ -1,5 +1,3 @@
local ffi = require "ffi"
local screenWidth = 800
local screenHeight = 450
@ -21,10 +19,10 @@ local rightSideRecHeight = 16
local state = 0
local alpha = 1.0
local lua_color = ffi.new("Color", 3, 3, 128, 255)
local lua_color = rl.new("Color", 3, 3, 128, 255)
local function Fade(color, alpha)
return ffi.new("Color",
return rl.new("Color",
color.r * alpha,
color.g * alpha,
color.b * alpha,

View File

@ -8,9 +8,6 @@
-- Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
--
--------------------------------------------------------------------------------------------
local ffi = require "ffi"
local bit = require "bit"
local MAX_BUNNIES = 100000 -- 100K bunnies limit
-- This is the maximum amount of elements (quads) per batch
@ -44,10 +41,10 @@ function Bunny:update(texture)
end
-- Initialization
----------------------------------------------------------------------------------------
local screenWidth = 800
local screenHeight = 450
----------------------------------------------------------------------------------------
local screenWidth = 800
local screenHeight = 450
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark")
@ -65,9 +62,8 @@ while not rl.WindowShouldClose() do -- Detect window close button or ESC key
-- Create more bunnies
for i = 1, 100 do
if #bunnies < MAX_BUNNIES then
local speed = ffi.new("Vector2", rl.GetRandomValue(-250, 250) / 60, rl.GetRandomValue(-250, 250) / 60)
local color = ffi.new("Color", rl.GetRandomValue(50, 240), rl.GetRandomValue(80, 240), rl.GetRandomValue(100, 240), 255)
--bunnies[#bunnies] = Bunny:new(nil, GetMousePosition(), speed, color)
local speed = rl.new("Vector2", rl.GetRandomValue(-250, 250) / 60, rl.GetRandomValue(-250, 250) / 60)
local color = rl.new("Color", rl.GetRandomValue(50, 240), rl.GetRandomValue(80, 240), rl.GetRandomValue(100, 240), 255)
table.insert(bunnies, Bunny:new(rl.GetMousePosition(), speed, color))
end
end