Lua game engine Love trial

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.