## Help! New User!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

### Help! New User!

Hi, Im MicroMacro, but you can call me Eric.

I just started with love, but am not sure how to use it. I know how to use Lua, but what do I put in the main.lua file to make my .love file work?

Also, does everything need to be in functions, and do I need to do this:

Code: Select all

function hello()
code
end

hello()
Thanks! I really hope to start working on games with love. I really understand how the API itself works, I just need help getting started. Thanks!
https://github.com/ebernerd- where you can find all my work.

Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: Help! New User!

gestaltist
Prole
Posts: 49
Joined: Thu May 29, 2014 10:56 am

### Re: Help! New User!

Hey Eric.

http://love2d.org/wiki/Tutorial:Callback_Functions

You only put callback functions in your main.lua file. You don’t invoke them - Love does it for you.

CaptainMaelstrom
Party member
Posts: 157
Joined: Sat Jan 05, 2013 10:38 pm

### Re: Help! New User!

To add what others have said, pay particular attention to love.load, love.update, and love.draw

Code: Select all

function love.load()
str = 'Hello'
end

function love.draw()
love.graphics.print(str,20,20)
end


Chron
Prole
Posts: 2
Joined: Wed Dec 25, 2013 6:55 pm

### Re: Help! New User!

Welcome, Eric! I hope you enjoy your stay

I suggest that you do a few tutorials in order to become more familiar with the Löve framwork. This platformer tutorial on ExplodingRabbit has really helped me when I started out. I believe there are some small issues when using it with Löve 0.9.0, but I suggest you to either try and fix it yourself (which would be perfect, since you'd also learn something while doing it) or ask here if you just can't figure it out.

Some more great tutorials: http://www.headchant.com/love-tutorials/, http://nova-fusion.com/2011/06/14/a-gui ... th-love2d/, http://nova-fusion.com/2011/04/19/camer ... he-basics/. As already mentioned, the Löve wiki is also very helpful.

When doing any of these tutorials, don't just read it, code it (actually type it!) yourself and play around with it! That way you really understand what each part of the code does, and can use that knowledge for your own projects later. Actually, you should do that whenever you look up any code on the Internet: Don't just copy and paste, but try to comprehend every bit of it. That way you can solve similar problems by yourself later!

Of course, if there's any problem you just can't figure out or find a solution on the internet, you can always ask us here. The Löve community is really helpful! I sometimes actually found the solution by myself while typing my post and trying to explain the issue - I guess it's similar to rubber ducking.

MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

### Re: Help! New User!

Thanks so much for the support! Only 5 seconds after I posted this, I realized there was a Main Page, and I was clicking the wrong link.

But, now I am stuck. I used to use Scratch, a "language" by the Massachusetts Institute of Technology that programmed with puzzle blocks. I want to make a sequel to this game: http://scratch.mit.edu/projects/16198417/

How would I make the game spawn the red blocks, make them stay for a few seconds, turn a different color, wait a few seconds, then disappear? And how would I make it possible to sense the bad character?

I am not looking for someone to code the entire game. I got a lot done, but I my brain is just caught in how to get around this obstacle.

Thanks!
https://github.com/ebernerd- where you can find all my work.

Jeeper
Party member
Posts: 552
Joined: Tue Mar 12, 2013 7:11 pm

### Re: Help! New User!

MicroMacro wrote: How would I make the game spawn the red blocks, make them stay for a few seconds, turn a different color, wait a few seconds, then disappear? !
Create an object. Make the object have a timer, when the timer has reached X seconds you change color, when the timer has reached 2X you remove the object. Example for simple timers:

Code: Select all

timer = 0 --What the timer starts at
phase1 = 3 -- When the first event will happen
phase2 = 8 -- When the second event will happen

function bestTimer(dt)
timer = timer + dt -- Makes the timer tick

if timer > phase1 then -- Checks if the timer is past the first event
--do cool stuff
end

if timer > phase2 then -- Checks if the timer is past the second event
--do more cool stuff
end
end

MicroMacro wrote: And how would I make it possible to sense the bad character?
Need more info, preferably a .love file. But I am going to asume that you wonder how to make collision detection. And since the game that you linked (it didn't work for me, but I did see a bit) seems to have squares I am going to asume that you want Square to square detection. Here is how you do it:

Code: Select all

-- a = first object
-- b = second object

if a.x + a.width > b.x and a.x < b.x + b.width and a.y + a.height > b.y and a.y < b.y + b.height then
print("A and B are colliding")
end   
Last edited by Jeeper on Fri May 30, 2014 11:04 pm, edited 1 time in total.

MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

### Re: Help! New User!

Jeeper wrote: And how would I make it possible to sense the bad character?
What I mean by that is this:
In the original game, when the block hit the character in Phase2, the character would die. How would I be able to make it so that when the character's pixels touch a baddie's pixels, it "dies"?
https://github.com/ebernerd- where you can find all my work.

Jeeper
Party member
Posts: 552
Joined: Tue Mar 12, 2013 7:11 pm

### Re: Help! New User!

MicroMacro wrote:
Jeeper wrote: And how would I make it possible to sense the bad character?
What I mean by that is this:
In the original game, when the block hit the character in Phase2, the character would die. How would I be able to make it so that when the character's pixels touch a baddie's pixels, it "dies"?
Yeah I kind of got that by trying out the game, even though it doesn't work. I updated my first post, check it out.

MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

### Re: Help! New User!

Thanks.

Also, can I have a list of the callbacks? I can only find a few on the wiki.

Also, I hope for the best with Windmill gaming!
https://github.com/ebernerd- where you can find all my work.

### Who is online

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