Difference between revisions of "Love - Moving an object"
(→Requirements) |
(→Create a Player Object) |
||
Line 25: | Line 25: | ||
<syntaxhighlight lang=lua> | <syntaxhighlight lang=lua> | ||
player = { | 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. | 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 13:08, 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.