mousepressed vs. mouse.isDown PowerUp

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
TheDeskPop
Prole
Posts: 10
Joined: Fri Dec 28, 2012 6:23 pm
Contact:

mousepressed vs. mouse.isDown PowerUp

Post by TheDeskPop »

Scenario Normal: When a user hits an entity:

Code: Select all

function love.mousepressed( x, y, button )
     if button == "l" then 
     ents.shoot(x, y)
end
Scenario wished for: For specific entity when killed or hit I wish to grant a power up.
I think this will come from love.mouse.isDown ("l") with a random number associated with dt in love.update and function Powerup
The random number associated with dt will be so that the Powerup does not last forever.

I have searched, tried, and have not been able to solve this. I hate asking for code but if anyone has any pointers I would be grateful!
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: mousepressed vs. mouse.isDown PowerUp

Post by OmarShehata »

I'm not sure what you mean by a random number and dt and all that, do you simply want that when an enemy is killed, the player gets a power that he can use whenever he wants?

If so, you just need to create a table called "Powerups" for example. And whenever you want to grant a power, do:

Code: Select all

--when enemy dies
Powerups["BigCannon"] = true;
And then

Code: Select all

function love.mousepressed( x, y, button )
     if(button == "l" and Powerups["BigCannon"] == true) then
     --fire big cannon
    Powerups["BigCannon"] = false;
end
So the BigCannon will only fire when you've gained the power up and press "l".

If you want the powerups to be cumulative (i.e you can gain several powerups) just store a number in the table instead of "true" or "false"

Did that make any sense? If you need any more help, or if that's not what you were asking for, feel free to ask again!
User avatar
TheDeskPop
Prole
Posts: 10
Joined: Fri Dec 28, 2012 6:23 pm
Contact:

Re: mousepressed vs. mouse.isDown PowerUp

Post by TheDeskPop »

That is close to what I need. However the numbers would be a number so that the PowerUp does not last forever. I need it to somehow go away after being used.

The reason I mentioned mouse.isDown is because I want the user to be able to hold the mouse button down for continuous fire after killing the PowerUp enemy.
So in other words after killing the PowerUp enemy it would then grant automatic fire rather than single shot fire.
Post Reply

Who is online

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