I'm trying to make an object that always goes down go back up once it hits the bottom, and not stay still.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
JacKobOriginal
Prole
Posts: 11
Joined: Thu Mar 22, 2018 12:05 am
Location: Colombia
Contact:

I'm trying to make an object that always goes down go back up once it hits the bottom, and not stay still.

Post by JacKobOriginal »

I'm trying to figure out how to teleport a moving object to the top once it moves to the bottom, but every time I do this It always stays still.

Here's what the code sorta looks like:

Code: Select all

function love.load()
    objectimg = love.graphics.newImage("object.png")
    objecty = 50
    objectspeed = 100
end

function love.draw()
    love.graphics.draw(objectimg, 50, objecty)
end

function love.update(dt)
    objecty = objecty + objectspeed * dt
    if objecty > 600 then
        objecty = 0
    end
end
Follow my GameDev Twitter: https://twitter.com/qqnutgames
Play Lil Jingle: https://qqnut.itch.io/lil-jingle
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: I'm trying to make an object that always goes down go back up once it hits the bottom, and not stay still.

Post by pgimeno »

The code you have posted works for me. If that example works for you but in your actual code it does not work, it's nearly impossible to give any advice if you don't post it. All I can say is that your use of globals seems suspicious, so that'd be one thing to look into.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests