From 2f96ef6774585691ce6a9b83449f36a2681403b9 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 27 Jun 2016 15:06:27 +0200 Subject: More bounciness! --- player.lua | 2 +- world.lua | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/player.lua b/player.lua index 70446b4..48d7843 100644 --- a/player.lua +++ b/player.lua @@ -19,7 +19,7 @@ Player = { world = nil, -- game world -- Combat combo = 1, - lives = 3, + lives = 0, spawntimer = 0, alive = true, punchcd = 0, diff --git a/world.lua b/world.lua index 1e46c06..8da0d6b 100644 --- a/world.lua +++ b/world.lua @@ -29,8 +29,7 @@ World = { -- Gameplay status lastNaut = false, -- "WINNER" - win_angle = 0, - win_dir = 1 + win_move = 0 } -- Constructor of `World` ZA WARUDO! @@ -238,13 +237,17 @@ function World:update(dt) end end -- Bounce `winner` - if self.lastNaut then - if self.win_angle > 5 then self.win_dir = -1 - elseif self.win_angle < -5 then self.win_dir = 1 end - self.win_angle = self.win_angle + dt * self.win_dir * 16 + self.win_move = self.win_move + dt + if self.win_move > 2 then + self.win_move = self.win_move - 2 end end +function World:getBounce(f) + local f = f or 1 + return math.sin(self.win_move*f*math.pi) +end + -- Draw function World:draw() -- Camera stuff @@ -318,9 +321,12 @@ function World:draw() -- Draw winner if self.lastNaut then local w, h = love.graphics.getWidth()/scale, love.graphics.getHeight()/scale + local angle = self:getBounce(2) + local dy = self:getBounce()*3 love.graphics.setFont(Bold) - love.graphics.printf("WINNER",(w/2)*scale,(40)*scale,336,"center",self.win_angle*math.pi/180,scale,scale,168,12) + love.graphics.printf("WINNER",(w/2)*scale,(42+dy)*scale,336,"center",(angle*5)*math.pi/180,scale,scale,168,12) love.graphics.setFont(Font) + love.graphics.printf("rofl, now kill yourself", w/2*scale, 18*scale, 160, "center", 0, scale, scale, 80, 3) end end -- cgit v1.1