REWORKED HOW THINGS ARE SCALED
speed values should be adjusted accordingly, but maybe i slipped some i changed: player acc arrow speed i intentionally didnt change: jump speed
This commit is contained in:
parent
1e1f9edb45
commit
b8b2525975
|
@ -129,8 +129,8 @@ function Kupo:HandleAnimation()
|
||||||
DrawAnimationFrame(
|
DrawAnimationFrame(
|
||||||
self.bow,
|
self.bow,
|
||||||
math.min(self.bow_frame,self.bow_frames),
|
math.min(self.bow_frame,self.bow_frames),
|
||||||
self.pos.x + ( 8 * math.sin(self.bow_rotation)) * game.scale,
|
self.pos.x + ( 8 * math.sin(self.bow_rotation)),
|
||||||
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)) * game.scale,
|
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
|
||||||
self.bow_rotation
|
self.bow_rotation
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
y = 0
|
y = 0
|
||||||
}
|
}
|
||||||
-- constants
|
-- constants
|
||||||
o.acc = 90
|
o.acc = 45
|
||||||
o.friction = 20
|
o.friction = 20
|
||||||
o.gravity = 9.81
|
o.gravity = 9.81
|
||||||
o.climbHeight = 4
|
o.climbHeight = 4
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
-- bools
|
-- bools
|
||||||
o.isJumping = false
|
o.isJumping = false
|
||||||
o.isOnGround = 0
|
o.isOnGround = 0
|
||||||
o.coyoteValue = 10
|
o.coyoteValue = 5
|
||||||
o.isOnLadder = false
|
o.isOnLadder = false
|
||||||
o.canJump = true
|
o.canJump = true
|
||||||
o.canFall = true
|
o.canFall = true
|
||||||
|
@ -147,7 +147,7 @@ function Player:DoPhysics()
|
||||||
self.vel.y = 0
|
self.vel.y = 0
|
||||||
self.vel.x = 0
|
self.vel.x = 0
|
||||||
|
|
||||||
self.pos.y = self.pos.y - 4*game.scale * current_dt
|
self.pos.y = self.pos.y - 4 * current_dt
|
||||||
|
|
||||||
self.canFall = false
|
self.canFall = false
|
||||||
self.canJump = false
|
self.canJump = false
|
||||||
|
@ -159,11 +159,11 @@ function Player:DoPhysics()
|
||||||
|
|
||||||
-- checks for slopes
|
-- checks for slopes
|
||||||
for i = 1, self.climbHeight do
|
for i = 1, self.climbHeight do
|
||||||
if not isThereCollisionAt(self.pos.x + self.vel.x, self.pos.y - i * game.scale)
|
if not isThereCollisionAt(self.pos.x + self.vel.x, self.pos.y - i)
|
||||||
and self.isOnGround > 0 then
|
and self.isOnGround > 0 then
|
||||||
|
|
||||||
self.pos.x = self.pos.x + self.vel.x * 4/5
|
self.pos.x = self.pos.x + self.vel.x * 4/5
|
||||||
self.pos.y = self.pos.y - i * game.scale
|
self.pos.y = self.pos.y - i
|
||||||
|
|
||||||
self.canFriction = false
|
self.canFriction = false
|
||||||
break
|
break
|
||||||
|
|
|
@ -28,8 +28,8 @@ function Entity:Draw()
|
||||||
if self.sprite ~= nil then
|
if self.sprite ~= nil then
|
||||||
local relative_position_x = self.pos.x - Camera.pos.x
|
local relative_position_x = self.pos.x - Camera.pos.x
|
||||||
local relative_position_y = self.pos.y - Camera.pos.y
|
local relative_position_y = self.pos.y - Camera.pos.y
|
||||||
local origin_compensation_x = - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * game.scale
|
local origin_compensation_x = - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation))
|
||||||
local origin_compensation_y = - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * game.scale
|
local origin_compensation_y = - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation))
|
||||||
local dimensions_x = self.sprite_scale.x * self.sprite_flip.x
|
local dimensions_x = self.sprite_scale.x * self.sprite_flip.x
|
||||||
local dimensions_y = self.sprite_scale.y * self.sprite_flip.y
|
local dimensions_y = self.sprite_scale.y * self.sprite_flip.y
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
|
@ -37,8 +37,8 @@ function Entity:Draw()
|
||||||
relative_position_x + origin_compensation_x * dimensions_x,
|
relative_position_x + origin_compensation_x * dimensions_x,
|
||||||
relative_position_y + origin_compensation_y * dimensions_y,
|
relative_position_y + origin_compensation_y * dimensions_y,
|
||||||
self.sprite_rotation,
|
self.sprite_rotation,
|
||||||
game.scale * self.sprite_scale.x * self.sprite_flip.x,
|
self.sprite_scale.x * self.sprite_flip.x,
|
||||||
game.scale * self.sprite_scale.y * self.sprite_flip.y
|
self.sprite_scale.y * self.sprite_flip.y
|
||||||
)
|
)
|
||||||
if debug_collision then
|
if debug_collision then
|
||||||
love.graphics.setColor(1, 0, 0)
|
love.graphics.setColor(1, 0, 0)
|
||||||
|
@ -78,8 +78,8 @@ function DrawAnimationFrame(animation, frame, x, y, rotate, sx, sy)
|
||||||
x - Camera.pos.x,
|
x - Camera.pos.x,
|
||||||
y - Camera.pos.y,
|
y - Camera.pos.y,
|
||||||
rotate,
|
rotate,
|
||||||
game.scale * sx,
|
sx,
|
||||||
game.scale * sy
|
sy
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ function DrawAnimation(animation, x, y, rotate, sx, sy)
|
||||||
x - Camera.pos.x,
|
x - Camera.pos.x,
|
||||||
y - Camera.pos.y,
|
y - Camera.pos.y,
|
||||||
rotate,
|
rotate,
|
||||||
game.scale * sx,
|
sx,
|
||||||
game.scale * sy
|
sy
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,6 @@ levelProperties = {
|
||||||
tileProperties = {
|
tileProperties = {
|
||||||
width = 16,
|
width = 16,
|
||||||
height = 16,
|
height = 16,
|
||||||
scale = game.scale,
|
scale = 1,
|
||||||
tileset = love.graphics.newImage("assets/terrain/tileset.png")
|
tileset = love.graphics.newImage("assets/terrain/tileset.png")
|
||||||
}
|
}
|
||||||
|
|
15
main.lua
15
main.lua
|
@ -11,7 +11,7 @@ function love.load()
|
||||||
love.keyboard.setKeyRepeat(true)
|
love.keyboard.setKeyRepeat(true)
|
||||||
love.graphics.setDefaultFilter("nearest") -- good pixel
|
love.graphics.setDefaultFilter("nearest") -- good pixel
|
||||||
game = {
|
game = {
|
||||||
scale = 1,
|
scale = 2,
|
||||||
width = love.graphics.getWidth(),
|
width = love.graphics.getWidth(),
|
||||||
height = love.graphics.getHeight(),
|
height = love.graphics.getHeight(),
|
||||||
paused = false
|
paused = false
|
||||||
|
@ -26,8 +26,8 @@ function love.load()
|
||||||
main_Player = Player:New(1220,220)
|
main_Player = Player:New(1220,220)
|
||||||
LoadedEntities = {}
|
LoadedEntities = {}
|
||||||
table.insert(LoadedEntities,main_Player)
|
table.insert(LoadedEntities,main_Player)
|
||||||
table.insert(LoadedEntities,Kupo:New(700,200))
|
table.insert(LoadedEntities,Kupo:New(450,100))
|
||||||
table.insert(LoadedEntities,Kupo:New(500,300))
|
table.insert(LoadedEntities,Kupo:New(250,150))
|
||||||
main_Player.sprite = love.graphics.newImage("assets/characters/nancy/idle1.png")
|
main_Player.sprite = love.graphics.newImage("assets/characters/nancy/idle1.png")
|
||||||
main_Player:LoadAnimation(animation.nancy.idle)
|
main_Player:LoadAnimation(animation.nancy.idle)
|
||||||
end
|
end
|
||||||
|
@ -102,6 +102,8 @@ function love.keypressed(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
|
-- GAME WORLD
|
||||||
|
love.graphics.scale(game.scale,game.scale)
|
||||||
LevelDisplayBackground()
|
LevelDisplayBackground()
|
||||||
for _, enty in pairs(LoadedEntities) do
|
for _, enty in pairs(LoadedEntities) do
|
||||||
enty:HandleAnimation()
|
enty:HandleAnimation()
|
||||||
|
@ -112,11 +114,14 @@ function love.draw()
|
||||||
|
|
||||||
-- Save color
|
-- Save color
|
||||||
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||||
|
|
||||||
|
-- HUD
|
||||||
|
love.graphics.scale(1,1)
|
||||||
-- Scale control
|
-- Scale control
|
||||||
if game.height > game.width then
|
if game.height > game.width then
|
||||||
textScale = game.height/480
|
textScale = game.height/480/2
|
||||||
else
|
else
|
||||||
textScale = game.width/640
|
textScale = game.width/640/2
|
||||||
end
|
end
|
||||||
|
|
||||||
--debug
|
--debug
|
||||||
|
|
Loading…
Reference in New Issue