Page 1 of 1

2 quick noob questions (1 about compiling & 1 about coding)

Posted: Sun Mar 18, 2012 5:28 pm
by cris9696
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.

Re: 2 quick noob questions (1 about compiling & 1 about codi

Posted: Sun Mar 18, 2012 5:46 pm
by tentus
1) Editor choice depends on operating system. On Windows, I prefer Notepad++.

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

Re: 2 quick noob questions (1 about compiling & 1 about codi

Posted: Sun Mar 18, 2012 7:13 pm
by veethree
You can use just about any text editor to open and edit .lua files, But i'm with tentus on this, Notepad++ is the shit. You can get an auto complete configuration thing for it here And instructions on how to install it here

Re: 2 quick noob questions (1 about compiling & 1 about codi

Posted: Sun Mar 18, 2012 9:48 pm
by Refpeuk
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)