Page 1 of 1

Great Love practice?

Posted: Sun Jan 27, 2013 6:13 am
by dementia_patient567
I've been messing around with Love2d and it's awesome. I'm getting the hang of it slowly but surely. This(
1942.love
(133.74 KiB) Downloaded 187 times
) abomination is the closest I've managed to making a "game" so far with just a little bit of practice. I didn't bother finishing it because there were too many things wrong with it. I just couldn't get things to work. Anyways. I was wondering if you guys had some really good practices to get people's programming up to par. Whether that means games to clone or what, idk. I go through Lua and Love tutorials/libraries for a little bit pretty often and I learn a few new things each time. I just really learn better through trial and error and practice rather than staring at tutorials and libraries all day(which I'm willing to do, and I do just that, but it just isn't as effective for me.)

Basically I'm just asking what things I could do in practice that would help me achieve my goals in programming in Love and in general.

Thanks guys!

Re: Great Love practice?

Posted: Sun Jan 27, 2013 10:59 pm
by Saegor
hello

your .love don't work because you zipped the main folder instead of all the files.
look at the bottom for a working version

some example tips :

you can replace this

Code: Select all

explosion= {}
explosion[1] = love.graphics.newImage("images/explode/ex1.png")
explosion[2] = love.graphics.newImage("images/explode/ex2.png")
explosion[3] = love.graphics.newImage("images/explode/ex3.png")
explosion[4] = love.graphics.newImage("images/explode/ex4.png")
explosion[5] = love.graphics.newImage("images/explode/ex5.png")
explosion[6] = love.graphics.newImage("images/explode/ex6.png")
explosion[7] = love.graphics.newImage("images/explode/ex7.png")
explosion[8] = love.graphics.newImage("images/explode/ex8.png")
explosion[9] = love.graphics.newImage("images/explode/ex9.png")
explosion[10] = love.graphics.newImage("images/explode/ex10.png")
explosion[11] = love.graphics.newImage("images/explode/ex11.png")
explosion[12] = love.graphics.newImage("images/explode/ex12.png")
explosion[13] = love.graphics.newImage("images/explode/ex13.png")
explosion[14] = love.graphics.newImage("images/explode/ex14.png")
explosion[15] = love.graphics.newImage("images/explode/ex15.png")
explosion[16] = love.graphics.newImage("images/explode/ex16.png")
explosion[17] = love.graphics.newImage("images/explode/ex17.png")
explosion[18] = love.graphics.newImage("images/explode/ex18.png")
explosion[19] = love.graphics.newImage("images/explode/ex19.png")
explosion[20] = love.graphics.newImage("images/explode/ex20.png")
explosion[21] = love.graphics.newImage("images/explode/ex21.png")
explosion[22] = love.graphics.newImage("images/explode/ex22.png")
explosion[23] = love.graphics.newImage("images/explode/ex23.png")
explosion[24] = love.graphics.newImage("images/explode/ex24.png")
explosion[25] = love.graphics.newImage("images/explode/ex25.png")
by this

Code: Select all

explosion = {}
for n = 1, 25 do
explosion[n] = love.graphics.newImage("images/explode/ex" .. n ..".png")
end
another tip : try to make again the same game, cause you will make inconsciently more optimizations to your code with the newly gained XP in Lua

Re: Great Love practice?

Posted: Thu Jan 31, 2013 3:03 pm
by zorfmorf
Essential things you should keep in mind:

- Just like in Saegor's example above, if you find yourself writing the same code again and again/ copy&paste a lot of code, this usually means that you can simplify your approach greatly
- Try to keep a clean, consistent style of code. Indent properly, use meaningful names for variables, define your global variables at the start of your file, etc
- Write lots of comments! Write a short explanation for every more complex piece of code. For every method, explain what the parameters are, what the method does/returns, how it (should) handle special cases

Re: Great Love practice?

Posted: Thu Jan 31, 2013 4:14 pm
by d_0o_d
Yes, truly, the best thing you can do is practice your skills by coding stuff. Additionally you could read and modify code of some pro coders (ask for permission of course, but I don't think you get problems if you don't publish the modified code. It's just for the purpose of learning, right? ;) ).
Maybe you think at some point that there must be a way to make things easier and more clean, often that is the case. But to find this way, you may have to ask google or some nice people :)