Search found 110 matches
Re: help cleaning up my code
I would suggest the opposite of BrotSagtMist: Create more functions that only contain 1-3 lines of code for better readability. As an example your function love.mousepressed() has 5 indentation levels. With some easy refactorings you can get this down to two or three and have an easier time to read ...
- Wed Dec 06, 2023 8:36 pm
- Forum: Support and Development
- Topic: Check if the web build is working every time a commit is pushed
- Replies: 2
- Views: 1986
Re: Check if the web build is working every time a commit is pushed
You can start chrome (or chromium based browsers) with debug output enabled ( source ): chromium --log-level=0 --enable-logging=stderr Then everything that is printed in the web console is also printed to the command line where chrome was started. Here an simple example javascript in a file called l...
- Tue Oct 17, 2023 8:58 pm
- Forum: Support and Development
- Topic: How to store file text into array
- Replies: 4
- Views: 4449
Re: How to store file text into array
In other words,what should I put at the ? So the condition is true when it access out of the string You need to put the following where the ? is: "" But why would you want to do that? You know that you are at the end of the string when i == #data[1] and you are "beyond" the stri...
- Sun Aug 13, 2023 8:20 pm
- Forum: Support and Development
- Topic: How would I go about making a flashlight effect in Love2D?
- Replies: 5
- Views: 1024
Re: How would I go about making a flashlight effect in Love2D?
I attached a simple example that works without shaders.
Thanks to SD.Chatane for the image (licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)).
Thanks to SD.Chatane for the image (licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)).
- Sun Jun 25, 2023 7:46 pm
- Forum: Support and Development
- Topic: Timer as Integer ?
- Replies: 9
- Views: 1169
Re: Timer as Integer ?
You want the math.floor function: print(math.floor(19.02032)) -- prints "19" If you want commercial rounding you need to add 0.5 to your number before you use math.floor : function print_rounding(number, rounded_number) print("Rounding " .. tostring(number) .. " to " .....
- Fri Mar 10, 2023 5:08 pm
- Forum: General
- Topic: HTML+CSS UI Rendering
- Replies: 10
- Views: 4990
Re: HTML+CSS UI Rendering
I only came across LURE, [...] And I am confused, I do not know how to use it, there is nowhere at least a brief instruction on how to use it. You cannot use it (yet): LURE is currently under development and cannot yet produce rendered content. If you want to use Lua as a scripting language, but us...
- Sat Jan 21, 2023 10:14 pm
- Forum: Support and Development
- Topic: Wrapper / abstraction layer mechanism that download needed files on demand
- Replies: 12
- Views: 3461
Re: Wrapper / abstraction layer mechanism that download needed files on demand
The concept you are searching for is called lazy loading . Here is a sketch in pseudo code: function readFile(filename) if love.filesystem.getInfo(filename) == nil then -- download file end return love.filesystem.read(filename) end This will check if the file is already downloaded. If not it will do...
- Fri Dec 30, 2022 12:36 am
- Forum: Support and Development
- Topic: I have a glitch in my game
- Replies: 2
- Views: 1021
Re: I have a glitch in my game
The variable currentAnim is a global variable that is shared by player.lua and polly.lua . Do not use globals for animations, but class fields instead: function Polly:animations() -- loads in animations local g = self.grid self.idle = anim8.newAnimation(g(("1-4"), 1), 0.1) self.runAnim = a...
- Sat Nov 19, 2022 11:40 pm
- Forum: Support and Development
- Topic: Trouble with a seemingly simple snake game(Solved!)
- Replies: 13
- Views: 2413
Re: Trouble with a seemingly simple snake game
Setting occupied = false at the beginning of the loop will fix the issue: --snake.lua, starting from line 137 local occupied = false repeat occupied = false newfood_position = {math.random(1,25),math.random(1,25)} for i,v in pairs(snake.all_positions) do if v.x == newfood_position[1] and v.y == newf...
- Mon Jul 18, 2022 3:44 pm
- Forum: Support and Development
- Topic: Coding challenge: convex shapes
- Replies: 10
- Views: 4247
Re: Coding challenge: convex shapes
I notice not all segments 'move' - either a bug or your algorithm keeps moving the same three points because that reaches success the fastest? I think this is a limitation of growing a convex shape point by point. If you have a few points on a line (or nearly on a line) it is very hard to move thos...