Page 1 of 1

Gun Image, and while true dos?

Posted: Mon Jul 24, 2017 6:40 pm
by seithw
Alright well ive been trying to add a while true do to my game with sleep time added to it, but it just keeps freezing up. Is there a way to weld a image together or something? If theres not I'm gonna just have to make another character with a gun in ps... Plz help ive been looking for a day and a half for something this small.

Re: Gun Image, and while true dos?

Posted: Mon Jul 24, 2017 9:46 pm
by veethree
Post your code. Makes it significantly easier for us to help you.

If you have a while true loop with love.timer.sleep() in it, I'd assume your game will be frozen until that loop stops.

As for welding an image together, You can just draw the first image at a certain position, then calculate where the 2nd one goes based on the first ones position.

Code: Select all

local x, y = 100, 100

love.graphics.draw(image, x, y)
love.graphics.draw(image, x + 10, y)

Re: Gun Image, and while true dos?

Posted: Mon Jul 24, 2017 10:05 pm
by OmegaMax
Posting code is the best way to get help instead of anyone having to guess what the problem is.

Re: Gun Image, and while true dos?

Posted: Mon Jul 24, 2017 11:10 pm
by raidho36
seithw wrote: Mon Jul 24, 2017 6:40 pm Alright well ive been trying to add a while true do to my game with sleep time added to it, but it just keeps freezing up.
Well yeah that's by design, that's what sleep function does - freezes the game for the duration you need, give or take, while freeing up CPU power to other programs.

Re: Gun Image, and while true dos?

Posted: Tue Jul 25, 2017 7:36 am
by zorg
Also, löve already has a while true do loop, in love.run, which is the game loop itself...

Re: Gun Image, and while true dos?

Posted: Wed Jul 26, 2017 5:28 am
by xNick1
If you want a timer just use two variables. TimePassed and TimeToPass. You increase TimePassed in love.update, and when it reaches TimeToPass you do what you want to do. Ex: I want the player to say "hello world" every 5 secs. Obviously you reset TimePassed to 0 once you entered the condition

Re: Gun Image, and while true dos?

Posted: Wed Jul 26, 2017 6:02 am
by MasterLee
Obviously not because then the player would say hello world in a rate of 5+x. Also you could decrease TimeToPass and than add the initial amount when TimeToPass is negativ or zero. So you could omit TimePassed.