Huge Impediment for me

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
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Huge Impediment for me

Post by Xoria »

This code is supposed to draw something when left mouse is clicked at the mouse location, but because I have a background that moves based on mouse position, I don't know how to make images seem to appear in the "new" appropriate position.

The background function is in function.lua

The uploader isn't working so: http://www.mediafire.com/?ynmkbyku2oh
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Huge Impediment for me

Post by Robin »

First: uploading didn't work because, well, it was too large ;)
Second: please upload .loves, people prefer that because they can run it much more easily.
Thirdly: don't put all functions in love.update. That is a huge clusterfuck, because the functions will be bound every freakin frame.
Fourthly: you can get the mouse position with love.mouse.getPosition(). Use as followed:

Code: Select all

local x, y = love.mouse.getPosition()
Or, in your case, replace this:

Code: Select all

if love.mouse.isDown("l") then
     showEarth = true
end
by this:

Code: Select all

if love.mouse.isDown("l") then
     showEarth = true
     earthX, earthY = love.mouse.getPosition()
end
and replace this:

Code: Select all

if showEarth == true then
------planetEARTH !
---moon(s)*
love.graphics.draw(planetEarth.moon.image,planetEarth.moon.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.moon.width,planetEarth.moon.height,16,16)

--Earth*
love.graphics.draw(planetEarth.image,planetEarth.x+camera.x,planetEarth.y+camera.y, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
--love.graphics.draw(planetEarth.image,planetEarth.x,planetEarth.y, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
end
by this:

Code: Select all

if showEarth then
    ---moon(s)*
    love.graphics.draw(planetEarth.moon.image,planetEarth.moon.x+camera.x+earthX,planetEarth.y+camera.y+earthY, math.rad(planetEarth.angle),planetEarth.moon.width,planetEarth.moon.height,16,16)

    --Earth*
    love.graphics.draw(planetEarth.image,planetEarth.x+camera.x+earthX,planetEarth.y+camera.y+earthY, math.rad(planetEarth.angle),planetEarth.width,planetEarth.height,16,16)
end
Disclaimer: I haven't tested this at all.
Help us help you: attach a .love.
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Re: Huge Impediment for me

Post by Xoria »

Wow, thanks to you, I ain't stuck anymore. Woot.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests