Thank you very much for the detailed information. This lua book is in English and that will make it difficult for me to learn, I know that the reference manual has a Spanish version but you don't know any book in Spanish about lua.BrotSagtMist wrote: ↑Tue Apr 11, 2023 4:57 pmDo they explain why? Dont write anything that you do not exactly know why you write it. If you cant make sense of it, leave it out.When I've seen a love tutorial, the first thing it teaches you is the love.load, love.update and love.draw functions that you have to place them in order and then you create your tables as objects and place them appropriately in each function.
Lets take love.load for example. This can be used to restart the game, pass command line arguments or to calculate local values without polluting the name space.
So it can be useful. If you need any of the above. But if you dont, there is simply no reason to use it other than that tutorial telling you to do it.This simply means that whenever a key is pressed it will use the argument _a_, which is the name of the key as string, to look in table _B_ if it has an entry of the same name, and if it does, call it.Finally, you create the kepressed function with the parameters (_,a) that I don't know what it refers to and then you use a conditional that I don't know what you're doing there.
This just binds functions to keys.Everything is a table in lua and everything is empty. And these functions are made up anyway.In this example you are saving functions in love.update as if it were an empty table and I did not know that this could be done and I also did not know that love.update was a table and I do not understand that it is allowed to use an internal table or function to save data. These are things that are not explained in any tutorial and they confuse me.
Löves strengths are also its weaknesses. By providing sensible defaults it also hides away whats going on in the background and makes it hard for beginners to follow what is going on.
See https://love2d.org/wiki/love.run, but the TL:DR version is that at the end of your main.lua file löve appends something like this pseudo code:So if love.load exists, run it.Code: Select all
if love.load then love.load() end while true do for event, values in listevents() do love[event](values) end love.update(timepassed) love.draw() sleep(1/60) end
Start an infinitive loop.
For all keyboard/mouse events call functions that have that name.
Run love.update and love.draw
Sleep and repeat next frame.
This code is normally invisible to the user.
Thats it. Thats the game loop. There is no higher reason behind draw and update, it simply happens that whatever has that name gets called each frame.
And that is purely because it is written like that at this spot.
In this example love.update is NEVER called. It is assigned, HUGE difference.In addition to the fact that you call love.update three times and I didn't know what could be done either, so I wonder what tutorials you followed to learn that this could be done.
I never used any tutorial, there is documentation for that purpose.
But you on the other hand have the problem that you are trying to use löve without the knowledge of how to use lua.
And our own wiki notes to read PIL at the beginning. https://www.lua.org/pil/contents.html
This is where you should start.
Before starting to study the book, I'm going to finish the pong example because I don't like to leave things half done, although you probably won't like the code that it shows, although I will try to minimize the oop as much as possible.