Love - Moving an object

From TRCCompSci - AQA Computer Science
Revision as of 13:07, 4 June 2019 by Admin (talk | contribs) (Requirements)
Jump to: navigation, search

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.