some upgrades
This commit is contained in:
parent
f71db7a456
commit
022858330a
BIN
assets/images/backgrounds/gbyeblack.png
Normal file
BIN
assets/images/backgrounds/gbyeblack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
BIN
assets/images/backgrounds/level1_hires.png
Normal file
BIN
assets/images/backgrounds/level1_hires.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
1
libs/hump
Submodule
1
libs/hump
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 08937cc0ecf72d1a964a8de6cd552c5e136bf0d4
|
13
main.lua
13
main.lua
@ -4,12 +4,14 @@ peachy = require("libs/peachy")
|
||||
--load player
|
||||
player = require("modules/player")
|
||||
|
||||
--load hump camera
|
||||
Camera = require("libs/hump/camera")
|
||||
camera = Camera(player.x, player.y)
|
||||
|
||||
--load content_loader
|
||||
local content_loader = require("modules/content_loader")
|
||||
spritesheets = content_loader.spritesheets
|
||||
sound_effects = content_loader.sound_effects
|
||||
backgrounds = content_loader.backgrounds
|
||||
music = content_loader.music
|
||||
|
||||
--load globals
|
||||
local globals = require("modules/globals")
|
||||
@ -25,10 +27,13 @@ update_mod = require("modules/update_callback")
|
||||
local update_callback = update_mod.update
|
||||
local updateinit = update_mod.updateinit
|
||||
|
||||
drawerinit(spritesheets, player, game)
|
||||
updateinit(game)
|
||||
drawerinit(spritesheets, player, game, camera)
|
||||
updateinit(game, camera)
|
||||
player:init(sound_effects, spritesheets, game)
|
||||
|
||||
--play music for level
|
||||
game:getcurlevel().music:play()
|
||||
|
||||
function love.draw()
|
||||
draw_callback()
|
||||
end
|
||||
|
@ -15,22 +15,13 @@ spritesheets["player_die"] = peachy.new("assets/images/spritesheets/player.json"
|
||||
--load player DEFAULT
|
||||
spritesheets["player_default"] = peachy.new("assets/images/spritesheets/player.json", love.graphics.newImage("assets/images/spritesheets/player.png"), "Default")
|
||||
|
||||
--load backgrounds
|
||||
local backgrounds = {}
|
||||
for i, file in ipairs(love.filesystem.getDirectoryItems("assets/images/backgrounds")) do
|
||||
if file:find(".png") then
|
||||
--load backgrounds
|
||||
print(i)
|
||||
backgrounds[i] = love.graphics.newImage("assets/images/backgrounds/"..file)
|
||||
end
|
||||
end
|
||||
--load sound effects
|
||||
local sound_effects = {}
|
||||
for i, file in ipairs(love.filesystem.getDirectoryItems("assets/sounds/effects")) do
|
||||
for i, file in ipairs(love.filesystem.getDirectoryItems("assets/audio/effects")) do
|
||||
if file:find(".ogg") then
|
||||
--load sound effects
|
||||
local keyname = file:gsub(".ogg", "")
|
||||
sound = love.audio.newSource("assets/sounds/effects/"..file, "static")
|
||||
sound = love.audio.newSource("assets/audio/effects/"..file, "static")
|
||||
sound_effects[keyname] = {}
|
||||
sound_effects[keyname].volume = 1
|
||||
sound_effects[keyname].timer = love.timer.getTime()
|
||||
@ -48,17 +39,7 @@ for i, file in ipairs(love.filesystem.getDirectoryItems("assets/sounds/effects")
|
||||
end
|
||||
end
|
||||
end
|
||||
--load music
|
||||
local music = {}
|
||||
for i, file in ipairs(love.filesystem.getDirectoryItems("assets/sounds/music")) do
|
||||
if file:find(".ogg") then
|
||||
--load music
|
||||
music[file:sub(1, -5)] = love.audio.newSource("assets/sounds/music/"..file, "stream")
|
||||
end
|
||||
end
|
||||
return {
|
||||
spritesheets = spritesheets,
|
||||
backgrounds = backgrounds,
|
||||
sound_effects = sound_effects,
|
||||
music = music
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
local spritesheets = {}
|
||||
local player = {}
|
||||
local game = {}
|
||||
local camera = {}
|
||||
|
||||
function drawerinit(spritesheetst, playert, gamex)
|
||||
function drawerinit(spritesheetst, playert, gamex, camerax)
|
||||
spritesheets = spritesheetst
|
||||
player = playert
|
||||
game = gamex
|
||||
camera = camerax
|
||||
end
|
||||
|
||||
local function draw()
|
||||
camera:attach()
|
||||
--draw background
|
||||
love.graphics.draw(backgrounds[game.level], 0, 0)
|
||||
love.graphics.draw(game.levels[game.level].background, 0, 0)
|
||||
--draw player_animation
|
||||
player.animation:draw(player.x, player.y)
|
||||
if player.state == "idle" then
|
||||
@ -26,6 +29,7 @@ local function draw()
|
||||
else
|
||||
spritesheets["player_default"]:draw(player.x, player.y)
|
||||
end
|
||||
camera:detach()
|
||||
end
|
||||
return {
|
||||
drawerinit = drawerinit,
|
||||
|
@ -6,6 +6,19 @@ game.title = "Weeeeeeeee"
|
||||
game.version = "0.0.1"
|
||||
game.fullscreen = false
|
||||
game.level = 1
|
||||
game.level_count = 1
|
||||
game.levels = {}
|
||||
game.getcurlevel = function(self)
|
||||
return self.levels[self.level]
|
||||
end
|
||||
for i = 1, game.level_count, 1 do
|
||||
game.levels[i] = {}
|
||||
game.levels[i].background = love.graphics.newImage("assets/images/backgrounds/level".. i .."_hires.png")
|
||||
game.levels[i].width = game.levels[i].background:getWidth()
|
||||
game.levels[i].height = game.levels[i].background:getHeight()
|
||||
game.levels[i].music = love.audio.newSource("assets/audio/music/track".. i ..".ogg", "static")
|
||||
game.levels[i].music:setLooping(true)
|
||||
end
|
||||
|
||||
return {
|
||||
game = game
|
||||
|
@ -14,11 +14,13 @@ player.init = function(self, sound_effects, spritesheets, game)
|
||||
self.sound_effects = sound_effects
|
||||
self.spritesheets = spritesheets
|
||||
self.game = game
|
||||
self.x = self.game.width / 2 + 8
|
||||
self.y = self.game.height + 8
|
||||
player.animation = spritesheets["player_idle"]
|
||||
end
|
||||
|
||||
player.walk_right = function(self, dt)
|
||||
if self.x < self.game.width - self.width and self.alive then
|
||||
if self.x < self.game:getcurlevel().width - self.width - self.game.width - 8 and self.alive then
|
||||
self.x = self.x + self.speed * dt
|
||||
self.state = "walk_right"
|
||||
self.direction = "right"
|
||||
@ -26,7 +28,7 @@ player.walk_right = function(self, dt)
|
||||
end
|
||||
end
|
||||
player.walk_left = function(self, dt)
|
||||
if self.x > 0 and self.alive then
|
||||
if self.x > self.game.width / 2 + 8 and self.alive then
|
||||
self.x = self.x - self.speed * dt
|
||||
self.state = "walk_left"
|
||||
self.direction = "left"
|
||||
@ -34,7 +36,7 @@ player.walk_left = function(self, dt)
|
||||
end
|
||||
end
|
||||
player.jump = function(self, dt)
|
||||
if self.y > 0 and self.alive then
|
||||
if self.y > self.game.height / 2 + 8 and self.alive then
|
||||
self.y = self.y - self.jump_height * dt
|
||||
self.state = "jump"
|
||||
self.animation = self.spritesheets["player_jump"]
|
||||
@ -42,7 +44,7 @@ player.jump = function(self, dt)
|
||||
end
|
||||
end
|
||||
player.down = function(self, dt)
|
||||
if self.y < self.game.height - self.height and self.alive then
|
||||
if self.y < self.game:getcurlevel().height - self.height - self.game.height / 2 - 8 and self.alive then
|
||||
self.y = self.y + self.jump_height * dt
|
||||
self.state = "jump"
|
||||
self.animation = self.spritesheets["player_jump"]
|
||||
|
@ -1,7 +1,8 @@
|
||||
local game = {}
|
||||
|
||||
local function updateinit(gamex)
|
||||
local camera = {}
|
||||
local function updateinit(gamex, camerax)
|
||||
game = gamex
|
||||
camera = camerax
|
||||
end
|
||||
|
||||
local function update(dt)
|
||||
@ -48,8 +49,13 @@ local function update(dt)
|
||||
--revive player
|
||||
player.spritesheets["player_die"]:setFrame(1)
|
||||
player:revive(dt)
|
||||
end
|
||||
if key("x") then
|
||||
print("x: \""..player.x.."\"; y: \""..player.y.."\"")
|
||||
end
|
||||
end
|
||||
local dx,dy = (player.x - camera.x) / 2, (player.y - camera.y) / 2
|
||||
camera:move(dx, dy)
|
||||
end
|
||||
return {
|
||||
update = update,
|
||||
|
Loading…
Reference in New Issue
Block a user