## Gun Image, and while true dos?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
seithw
Prole
Posts: 1
Joined: Mon Jul 24, 2017 6:23 pm

### Gun Image, and while true dos?

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.

veethree
Inner party member
Posts: 820
Joined: Sat Dec 10, 2011 7:18 pm

### Re: Gun Image, and while true dos?

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)

OmegaMax
Prole
Posts: 12
Joined: Wed Jun 07, 2017 3:49 pm

### Re: Gun Image, and while true dos?

Posting code is the best way to get help instead of anyone having to guess what the problem is.

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Gun Image, and while true dos?

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.

zorg
Party member
Posts: 2983
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: Gun Image, and while true dos?

Also, löve already has a while true do loop, in love.run, which is the game loop itself...
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

xNick1
Party member
Posts: 265
Joined: Wed Jun 15, 2016 8:27 am
Location: Rome, Italy

### Re: Gun Image, and while true dos?

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
Currently working on a lucid dreaming adventure called Aarstider: http://bit.ly/2mXmgPI

MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

### Re: Gun Image, and while true dos?

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.

### Who is online

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