Game Development Reference
In-Depth Information
In this sample, we'll have a bit of fun with the pitch:
count = 1
function love.load()
pop = love.audio.newSource("pop.ogg", "static")
end
function love.mousepressed(mx, my, mButton)
if mButton == "l" then
count = count + 1
if count>15 then count = 1 end
pop:setPitch(count/10)
love.audio.play(popSound)
end
setLooping :
Sample Game Code
This final section will give an example of a game that incorporates all of the topics covered in the
chapter. The example creates a picture-logic puzzle (aka nanogram puzzle), which is similar to a
crossword puzzle, except the player has to fill in squares with numbers instead of letters, based
on numerical clues that are provided. For example, if the clue is 2, it means that the row or column
contains two filled squares that are contiguous. A clue of 1,1 means that the row or column contains
two squares that are not contiguous and must have at least one blank square between them.
In our sample, we shall randomly create a puzzle for a 5×5 grid and create the clues, as shown in
Figure 11-12 .
squares = 5
_W = love.graphics:getWidth()
_H = love.graphics:getHeight()
math.randomseed(os.time())
local size = 400/squares
local boxes = {}
local solved = false
function make_board()
solved = false
 
Search WWH ::




Custom Search