diff --git a/.gitignore b/.gitignore
index 68a0547..ab49171 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.DS_Store
Release/
.vscode/
-*.tiled-session
\ No newline at end of file
+*.tiled-session
+Scripts/
\ No newline at end of file
diff --git a/FMOD/Desktop/Master.bank b/FMOD/Desktop/Master.bank
new file mode 100644
index 0000000..d4047d3
Binary files /dev/null and b/FMOD/Desktop/Master.bank differ
diff --git a/FMOD/Desktop/Master.strings.bank b/FMOD/Desktop/Master.strings.bank
new file mode 100644
index 0000000..a201810
Binary files /dev/null and b/FMOD/Desktop/Master.strings.bank differ
diff --git a/Graphics/Animations/animation6.png b/Graphics/Animations/animation6.png
index 53d0bc7..92f2ed5 100644
Binary files a/Graphics/Animations/animation6.png and b/Graphics/Animations/animation6.png differ
diff --git a/Graphics/Fonts/CommonCase.ttf b/Graphics/Fonts/CommonCase.ttf
new file mode 100644
index 0000000..26d7197
Binary files /dev/null and b/Graphics/Fonts/CommonCase.ttf differ
diff --git a/Tiled/Maps/Exports/sample.lua b/Tiled/Maps/Exports/sample.lua
index 86ce952..4ed4114 100644
--- a/Tiled/Maps/Exports/sample.lua
+++ b/Tiled/Maps/Exports/sample.lua
@@ -5917,26 +5917,26 @@ return {
properties = {},
encoding = "lua",
data = {
- 0, 37, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 60, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 114, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 60, 53, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 114, 24, 34, 53, 53, 53, 53, 44, 0, 0, 0, 0, 6, 0, 0, 0, 6, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 60, 61, 61, 61, 61, 61, 34, 44, 0, 0, 0, 17, 0, 0, 56, 25, 57, 65, 0, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 114, 24, 195, 206, 206, 206, 61, 65, 0, 56, 57, 25, 57, 58, 0, 17, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 60, 61, 206, 205, 195, 195, 34, 44, 0, 0, 17, 0, 0, 56, 25, 57, 25, 58, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 60, 61, 61, 206, 61, 61, 23, 121, 0, 0, 28, 0, 0, 0, 17, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 114, 105, 105, 117, 105, 105, 121, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 60, 53, 53, 53, 53, 53, 44, 0, 0, 0, 0, 37, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 60, 61, 61, 61, 61, 61, 65, 0, 0, 0, 37, 35, 34, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 60, 61, 205, 194, 205, 61, 65, 0, 0, 0, 114, 24, 194, 34, 44, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 56, 70, 206, 205, 195, 206, 61, 65, 0, 0, 0, 0, 114, 24, 195, 34, 44, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 60, 61, 205, 206, 61, 61, 65, 0, 0, 0, 0, 0, 114, 24, 205, 34, 44, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 114, 24, 205, 23, 105, 105, 121, 0, 0, 0, 0, 0, 0, 114, 24, 23, 121, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 60, 61, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 121, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 114, 105, 36, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 23, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 24,
+ 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60,
+ 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60,
+ 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 35,
+ 34, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 61,
+ 61, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 24,
+ 61, 65, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 61, 205, 205, 194, 205, 195, 61,
+ 65, 0, 0, 0, 0, 37, 53, 53, 53, 53, 53, 53, 53, 53, 53, 44, 0, 0, 0, 0, 0, 0, 60, 61, 194, 194, 194, 206, 195, 61,
+ 34, 53, 53, 53, 53, 35, 61, 61, 61, 61, 61, 61, 61, 61, 61, 34, 53, 53, 53, 53, 53, 53, 35, 61, 61, 61, 61, 61, 61, 195
}
},
{
diff --git a/Tiled/Maps/sample.tmx b/Tiled/Maps/sample.tmx
index 471bd0d..409660e 100644
--- a/Tiled/Maps/sample.tmx
+++ b/Tiled/Maps/sample.tmx
@@ -7,26 +7,26 @@
-0,37,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,60,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,114,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,60,53,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,114,24,34,53,53,53,53,44,0,0,0,0,6,0,0,0,6,0,6,0,0,0,0,0,0,0,0,0,
-0,0,0,60,61,61,61,61,61,34,44,0,0,0,17,0,0,56,25,57,65,0,1,0,0,0,0,0,0,0,
-0,0,0,114,24,195,206,206,206,61,65,0,56,57,25,57,58,0,17,0,17,0,0,0,0,0,0,0,0,0,
-0,0,0,0,60,61,206,205,195,195,34,44,0,0,17,0,0,56,25,57,25,58,0,0,0,0,0,0,0,0,
-0,0,0,0,60,61,61,206,61,61,23,121,0,0,28,0,0,0,17,0,28,0,0,0,0,0,0,0,0,0,
-0,0,0,0,114,105,105,117,105,105,121,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,60,53,53,53,53,53,44,0,0,0,0,37,44,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,60,61,61,61,61,61,65,0,0,0,37,35,34,44,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,60,61,205,194,205,61,65,0,0,0,114,24,194,34,44,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,56,70,206,205,195,206,61,65,0,0,0,0,114,24,195,34,44,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,60,61,205,206,61,61,65,0,0,0,0,0,114,24,205,34,44,0,0,0,0,0,0,
-0,0,0,0,0,0,0,114,24,205,23,105,105,121,0,0,0,0,0,0,114,24,23,121,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,60,61,65,0,0,0,0,0,0,0,0,0,0,114,121,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,114,105,36,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,114,121,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+23,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,105,24,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,35,
+34,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,114,24,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+61,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+23,121,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,53,53,35,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,53,53,35,61,61,61,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,61,206,205,195,61,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,35,194,206,206,206,205,61,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,206,205,206,206,206,61,
+65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,61,205,205,194,205,195,61,
+65,0,0,0,0,37,53,53,53,53,53,53,53,53,53,44,0,0,0,0,0,0,60,61,194,194,194,206,195,61,
+34,53,53,53,53,35,61,61,61,61,61,61,61,61,61,34,53,53,53,53,53,53,35,61,61,61,61,61,61,195
diff --git a/actor.lua b/actor.lua
index bcda2da..2e69527 100644
--- a/actor.lua
+++ b/actor.lua
@@ -1,6 +1,7 @@
Actor = inherits(AnimatedSprite, {
dx = 0, dy = 0,
- xr = 0, yr = 0
+ xr = 0, yr = 0,
+ body = {}
})
local actor_mt = class(Actor)
@@ -8,13 +9,25 @@ local actor_mt = class(Actor)
function Actor:new(x, y, skins)
local o = AnimatedSprite:init(x, y, skins)
- return setmetatable(o, actor_mt)
+ local s = setmetatable(o, actor_mt)
+
+ s:adddefaultbox()
+
+ return s
end
function Actor:add(x, y, skins)
table.insert(p, Actor:new(x, y, skins))
end
+function Actor:addbox(w, h, xoff, yoff)
+ table.insert(self.body, Rectangle:new(self.x + (xoff or 0), self.y + (yoff or 0), w, h, xoff or 0, yoff or 0))
+end
+
+function Actor:adddefaultbox()
+ self:addbox(self.w, self.h)
+end
+
function Actor:movex(vel)
self.xr = self.xr + vel
local move = self.xr > 0 and math.floor(self.xr) or self.xr <= 0 and math.ceil(self.xr)
@@ -25,6 +38,7 @@ function Actor:movex(vel)
while move ~= 0 do
self.x = self.x + move
move = move - sign
+ self:updatebody()
end
end
end
@@ -39,11 +53,31 @@ function Actor:movey(vel)
while move ~= 0 do
self.y = self.y + move
move = move - sign
+ self:updatebody()
end
end
end
+function Actor:updatebody()
+ for _,box in pairs(self.body) do
+ box.x = self.x + box.xoff
+ box.y = self.y + box.yoff
+ end
+end
+
function Actor:update(dt)
self:animate(dt)
- self:movex(100 * dt)
+end
+
+function Actor:draw()
+ self:drawselfanim()
+ if love.keyboard.isDown("right") then
+ self:movex(1)
+ end
+
+ if showdebug then
+ for _,box in pairs(self.body) do
+ box:draw()
+ end
+ end
end
\ No newline at end of file
diff --git a/assets.lua b/assets.lua
index 8289b17..86ed6f1 100644
--- a/assets.lua
+++ b/assets.lua
@@ -45,4 +45,5 @@ end
function loadassets()
images = loadfolder("Graphics/Sprites", "image")
animations = loadfolder("Graphics/Animations", "anim")
+ fonts = loadfolder("Graphics/Fonts", "font")
end
\ No newline at end of file
diff --git a/collision.lua b/collision.lua
index febd077..357c217 100644
--- a/collision.lua
+++ b/collision.lua
@@ -1,4 +1,6 @@
-Rectangle = {}
+Rectangle = {
+ xoff = 0, yoff = 0
+}
local rectangle_mt = class(Rectangle)
function Rectangle:new(x, y, w, h)
diff --git a/main.lua b/main.lua
index 61dd856..6cbf654 100644
--- a/main.lua
+++ b/main.lua
@@ -13,11 +13,13 @@ sti = require("sti")
showdebug = true
debug = 0
-window = { w = 800, h = 600, scale = 1 }
+window = { w = 800, h = 600, scale = 1.65 }
camera = { x = 0, y = 0 }
-speed = { ideal = 1 / 60, multiplier = 1 }
+speed = { target = 1 / 60, multiplier = 1 }
+
+gamestate = { state = 0, main = 0, paused = 1 }
p = {}
@@ -34,40 +36,42 @@ end
function love.update(dt)
--calculate fixed timestep
- local rate = speed.ideal * dt * speed.multiplier * 30
+ local rate = speed.target * dt * speed.multiplier * 30
updatemouse()
- if love.keyboard.isDown("up") then window.scale = window.scale + rate end
- if love.keyboard.isDown("down") then window.scale = window.scale - rate end
+ if gamestate.state == gamestate.main then
- if love.keyboard.isDown("w") then camera.y = camera.y - rate * 100 end
- if love.keyboard.isDown("a") then camera.x = camera.x - rate * 100 end
- if love.keyboard.isDown("s") then camera.y = camera.y + rate * 100 end
- if love.keyboard.isDown("d") then camera.x = camera.x + rate * 100 end
-
- for _,v in pairs(p) do
- v:update(rate)
- end
+ if love.keyboard.isDown("up") then window.scale = window.scale + rate end
+ if love.keyboard.isDown("down") then window.scale = window.scale - rate end
+
+ if love.keyboard.isDown("w") then camera.y = camera.y - rate * 100 end
+ if love.keyboard.isDown("a") then camera.x = camera.x - rate * 100 end
+ if love.keyboard.isDown("s") then camera.y = camera.y + rate * 100 end
+ if love.keyboard.isDown("d") then camera.x = camera.x + rate * 100 end
+
+ for _,v in pairs(p) do
+ v:update(rate)
+ end
- debug = tostring(mouse.p) .. " " .. tostring(mouse.held)
+ end
mouse.op = mouse.p
end
function love.draw()
- love.graphics.push()
+ --set drawing offset to camera position
love.graphics.translate(camera.x * window.scale, camera.y * window.scale)
-
- love.graphics.circle("fill", mouse.x, mouse.y, 3)
-
+ --draw tiled map
map:draw(camera.x, camera.y, window.scale)
for _,v in pairs(p) do
v:draw()
end
- love.graphics.pop()
+ --draw mouse cursor
+ love.graphics.circle("fill", mouse.x, mouse.y, 3)
+
if showdebug then
love.graphics.print(tostring(debug))
end
diff --git a/sprite.lua b/sprite.lua
index 9450381..81e5d4b 100644
--- a/sprite.lua
+++ b/sprite.lua
@@ -10,6 +10,8 @@ function Sprite:init(x, y, image)
x = x, y = y,
image = images[image]
}
+ o.w = o.image:getWidth()
+ o.h = o.image:getHeight()
return o
end
@@ -60,6 +62,8 @@ function AnimatedSprite:init(x, y, skins)
end
o.anim = o.skins[1]
+ o.w = o.anim.image:getWidth() / o.anim.frames
+ o.h = o.anim.image:getHeight()
return o
end
@@ -105,12 +109,16 @@ function AnimatedSprite:swapanimation(anim)
end
end
-function AnimatedSprite:draw()
+function AnimatedSprite:drawselfanim()
love.graphics.draw(
self.anim.image, self.anim.quads[self.frame],
self.x * window.scale, self.y * window.scale, self.r,
(self.flipped and -1 or (not self.flipped and 1)) * window.scale, window.scale
)
+end
+
+function AnimatedSprite:draw()
+ self:drawselfanim()
if self.bounds ~= nil and showdebug then
self.bounds:draw()