idle/clicker game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
soullessbr
Prole
Posts: 11
Joined: Sat Jun 01, 2013 1:18 am

idle/clicker game

Post by soullessbr »

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
User avatar
eqnox
Prole
Posts: 44
Joined: Fri Jul 31, 2015 2:36 pm

Re: idle/clicker game

Post by eqnox »

not sure what exactly you are asking, but a good way of storing really big numbers is exponents
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: idle/clicker game

Post by Inny »

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:

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)
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.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: idle/clicker game

Post by undef »

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.
twitter | steam | indieDB

Check out quadrant on Steam!
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 2 guests