1
function love.collide ()
  if x < 0 then
    x = 0
  end

  if x < love.graphics.getWidth () - Dolphin:getWidth () then
  x = love.graphics.getWidth () - Dolphin:getWidth ()
  end

end

I'm trying to make an x coordinate collision and I have already defined x previously. There is no error but the collision fails to work.

2 Answers 2

1

I think you mean x > love.graphic.getWidth() - Dolphin:getWidth(). Because otherwise your Dolphin should always be stuck at the right-hand boundary.

Sign up to request clarification or add additional context in comments.

Comments

0

I assume that you want to detect the collision between your object (Dolphin) and the boundary of the screen, but you are not comparing the position of the object (which changes); instead you compare the width of the object, which probably doesn't change.

1 Comment

When I use getWidth, I'm getting the width of my window size not the width of the object. However, I did get this to work simply by changing it to function love.update

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.