The basic structure of the game is done as you can see in the following code:
That's just it, well... maybe! So let's play with these chunks one more time.
Now let's edit main.lua
to enable loading sample assets that we want to use within the game:
Before you go on and start coding your game, you need to give your video game some specs such as window width, window height, and window title. So set up a new file named
conf.lua
; inside it you can then create your game specs as shown in the following code snippet:
You can manipulate the figures and titles any way and also change that w
to whatever variable you want.
The preceding code does the following:
Basically we are using the
love.graphics
module; it can be used to draw (in the real sense) texts, images, and any drawable object in the scene. In the previous code snippets, we defined our fonts with the love.graphics.newFont(45)
that formats our text by declaring the size of the font as 45
. setFont()
loads the font we defined as myfont
, setColor()
colors the text in the RGB format, and setBackgroundColor()
sets the background.
Then we printed text using the love.graphics.print('text', x, y)
function in the draw
function with three parameters parsed in it: the text and the x and y coordinates. We are not going to do anything in the
love.update()
function yet, because we are not dealing with scene events.
So let's load our game as a .love
file and see what it displays: