Skip to content
Snippets Groups Projects
Commit 80da47b2 authored by dg's avatar dg
Browse files

Particle effects now correctly resize in 16x16 mode (if you spot one that does not do tell me)

git-svn-id: http://svn.net-core.org/repos/t-engine4@1883 51575b47-30f0-44d4-a5cc-537603b46e54
parent cad24652
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 3 deletions
...@@ -337,6 +337,12 @@ end ...@@ -337,6 +337,12 @@ end
function _M:recreate() function _M:recreate()
self:makeCMap() self:makeCMap()
self.changed = true self.changed = true
-- Update particles to the correct size
for e, _ in pairs(self.particles) do
e:loaded()
end
self:redisplay() self:redisplay()
end end
...@@ -956,7 +962,7 @@ function _M:displayParticles() ...@@ -956,7 +962,7 @@ function _M:displayParticles()
-- Dont bother with obviously out of screen stuff -- Dont bother with obviously out of screen stuff
if alive and e.x + e.radius >= self.mx and e.x - e.radius < self.mx + self.viewport.mwidth and e.y + e.radius >= self.my and e.y - e.radius < self.my + self.viewport.mheight then if alive and e.x + e.radius >= self.mx and e.x - e.radius < self.mx + self.viewport.mwidth and e.y + e.radius >= self.my and e.y - e.radius < self.my + self.viewport.mheight then
alive = e.ps:toScreen(self.display_x + (e.x - self.mx + 0.5) * self.tile_w * self.zoom, self.display_y + (e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y), self.zoom) alive = e.ps:toScreen(self.display_x + (e.x - self.mx + 0.5) * self.tile_w * self.zoom, self.display_y + (e.y - self.my + 0.5) * self.tile_h * self.zoom, self.seens(e.x, e.y), e.zoom * self.zoom)
end end
if not alive then if not alive then
......
...@@ -49,17 +49,22 @@ end ...@@ -49,17 +49,22 @@ end
function _M:loaded() function _M:loaded()
local def, fct, max, gl, no_stop local def, fct, max, gl, no_stop
local base_size = nil
if type(self.def) == "string" then if type(self.def) == "string" then
if _M.particles_def[self.def] then if _M.particles_def[self.def] then
setfenv(_M.particles_def[self.def], setmetatable(self.args or {}, {__index=_G})) local t = self.args or {}
setfenv(_M.particles_def[self.def], setmetatable(t, {__index=_G}))
def, fct, max, gl, no_stop = _M.particles_def[self.def]() def, fct, max, gl, no_stop = _M.particles_def[self.def]()
base_size = t.base_size
else else
local odef = self.def local odef = self.def
print("[PARTICLE] Loading from /data/gfx/particles/"..self.def..".lua") print("[PARTICLE] Loading from /data/gfx/particles/"..self.def..".lua")
local f, err = loadfile("/data/gfx/particles/"..self.def..".lua") local f, err = loadfile("/data/gfx/particles/"..self.def..".lua")
if not f and err then error(err) end if not f and err then error(err) end
setfenv(f, setmetatable(self.args or {}, {__index=_G})) local t = self.args or {}
setfenv(f, setmetatable(t, {__index=_G}))
def, fct, max, gl, no_stop = f() def, fct, max, gl, no_stop = f()
base_size = t.base_size
_M.particles_def[odef] = f _M.particles_def[odef] = f
end end
else error("unsupported particle type: "..type(self.def)) else error("unsupported particle type: "..type(self.def))
...@@ -69,6 +74,10 @@ function _M:loaded() ...@@ -69,6 +74,10 @@ function _M:loaded()
if not self.__particles_gl[gl] then self.__particles_gl[gl] = core.display.loadImage("/data/gfx/"..gl..".png"):glTexture() end if not self.__particles_gl[gl] then self.__particles_gl[gl] = core.display.loadImage("/data/gfx/"..gl..".png"):glTexture() end
gl = self.__particles_gl[gl] gl = self.__particles_gl[gl]
-- Zoom accordingly
self.base_size = base_size
self:updateZoom()
self.update = fct self.update = fct
-- Make a gas cloud -- Make a gas cloud
if def.gas then if def.gas then
...@@ -77,3 +86,10 @@ function _M:loaded() ...@@ -77,3 +86,10 @@ function _M:loaded()
self.ps = core.particles.newEmitter(max or 1000, no_stop, config.settings.particles_density or 100, def, gl) self.ps = core.particles.newEmitter(max or 1000, no_stop, config.settings.particles_density or 100, def, gl)
end end
end end
function _M:updateZoom()
self.zoom = self.zoom or 1
if self.base_size then
self.zoom = ((engine.Map.tile_w + engine.Map.tile_h) / 2) / self.base_size
end
end
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
local dir = math.rad(ad + 90) local dir = math.rad(ad + 90)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { return {
base = 1000, base = 1000,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
local toggle = false local toggle = false
return { generator = function() return { generator = function()
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
-- Nicolas Casalini "DarkGod" -- Nicolas Casalini "DarkGod"
-- darkgod@te4.org -- darkgod@te4.org
base_size = 32
return { generator = function() return { generator = function()
local ad = rng.range(0, 360) local ad = rng.range(0, 360)
local a = math.rad(ad) local a = math.rad(ad)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment