I'm make game like mario and my code not working why i cant jump ;(
Posted: Sun Jul 31, 2022 9:32 am
function love.load()
window = love.window.setMode(800, 600, {resizable=false}) -- auto settings
wf = require "libraries/windfield"
world = wf.newWorld(0, 500)
world:addCollisionClass('solid')
ground = world:newRectangleCollider(0, 550, 800, 50)
ground:setCollisionClass('solid')
leftWall = world:newRectangleCollider(0, 0, 50, 600)
leftWall:setCollisionClass('solid')
rightWall = world:newRectangleCollider(750, 0, 50, 600)
rightWall:setCollisionClass('solid')
up = world:newRectangleCollider(0, 0, 800, 50)
up:setCollisionClass('solid')
rightWall:setType('static')
leftWall:setType('static')
ground:setType('static')
up:setType('static')
aopdoap = 1
playerS = {}
playerS.x = 250
playerS.y = 10
playerS.h = 100
playerS.w = 100
playerS.xV = 0
playerS.yV = 0
player = world:newRectangleCollider(playerS.x, playerS.y, playerS.w, playerS.h)
end
function love.update(dt)
world:update(dt)
if player:enter('solid') and love.keyboard.isDown('w') then
player:applyLinearImpulse(0, 4000)
end
end
function love.draw() --draw graphics
love.graphics.setColor(0/255, 255/255, 173/255)
world:draw()
end
function CheckCollision(x1,y1,w1,h1, x2,y2,w2,h2)
return x1 < x2+w2 and
x2 < x1+w1 and
y1 < y2+h2 and
y2 < y1+h1
end
window = love.window.setMode(800, 600, {resizable=false}) -- auto settings
wf = require "libraries/windfield"
world = wf.newWorld(0, 500)
world:addCollisionClass('solid')
ground = world:newRectangleCollider(0, 550, 800, 50)
ground:setCollisionClass('solid')
leftWall = world:newRectangleCollider(0, 0, 50, 600)
leftWall:setCollisionClass('solid')
rightWall = world:newRectangleCollider(750, 0, 50, 600)
rightWall:setCollisionClass('solid')
up = world:newRectangleCollider(0, 0, 800, 50)
up:setCollisionClass('solid')
rightWall:setType('static')
leftWall:setType('static')
ground:setType('static')
up:setType('static')
aopdoap = 1
playerS = {}
playerS.x = 250
playerS.y = 10
playerS.h = 100
playerS.w = 100
playerS.xV = 0
playerS.yV = 0
player = world:newRectangleCollider(playerS.x, playerS.y, playerS.w, playerS.h)
end
function love.update(dt)
world:update(dt)
if player:enter('solid') and love.keyboard.isDown('w') then
player:applyLinearImpulse(0, 4000)
end
end
function love.draw() --draw graphics
love.graphics.setColor(0/255, 255/255, 173/255)
world:draw()
end
function CheckCollision(x1,y1,w1,h1, x2,y2,w2,h2)
return x1 < x2+w2 and
x2 < x1+w1 and
y1 < y2+h2 and
y2 < y1+h1
end