Book Image

L÷VE for Lua Game Programming

By : AKINLAJA DAMILARE JOSHUA
Book Image

L÷VE for Lua Game Programming

By: AKINLAJA DAMILARE JOSHUA

Overview of this book

L?ñVE is a game development framework for making 2D games using the Lua programming language. L?ñVE is totally free, and can be used in anything from friendly open-source hobby projects, to closed-source commercial ones. Using the Lua programming framework, one can use L?ñVE2D to make any sort of interesting games. L?ñVE for Lua Game Programming will quickly and efficiently guide you through how to develop a video game from idea to prototype. Even if you are new to game programming, with this book, you will soon be able to create as many game titles as you wish without stress. The L?ñVE framework is the quickest and easiest way to build fully-functional 2D video games. It leverages the Lua programming language, which is known to be one of the easiest game development languages to learn and use. With this book, you will master how to develop multi-platform games for Windows, Linux, and Mac OS X. After downloading and installing L?ñVE, you will learn by example how to draw 2D objects, animate characters using sprites, and how to create game physics and game world maps. L?ñVE for Lua Game Programming makes it easier and quicker for you to learn everything you need to know about game programming. If you're interested in game programming, then this book is exactly what you've been looking for.
Table of Contents (15 chapters)

Drawing 2D objects


LÖve's love.graphics module already has in-built functions for drawing specific shapes such as a circle, arc, and rectangle. So let's draw all these shapes in a single game. Create a new game folder, rename it as shapes, open a new main.lua file in this directory, and edit it by adding the following code:

function love.load() –--loads all we need in game

--- set color for our shapes RGB

   love.graphics.setColor(0, 0, 0, 225)

--- set the background color RGB

   love.graphics.setBackgroundColor(225, 153, 0)

end

function love.draw() –--function to display/draw content to screen

---draw circle with parameters(mode, x-pos, y-pos, radius, segments)

   love.graphics.circle("fill", 200, 300, 50, 50)

---draw rectangle with parameters(mode, x-pos, y-pos, width, height)

   love.graphics.rectangle("fill", 300, 300, 100, 100)

---draw an arc with parameters(mode,x-pos,y-pos,radius,angle1,angle2)

   love.graphics.arc("fill", 450, 300, 100, math.pi/5, math.pi/2)


end

By following...