📜 ⬆️ ⬇️

Programming gaming applications on the Corona SDK: part 1


Important
This tutorial is designed for people who have experience of programming on Lua, if not, go to correct the situation. But it is also perfect for those who have never programmed Lua.

What is the Corona SDK?


Corona SDK is a cross-platform game engine that uses Lua to describe game logic.

Allows you to export applications for various platforms, including mobile.

The ability to export for such platforms:
')

Let's start!


We register on the official website , download the Corona SDK, there should be no problems with the installation. After installation, run the shortcut "Corona Simulator", which should appear on the desktop.

The project manager and special console will open.


Click "New project". Enter the name of the project, leave the rest as is, click on "OK".


This window should open.



And the project folder in the explorer.


We start programming


I use Notepad ++ to edit the code, but any other text editor will do.

Open the file "main.lua". After opening, you will see something like this.


I will use these images that I drew in the Graphics Gale program. You need to drop them into the root of the project folder.

Player.


Grass.



To begin with, we will connect physics, we will load images and we will assign coordinates for the player.

local physics = require("physics") physics.start() --  . player = display.newImage("player.png") --  . player.x = 100 player.y = 100 --   . physics.addBody(player,"dynamic") --    , "dynamic"  -    . 

Press Ctrl + S, if you did everything correctly, the player will start to fall down.


Add land


 grass_block={} --   for i=0,5 do grass_block[i]=display.newImage("grass.png") grass_block[i].x=grass_block[i].x+i*64 grass_block[i].y=player.y+100 physics.addBody(grass_block[i],"static") -- "static"  -  . end 

Result:


Conclusion


Here is such a brief lesson. In the next lesson, I will tell you how to make a player control, add a background, and tell you the details of settings for mobile platforms.

Source: https://habr.com/ru/post/318256/


All Articles