Difference between revisions of "Love - Moving an object"
(Created page with "=Requirements= You need to have followed the installation process for the Love engine. You also need to have created a minimal game (ie a new folder, with a 'main.lua' file)...") |
(→Requirements) |
||
Line 7: | Line 7: | ||
<syntaxhighlight lang=lua> | <syntaxhighlight lang=lua> | ||
+ | function love.load() | ||
+ | |||
+ | end | ||
+ | |||
function love.update(dt) | function love.update(dt) | ||
Line 14: | Line 18: | ||
end | end | ||
− | + | </syntaxhighlight> | |
− | + | ||
+ | =Create a Player Object= | ||
+ | This tutorial will create a player object, if you wanted to create a complete game then you would need to create a class for the player. So before 'love.load()' add the following code: | ||
− | + | <syntaxhighlight lang=lua> | |
+ | player = { | ||
+ | x = 100, | ||
+ | y = 100, | ||
+ | w = 10, | ||
+ | h = 10, | ||
+ | speed = 200 | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | This essentially creates a structure called player, this structure has an X position of 100, a Y position of 100, a w(width) of 10, a h(height) of 10, and a speed of 200. |
Revision as of 12:07, 4 June 2019
Requirements
You need to have followed the installation process for the Love engine.
You also need to have created a minimal game (ie a new folder, with a 'main.lua' file)
You need to have added this code to 'main.lua':
function love.load()
end
function love.update(dt)
end
function love.draw()
end
Create a Player Object
This tutorial will create a player object, if you wanted to create a complete game then you would need to create a class for the player. So before 'love.load()' add the following code:
player = {
x = 100,
y = 100,
w = 10,
h = 10,
speed = 200
}
This essentially creates a structure called player, this structure has an X position of 100, a Y position of 100, a w(width) of 10, a h(height) of 10, and a speed of 200.