Using the Love engine today, I tested some of its basic features.
Because it is the bottom of the library to encapsulate OpenGL graphics display, the efficiency of course is very high, and the efficiency of LUA itself is very high, the architecture of the special time the development of the game prototype, how to calculate the speed can not keep up with the C library for Lua call, it seems very convenient.
But the problem is also very obvious, this game engine documentation is really rotten, 0.9 version of the document did not know why the deletion of the majority, a lot of the previous blog to know the approximate usage.
The interaction of LUA and C
Ask some basic questions, such as how LUA interacts with C + +. Here is a good blog to write this question. "Lua script steps under C + +"
Actually very simple, LUA developers of course reserved the API interface, but C-style, I do not recommend C + + LUA binding, the engine LUA itself is the C series, C + + for Lua is too heavy, but trouble, I prefer the C + + implementation of the function, directly encapsulated into C function, For the game to call on it.
Simple example
OK, let's start with a simple example to show the engine, load a picture to a specified location, create a new empty folder as the project path, and a file below, main.lua
Note that the file name cannot be changed, and the love engine says he is looking for the entry script based on that name.
--Main.lua--Load Some default values for our rectangle. function love.load() X, Y, W, h =Ten,Ten, -,Ten; Buaa_logo = Love.graphics.newImage ("Res/image/buaa.jpg")End--Increase the size of the rectangle every frame. function love.update(DT) w = w +0.2; H = h +0.2;End--Draw a coloured rectangle. function love.draw() Love.graphics.draw (Buaa_logo, x, y)--Love.graphics.rectangle (' Fill ', X, Y, W, h);End
Of course, the resources I put under the project directory, the Love res/image
engine will rewrite the resource path to the current directory.
Execution mode:
In the project directory love .
, you can also refer to the official web packaging method
The effect is as follows:
Lua game engine Love trial