Commit da07e987 by anshve

Upload New File

parent ffee3f2b
Showing with 85 additions and 0 deletions
require 'src/Dependencies'
-- love.load is a constructor what called just once at the beginning of the game
function love.load()
math.randomseed(os.time())
love.graphics.setDefaultFilter('nearest', 'nearest')
love.window.setTitle(TITLE)
gSounds = {
['paddle_hit'] = love.audio.newSource('sounds/paddle_hit.wav', 'static'),
['point_scored'] = love.audio.newSource('sounds/point_scored.wav', 'static'),
['wall_hit'] = love.audio.newSource('sounds/wall_hit.wav', 'static'),
['select'] = love.audio.newSource('sounds/select.wav', 'static')
}
gStateMachine = StateMachine {
['menu'] = function() return MenuState() end,
['serve'] = function() return ServeState() end,
['play'] = function() return PlayState() end,
['victory'] = function() return VictoryState() end,
}
gFonts = {
['small'] = love.graphics.newFont('fonts/font.ttf', 8),
['medium'] = love.graphics.newFont('fonts/font.ttf', 16),
['large'] = love.graphics.newFont('fonts/font.ttf', 32)
}
love.graphics.setFont(gFonts['small'])
gTextures = {
['background-1'] = love.graphics.newImage('graphics/background-1.jpg'),
['background-2'] = love.graphics.newImage('graphics/background-2.jpg'),
['background-3'] = love.graphics.newImage('graphics/background-3.jpg'),
}
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
vsync = true,
fullscreen = false,
resizable = true
})
gStateMachine:change('menu', {})
love.keyboard.keysPressed = {}
end
-- love.resize called whenever we change the dimensions of our window
function love.resize(w, h)
push:resize(w, h)
end
-- love.update called every frame
function love.update(dt)
gStateMachine:update(dt)
if love.keyboard.wasPressed('escape') then
love.event.quit()
end
love.keyboard.keysPressed = {}
end
-- love.keypressed is a callback that processes key strokes as they happen, just once
function love.keypressed(key)
love.keyboard.keysPressed[key] = true
end
-- love.keyboard.wasPressed is a custom function that will let us test for individual keystrokes outside of the default `love.keypressed` callback
function love.keyboard.wasPressed(key)
if love.keyboard.keysPressed[key] then
return true
else
return false
end
end
-- love.draw called each frame after update to draw all game objects
function love.draw()
push:apply('start')
gStateMachine:render()
push:apply('end')
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment