diff --git a/ideas.txt b/ideas.txt new file mode 100644 index 0000000..1934aa8 --- /dev/null +++ b/ideas.txt @@ -0,0 +1,27 @@ +Sub-atomic particles +Atoms +Molecules +Cells +Structures + +? + +Particles -> x/y/type/state +Atoms -> x/y, particles{} +Molecules -> x/y, atoms{} +Cells -> x/y, molecules{} +Structures -> x/y, cells{} +(velocity) + +? + +Each type of thing is handled separately, once something is consumed by a higher level, it disappears from the lower level section. +This way we can save processing power. It means however that things at a higher level can't combine at a lower level. :/ + +spacial hash? elements can interact with each other only in the same hash, hashes overlap? + +- + +Particles spawn randomly within a radius specified by the farthest traveled particle. +Particles spawn with different types, each has a specific lifetime. (Use a particular generator for randomness of lifetimes.) +Velocities are random, seeded generator? diff --git a/run src.bat b/run src.bat new file mode 100644 index 0000000..f52efb1 --- /dev/null +++ b/run src.bat @@ -0,0 +1,2 @@ +@ECHO OFF +"C:\Program Files\LOVE\love.exe" "%cd%/src" diff --git a/src/main.lua b/src/main.lua new file mode 100644 index 0000000..35c0668 --- /dev/null +++ b/src/main.lua @@ -0,0 +1,87 @@ +local lg = love.graphics +local lm = love.math + +local particularRandomization = lm.newRandomGenerator(os.time()) +local currentMaxPosition = 2 +local maxVelocity = 2 +local lifetimes = {} +local particularLifetimes = lm.newRandomGenerator(os.time()*2) +local currentMaxType = 2 +local maxLifetime = 10 + +local function particular() + local self = {} + + self.x = particularRandomization:random(currentMaxPosition) + self.y = particularRandomization:random(currentMaxPosition) + self.vx = particularRandomization:random(maxVelocity) + self.vy = particularRandomization:random(maxVelocity) + + self.type = particularRandomization:random(currentMaxType) + if self.type > #lifetimes then + for i=#lifetimes,self.type do + lifetimes[i] = particularLifetimes:random(maxLifetime) + end + end + self.lifetime = lifetimes[self.type] + + return self +end + +local particles = {} + +local generationTiming = lm.newRandomGenerator(os.time()+100) +local nextGeneration = generationTiming:random() +local generationTimingCurrentTime = 0 + +local maxTypeIncrementTimer = 0 +local maxTypeIncrementInterval = 100 +function love.update(dt) + currentMaxPosition = currentMaxPosition + dt + + maxTypeIncrementTimer = maxTypeIncrementTimer + dt + while maxTypeIncrementTimer >= maxTypeIncrementInterval do + maxTypeIncrementTimer = maxTypeIncrementTimer - maxTypeIncrementInterval + currentMaxType = currentMaxType + 1 + end + + generationTimingCurrentTime = generationTimingCurrentTime + dt + while generationTimingCurrentTime >= nextGeneration do + generationTimingCurrentTime = generationTimingCurrentTime - nextGeneration + nextGeneration = generationTiming:random() + table.insert(particles, particular()) + end + + local deletes = {} + --for i=1 + for k, p in pairs(particles) do + p.x = p.vx * dt + p.y = p.vy * dt + p.lifetime = p.lifetime - dt + if p.lifetime <= 0 then + table.insert(deletes, k) + end + end + for _, p in ipairs(deletes) do + particles[p] = nil + end +end + +--lg.setColor(255, 255, 255, 255) +function love.draw() + --for i=1,#particles do + -- lg.point(particles[i].x, particles[i].y) + --end + for _, p in pairs(particles) do + --lg.point(p.x, p.y) + lg.circle("fill", p.x, p.y, 1) + end + + lg.circle("line", lg.getWidth()/2, lg.getHeight()/2, currentMaxPosition) +end + +function love.keypressed(key) + if key == "escape" then + love.event.quit() + end +end