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
I'm make game like mario and my code not working why i cant jump ;(
Re: I'm make game like mario and my code not working why i cant jump ;(
If you wrap the code with code tags on this forum then the formatting is better for us.
I suspect this bit of code is never true, or not true when you think it is.
I suspect this bit of code is never true, or not true when you think it is.
Code: Select all
if player:enter('solid')
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: I'm make game like mario and my code not working why i cant jump ;(
I think it may be that you're using 4000 instead of -4000. In love2d y coordinate 0 is the top of the screen not the bottom. Though also check what togFox said to be sure.
Re: I'm make game like mario and my code not working why i cant jump ;(
Yeah. True. 4000 is a vector straight down.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
Who is online
Users browsing this forum: No registered users and 3 guests