Gun Image, and while true dos?

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
seithw
Prole
Posts: 1
Joined: Mon Jul 24, 2017 6:23 pm

Gun Image, and while true dos?

Post 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.
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: Gun Image, and while true dos?

Post 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)
User avatar
OmegaMax
Prole
Posts: 12
Joined: Wed Jun 07, 2017 3:49 pm

Re: Gun Image, and while true dos?

Post by OmegaMax »

Posting code is the best way to get help instead of anyone having to guess what the problem is.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Gun Image, and while true dos?

Post 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.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Gun Image, and while true dos?

Post by zorg »

Also, löve already has a while true do loop, in love.run, which is the game loop itself...
Me and my stuff :3True 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.
User avatar
xNick1
Party member
Posts: 267
Joined: Wed Jun 15, 2016 8:27 am
Location: Rome, Italy

Re: Gun Image, and while true dos?

Post 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
MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: Gun Image, and while true dos?

Post 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.
Post Reply

Who is online

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