Good Morning/Evening, i have just 2 easy question.
1) What editor you use to write code?
2) i'm trying to program some stupid games,but i have a problem, i want to make an image move up 50 pixel and then, after 2 sec., the image have to go down, but i don't know how let the game to wait 2 sec, i have alredy tryed to use sleep function, but the game just freeze for 2 second, i need a code that count seconds.
I hope you understand what i wrote, thanks for the help.
2 quick noob questions (1 about compiling & 1 about coding)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: 2 quick noob questions (1 about compiling & 1 about codi
1) Editor choice depends on operating system. On Windows, I prefer Notepad++.
2) You need to read up on how dt works. In the above example, I add the time passed to a variable (timepassed) and when the time passed is greater than or equal to 2 seconds (our interval), I do three things. First, I take the now-excess seconds off, then I move the img by adding a predefined move variable (notice that move is negative, since up is negative in the Y axis). Lastly, I make move negative itself, so that in two more seconds we will go in the opposite direction.
2) You need to read up on how dt works.
Code: Select all
timepassed = 0
interval = 2
move = -50
function love.update(dt)
timepassed = timepassed + dt
if timepassed >= interval then
timepassed = timepassed - interval
imgposition = imgposition + move
move = -move
end
end
Kurosuke needs beta testers
Re: 2 quick noob questions (1 about compiling & 1 about codi
Re: 2 quick noob questions (1 about compiling & 1 about codi
Favourite text editor: Sublime Text 2 (free beta)
Also agree w/ tentus; start using dt from the very beginning; it's essential. (I made the mistake of ignoring it for a while)
Also agree w/ tentus; start using dt from the very beginning; it's essential. (I made the mistake of ignoring it for a while)
It was the best of times, it was the worst of times . . .
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests