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

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
cris9696
Prole
Posts: 1
Joined: Sun Mar 18, 2012 5:19 pm

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

Post 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.
User avatar
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

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

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

Post 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
User avatar
Refpeuk
Citizen
Posts: 91
Joined: Wed Dec 14, 2011 6:16 pm

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

Post 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)
It was the best of times, it was the worst of times . . .
Post Reply

Who is online

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