It's all right?
Guys I've been wasting my time with those idle/clicker game and I wonder if you can make one in love2d ?
As you would variables with those absurdly large numbers (see here units)?
Thank you
idle/clicker game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: idle/clicker game
not sure what exactly you are asking, but a good way of storing really big numbers is exponents
Re: idle/clicker game
Big numbers in computers work the way we all learned addition way back in grade school. You line the numbers one on top of the other, justified to the right, add the right most numbers together, and carry the extra digits to the next number to the left. We can do a bit more sophistication by doing this in several orders of magnitude instead of 1, and we're going to store things in the table "little endian" meaning the smaller numbers appear in smaller numbered indexes in the table. Here's some code showing how to make and add the numbers:
The reason I choose 1000 is because in English there's a convenience around numbers that have gotten larger by 3 orders of magnitude, you change the suffix name of the number from "thousand" to "million" to "billion". So, the length of the big number table can be the index into the suffix table, and you only need to display the largest digits.
Code: Select all
--- Make a big number expressed in "big endian", makebig(2,993)
function makebig(...)
local t = {...}
for i = 1, math.floor(#t/2) do t[i], t[1+#t-i] = t[1+#t-i], t[i] end
return t
end
function bigadd(x, y)
local N = math.max(#x, #y)
local z = {}
local carry = 0
for i = 1, N do
z[i] = (x[i] or 0) + (y[i] or 0) + carry
carry = math.floor(z[i] / 1000)
z[i] = z[i] - (carry * 1000)
end
if carry > 0 then
z[#z+1] = carry
end
return z
end
-- Show that two numbers are added together correctly
local testone = bigadd(makebig(2,993), makebig(2,742))
print(testone[2] .. ',' .. testone[1])
assert(testone[2]==5 and testone[1]==735)
-- test the roll over from 999k to 1 Million
local testtwo = bigadd(makebig(999,999), makebig(1))
assert(testtwo[3]==1)
Re: idle/clicker game
I once thought about making one as well, because it's so easy.
Then I thought they are actually pretty horrible, because there's nothing positive about them.
Then I thought they are actually pretty horrible, because there's nothing positive about them.
Who is online
Users browsing this forum: Bing [Bot] and 1 guest