Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/leg joint feedback #43

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions silly-sam/sam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ function Sam:init(world, xSpawn, ySpawn)
self.leftLeg.fixture:setFriction(0.5)
self.leftLeg.color = {0.1, 0.4, 1}

-- join to chest
self.leftLeg.joint = love.physics.newWeldJoint(self.chest.body, self.leftLeg.body, spawn.x-20, spawn.y+25)
-- join to chest with a little wiggle room
self.leftLeg.joint = love.physics.newPrismaticJoint(
self.chest.body, self.leftLeg.body,
spawn.x+20, spawn.y+20,
spawn.x+20, spawn.y+20,
0, 1, true, 0)

self.leftLeg.joint:setLimitsEnabled(true)
self.leftLeg.joint:setLimits(-5, 5)

self.leftLeg.onGround = false

Expand All @@ -40,7 +47,14 @@ function Sam:init(world, xSpawn, ySpawn)
self.rightLeg.fixture:setFriction(0.5)
self.rightLeg.color = {0.7, 0.1, 0.1}

self.rightLeg.joint = love.physics.newWeldJoint(self.chest.body, self.rightLeg.body, spawn.x+20, spawn.y+25)
self.rightLeg.joint = love.physics.newPrismaticJoint(
self.chest.body, self.rightLeg.body,
spawn.x+20, spawn.y+20,
spawn.x+20, spawn.y+20,
0, 1, true, 0)

self.rightLeg.joint:setLimitsEnabled(true)
self.rightLeg.joint:setLimits(-5, 5)

self.rightLeg.onGround = false

Expand Down Expand Up @@ -84,9 +98,9 @@ function Sam:init(world, xSpawn, ySpawn)

-- this is for drawing
self.rectParts = {
self.chest,
self.leftLeg,
self.rightLeg,
self.chest,
self.leftArm,
self.rightArm,
}
Expand Down
6 changes: 5 additions & 1 deletion silly-sam/toys/hangingBag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ function HangingBag:init(world, xSpawn, ySpawn, ropeLength, bagWidth, bagHeight,
self.bagPivotPoint.color = {0.5, 0.5, 0.5}

-- join pivot to the anchor
self.anchor.joint = love.physics.newRevoluteJoint(self.anchor.body, self.bagPivotPoint.body, xSpawn, ySpawn)
self.anchor.joint = love.physics.newRopeJoint(
self.anchor.body, self.bagPivotPoint.body,
xSpawn, ySpawn,
self.bagPivotPoint.body:getX(), self.bagPivotPoint.body:getY(),
ropeLength, false)

-- join bag to pivot
self.bag.joint = love.physics.newRevoluteJoint(self.bag.body, self.bagPivotPoint.body, self.bagPivotPoint.body:getX(), self.bagPivotPoint.body:getY())
Expand Down