Search found 1188 matches

by ivan
Sat Feb 17, 2018 6:48 pm
Forum: Support and Development
Topic: resize image at load
Replies: 3
Views: 68

Re: resize image at load

1. Yes, that should work, but it scales your image by a fraction so scale = 2 would draw your object twice as large. Exporting your image at 400% is not good because it wastes RAM and is slower to load. If you want to scale multiple sprites, there is also: love.graphics.scale 2. It's not a big deal ...
by ivan
Sat Feb 17, 2018 4:05 pm
Forum: Support and Development
Topic: resize image at load
Replies: 3
Views: 68

Re: resize image at load

Ok, so there are a few simple solutions but you're not going to like them. 1. You can resize/scale images while drawing 2. Don't base your game logic on images and how you draw things. Just use custom units for your game logic, like meters and convert those to pixels when you want to draw stuff. If ...
by ivan
Sun Feb 11, 2018 12:44 pm
Forum: Support and Development
Topic: Equivalent to Gamemaker's sign() function?
Replies: 39
Views: 961

Re: Equivalent to Gamemaker's sign() function?

Also, if you want the test to be deterministic, we need to either move math.rand outside of the test function or: local function benchmark(iter, fn) math.randomseed(0) ... The branching variant is the fastest on my machine btw. After localizing math.min/math.max, the branching version is still the f...
by ivan
Sat Feb 10, 2018 5:46 pm
Forum: Support and Development
Topic: Equivalent to Gamemaker's sign() function?
Replies: 39
Views: 961

Re: Equivalent to Gamemaker's sign() function?

Lua is an interpreted language running in a virtual machine.
While the Lua bytecode could be optimized using LuaJIT it's still running in a VM.
The VM alone adds all sorts of overhead. :)
by ivan
Sat Feb 10, 2018 4:26 pm
Forum: Support and Development
Topic: Equivalent to Gamemaker's sign() function?
Replies: 39
Views: 961

Re: Equivalent to Gamemaker's sign() function?

Both * and / are quite costly for floating numbers, if LuaJIT can't help to optimize. A simple branching like grump's version could be more efficient. I'm not an expert at LuaJIT, but Lua is an interpreted language so I it's kind of silly to talk about float point operations being costly. Things li...
by ivan
Sat Feb 10, 2018 1:43 pm
Forum: General
Topic: Vanilla Lua or Lua w/ LOVE Framework?
Replies: 3
Views: 184

Re: Vanilla Lua or Lua w/ LOVE Framework?

Love2D uses LuaJIT which is a fork of Lua.
Vanilla Lua is slower but may have new language features not available in LuaJIT.
by ivan
Sat Feb 10, 2018 1:30 pm
Forum: Support and Development
Topic: Equivalent to Gamemaker's sign() function?
Replies: 39
Views: 961

Re: Equivalent to Gamemaker's sign() function?

I like grump's version best but I have to throw this one in:

Code: Select all

function sign(n)
  return n == 0 and 0 or n/math.abs(n)
end
Could be simplified if you are certain that n is non-zero:

Code: Select all

assert(n ~= 0)
sign = n/math.abs(n)
by ivan
Thu Feb 08, 2018 5:28 pm
Forum: Libraries and Tools
Topic: Fizz X
Replies: 85
Views: 25617

Re: Fizz X

Hello, ivan. I have a question. How i can mark side of rectangle shape like it's collides with static shape? I need this for correct collisions with my own level geometry (by pixels). By while one shape can push other shape through my geometry. Hello Andrey, I have commented out this part of the co...
by ivan
Mon Feb 05, 2018 7:27 am
Forum: Support and Development
Topic: Need help with understanding the basics of love2d
Replies: 4
Views: 217

Re: Need help with understanding the basics of love2d

Like pgimeno mentioned, the documentation is very important: Love2D: https://love2d.org/wiki/Main_Page Lua: https://www.lua.org/pil/contents.html Be prepared to be reading/looking at the "docs" most of the time. Just note the difference between "pure" Lua and Love2D. Once you figure out how Lua work...
by ivan
Sun Feb 04, 2018 11:16 pm
Forum: Support and Development
Topic: Need help with understanding the basics of love2d
Replies: 4
Views: 217

Re: Need help with understanding the basics of love2d

Hello there. Your questions are too broad to answer meaningfully. For instance, is there super simplified way that someone could explain what all the moving parts of this whole process are? Basically, you write your game in Lua then you run it to check for errors. Most examples/tutorial code should ...