Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local mapX = { }
  2. local mapY = { }
  3. local count = 8
  4.  
  5. local i = 0
  6. while mapX[count] == 0 and mapY[count] == 0 do
  7.     local collide = false
  8.     for x = 0, 16 do
  9.         for y = 0, 16 do
  10.             local n = love.math.random(99)
  11.             -- we "randomize" a number so they don't ALWAYS spawn next to each other
  12.             -- they can but it's unlikely..
  13.             if n == 1 then
  14.                 for d = 0,  count do
  15.                     if x == mapX[d] and y == mapY[d] then
  16.                         -- we don't add them more than once in the same x and y coords
  17.                         collide = true
  18.                     end
  19.                 end
  20.                 if not collide then
  21.                     mapX[i] = x
  22.                     mapY[i] = y
  23.                     i = i + 1
  24.                     print("mapX: " .. mapX[i] .. " mapY: " .. mapY[i])
  25.                 end
  26.             end
  27.         end
  28.     end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement