Search found 224 matches

by ReFreezed
Mon May 10, 2021 2:09 pm
Forum: Support and Development
Topic: math.round() doesn't work
Replies: 3
Views: 50

Re: math.round() doesn't work

math.round doesn't exist in Lua by default. You'll have to define it yourself:

Code: Select all

math.round = function(n)
	return math.floor(n + 0.5)
end
See the Lua manual for all existing math functions.
by ReFreezed
Mon May 10, 2021 12:54 pm
Forum: Support and Development
Topic: I not can resize, the screen in love2d for android
Replies: 2
Views: 55

Re: I not can resize, the screen in love2d for android

Hello and welcome to the forums! I don't think you can change the screen resolution on Android. You can only specify if you want landscape mode or portrait mode by changing the ratio between the width and the height, which is why this code works: Portrait mode: love.window.setMode(1, 2) Landscape mo...
by ReFreezed
Mon May 10, 2021 12:37 pm
Forum: General
Topic: Using assert to establish pre/post conditions?
Replies: 4
Views: 80

Re: Using assert to establish pre/post conditions?

You shouldn't need to assert parameters that are coming from another part of your own code/library. I disagree there. For robustness and your own sanity, asserting that your program is actually doing what you think it does is always a good thing, especially when making changes in larger, or more co...
by ReFreezed
Mon May 10, 2021 12:04 pm
Forum: Libraries and Tools
Topic: LuaPreprocess - straightforward preprocessor with simple syntax
Replies: 30
Views: 35338

Re: LuaPreprocess - straightforward preprocessor with simple syntax

In addition to monolifed's solutions, the most straight-forward one-liner way is probably something like this: local ok = false !!(DEBUG and "assert(ok)" or "") -- Result: local ok = false assert(ok) !!(...) outputs a string as Lua code. You could also do something like this: !( ...
by ReFreezed
Mon May 10, 2021 1:01 am
Forum: General
Topic: KeyMap - A Keymapping Module with Controller Support
Replies: 2
Views: 1303

Re: KeyMap - A Keymapping Module with Controller Support

A quick look at the code reveals that the library overwrites love.keypressed and some other event handlers. Instead of calling KeyMap:isPushed() in love.keypressed you should do it in love.update and let the library handle all keyboard+gamepad input. In some other libraries you have to do something ...
by ReFreezed
Mon May 10, 2021 12:49 am
Forum: General
Topic: Using assert to establish pre/post conditions?
Replies: 4
Views: 80

Re: Using assert to establish pre/post conditions?

This is exactly what asserts are supposed to be for, so I'd say it's usually a good idea. (Maybe not for extremely trivial functions like that example, of course.) It's probably also a good idea to remove or comment out all the asserts in the final/public version of the program. (There are tools tha...
by ReFreezed
Sat Apr 17, 2021 12:44 pm
Forum: Games and Creations
Topic: Mino Bueno, a customizable Tetris clone
Replies: 9
Views: 8281

Re: Mino Bueno, a customizable Tetris clone

Pretty cool game. I don't know how many times I accidentally pressed up, constantly creating unreachable spaces. Doh!
by ReFreezed
Mon Apr 12, 2021 7:46 am
Forum: Libraries and Tools
Topic: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)
Replies: 2
Views: 1586

Re: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Update 1.2 Changes since 1.1: Added character filters for limiting what glyphs gets outputted. Added [in] parameter 'imageFile' for specifying the filename of the input image. Added "builtin" as a special value for the fontFile parameter. Added --silent option for disabling output to stdo...
by ReFreezed
Sat Apr 10, 2021 6:50 am
Forum: Libraries and Tools
Topic: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)
Replies: 2
Views: 1586

Re: ImageFont-like to BMFont converter (ReFreezed Bitmap Font converter)

Update 1.1 Changes since 1.0: Outputted glyphs are packed a lot better. Added [edit] parameter 'trim' for controlling trimming of transparent pixels around glyphs. Added [out] parameter 'imageBounds' for controlling the dimensions of outputted images (e.g. power-of-two). Added [out] parameter 'imag...
by ReFreezed
Sat Apr 10, 2021 6:38 am
Forum: General
Topic: Testing Different Projects
Replies: 5
Views: 1078

Re: Testing Different Projects

Only the files you require() will actually run, so if you only call require("collision_circles") in main.lua then it doesn't matter what arrow_follow.lua or any other file contains as those will not run. main.lua: -- Only uncomment one line: -- require("collision_circles") -- Unc...