Difference between revisions of "User:Kraftman"

m (typo fix)
Line 6: Line 6:
  
 
3 new to love!
 
3 new to love!
ok, so you know how to code, you know lua, but you dont know ho wlove works.
+
ok, so you know how to code, you know lua, but you don't know how love works.
  
Love is very open, it provides the bare minimum so that you can build up from it to suit your own needs. this means it isnt bloated by random crap you dont need: you only have what you need, because you only have what you code.
+
Love is very open, it provides the bare minimum so that you can build up from it to suit your own needs. this means it isn't bloated by random crap you don't need: you only have what you need, because you only have what you code.
  
Love provides a number of functions which once defined, are called by the love program as and when are needed. These specific functions are called callbacks. Arguably the most important function is lve.draw
+
Love provides a number of functions which once defined, are called by the love program as and when are needed. These specific functions are called callbacks. Arguably the most important function is love.draw
  
 
love.draw is called every frame update, and as a result, can be used to draw every object which you wish to show on the screen. As this function is called so often, it is important to limit the operations inside the function to only those which must be updated every frame.
 
love.draw is called every frame update, and as a result, can be used to draw every object which you wish to show on the screen. As this function is called so often, it is important to limit the operations inside the function to only those which must be updated every frame.
Line 25: Line 25:
  
 
there are similar callbacks, which are triggered based on moue and keyboard events.
 
there are similar callbacks, which are triggered based on moue and keyboard events.
It is important at this time to differentiate wether you want to do something when the input is first initalised, or if the input is currently there.
+
It is important at this time to differentiate wether you want to do something when the input is first initialized, or if the input is currently there.
  
 
for example, if you want to drag a frame, you need the event of the mouse button being pressed to start the dragging, and while the mouse is still down, updating the position of the object continuously to follow the mouse, and then once the mouse button is released, stopping the object from moving.
 
for example, if you want to drag a frame, you need the event of the mouse button being pressed to start the dragging, and while the mouse is still down, updating the position of the object continuously to follow the mouse, and then once the mouse button is released, stopping the object from moving.
Line 31: Line 31:
  
 
So now you can draw an object, handle mouse and keyboard events, what now?
 
So now you can draw an object, handle mouse and keyboard events, what now?
Now its up to you. build up from the basics until you have what you want. If theres something you'd like to do but cant, check the wiki, check the forums, ask on IRC.
+
Now its up to you. build up from the basics until you have what you want. If there's something you'd like to do but cant, check the wiki, check the forums, ask on IRC.

Revision as of 14:35, 20 May 2011

Getting started with love:

1 New to coding

2 new to lua

3 new to love! ok, so you know how to code, you know lua, but you don't know how love works.

Love is very open, it provides the bare minimum so that you can build up from it to suit your own needs. this means it isn't bloated by random crap you don't need: you only have what you need, because you only have what you code.

Love provides a number of functions which once defined, are called by the love program as and when are needed. These specific functions are called callbacks. Arguably the most important function is love.draw

love.draw is called every frame update, and as a result, can be used to draw every object which you wish to show on the screen. As this function is called so often, it is important to limit the operations inside the function to only those which must be updated every frame.

basic draw ----- example

love.update is another callback. it is also called every frame, however it is run before love.draw, and it passes a variable which is the length of time between the drawing of the last frame and the current frame.

example of both update and draw

if you want an object to shown on your canvas, you need to draw it every frame.

ok, so i can draw an object, ace. how do i move it?

there are similar callbacks, which are triggered based on moue and keyboard events. It is important at this time to differentiate wether you want to do something when the input is first initialized, or if the input is currently there.

for example, if you want to drag a frame, you need the event of the mouse button being pressed to start the dragging, and while the mouse is still down, updating the position of the object continuously to follow the mouse, and then once the mouse button is released, stopping the object from moving. Of course, how you implement this is completely up to you, and is the joy of the flexibility of LOVE!

So now you can draw an object, handle mouse and keyboard events, what now? Now its up to you. build up from the basics until you have what you want. If there's something you'd like to do but cant, check the wiki, check the forums, ask on IRC.