Skip to content

Commit

Permalink
Merge pull request #2 from zurgeg/add-roation-gimmick
Browse files Browse the repository at this point in the history
Add rotation gimmick
  • Loading branch information
zurgeg authored May 26, 2022
2 parents 2615b3e + d838b7b commit dc4a602
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion gameScene/sprites.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,31 @@ end

function UpdateSprites()
movedThisFrame = false

local crankDelta = playdate.getCrankChange()
if not hasUpdated then
hasUpdated = true
playdate.graphics.sprite.update()
end
if ((playdate.buttonJustPressed(playdate.kButtonA) or playdate.buttonJustPressed(playdate.kButtonB) or playdate.buttonJustPressed(playdate.kButtonUp)) and IsGrounded(catSprite, boxSprite) and not JumpingSprites["cat"]) or JumpingSprites["cat"] then
catSprite:pauseAnimation()
movedThisFrame = true
if crankDelta ~= 0 then
local catRotation = catSprite:getRotation()
local newCatRotation = catRotation + crankDelta
catSprite:setRotation(newCatRotation)
end
if IsGrounded(catSprite, boxSprite) and not JumpingSprites["cat"] then
SetJumpForce("cat", 10)
end
ApplyJumpForce(catSprite, "cat")
playdate.graphics.sprite.update()
catSprite:playAnimation()
end
if IsGrounded(catSprite, boxSprite) and catSprite:getRotation() ~= 0 then
-- todo: the player should die if they land on the box and are rotated
catSprite:setRotation(0)
JumpingSprites["cat"] = false
end
if playdate.buttonIsPressed(playdate.kButtonLeft) then
catSprite.globalFlip = gfx.kImageFlippedX
if not JumpingSprites["cat"] then
Expand Down
2 changes: 1 addition & 1 deletion physics/spriteCollision.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function ApplyJumpForce(sprite, spritename)
if not JumpingSprites[spritename] and force ~= 0 then
JumpingSprites[spritename] = true
end
if force ~= 0 then
if force > 0 then
MoveWithGravity(sprite, 0, -force)
else
JumpingSprites[spritename] = false
Expand Down

0 comments on commit dc4a602

Please sign in to comment.