Page 1 of 2
Help! New User!
Posted: Fri May 30, 2014 2:34 am
by MicroMacro
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:
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!
Re: Help! New User!
Posted: Fri May 30, 2014 2:55 am
by Jasoco
The front page has enough information to help you get started. It links to the Wiki where you will find more information. Please check it out.
Re: Help! New User!
Posted: Fri May 30, 2014 2:45 pm
by gestaltist
Hey Eric.
Get started with this link:
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.
Re: Help! New User!
Posted: Fri May 30, 2014 7:10 pm
by CaptainMaelstrom
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
Re: Help! New User!
Posted: Fri May 30, 2014 9:37 pm
by Chron
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.
Re: Help! New User!
Posted: Fri May 30, 2014 10:18 pm
by MicroMacro
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!
Re: Help! New User!
Posted: Fri May 30, 2014 10:58 pm
by Jeeper
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
Re: Help! New User!
Posted: Fri May 30, 2014 11:02 pm
by MicroMacro
Jeeper wrote:
And how would I make it possible to sense the bad character?
Need more info, preferably a .love file.
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"?
Re: Help! New User!
Posted: Fri May 30, 2014 11:05 pm
by Jeeper
MicroMacro wrote:Jeeper wrote:
And how would I make it possible to sense the bad character?
Need more info, preferably a .love file.
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.
Re: Help! New User!
Posted: Sat May 31, 2014 12:06 am
by MicroMacro
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!