plane: fixed landing for both players
This commit is contained in:
parent
678fc91cf6
commit
4ebbfa3887
1 changed files with 16 additions and 3 deletions
|
@ -10,6 +10,19 @@ VectorLight = require 'hump/vector-light'
|
||||||
require 'utils'
|
require 'utils'
|
||||||
require 'machinegun'
|
require 'machinegun'
|
||||||
|
|
||||||
|
-- normalizes angle to be between [0 .. 2 pi[
|
||||||
|
local normalizeAngle = function(angle)
|
||||||
|
if angle < 0 then
|
||||||
|
angle = -angle
|
||||||
|
angle = angle - 2 * math.pi * math.floor(angle / (2 * math.pi))
|
||||||
|
angle = math.pi * 2 - angle
|
||||||
|
else
|
||||||
|
angle = angle - 2 * math.pi * math.floor(angle / (2 * math.pi))
|
||||||
|
end
|
||||||
|
return angle
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local CLANG_SFX = {
|
local CLANG_SFX = {
|
||||||
love.audio.newSource("resources/audio/clangs/cast iron clangs - Marker #1.wav"),
|
love.audio.newSource("resources/audio/clangs/cast iron clangs - Marker #1.wav"),
|
||||||
love.audio.newSource("resources/audio/clangs/cast iron clangs - Marker #2.wav"),
|
love.audio.newSource("resources/audio/clangs/cast iron clangs - Marker #2.wav"),
|
||||||
|
@ -199,9 +212,9 @@ Plane = Class{
|
||||||
|
|
||||||
wasHitBy = function(self, by)
|
wasHitBy = function(self, by)
|
||||||
if by:isinstance(Ground) then
|
if by:isinstance(Ground) then
|
||||||
local angle = self.body:getAngle()
|
local angle = normalizeAngle(self.body:getAngle())
|
||||||
if (not goingRight and (angle > -math.pi / 4 and angle < math.pi / 4)) or
|
if (self.goingRight and (angle > math.pi * 2 - math.pi / 4 or angle < math.pi / 4)) or
|
||||||
(goingRight and (angle > math.pi - math.pi / 4 and angle < math.pi + math.pi / 4)) then
|
(not self.goingRight and (angle > math.pi - math.pi / 4 and angle < math.pi + math.pi / 4)) then
|
||||||
-- don't die this time.
|
-- don't die this time.
|
||||||
else
|
else
|
||||||
self:receiveDamage(1000)
|
self:receiveDamage(1000)
|
||||||
|
|
Loading…
Reference in a new issue