mirror of
https://gitlab.com/MaddoScientisto/cirnofarm.git
synced 2026-06-06 18:45:54 +00:00
Refactoring
This commit is contained in:
parent
0e0a458949
commit
8ecf21aba3
8 changed files with 193 additions and 160 deletions
79
src/game.lua
79
src/game.lua
|
|
@ -61,6 +61,65 @@ local Box = require(make_path("box"))
|
|||
|
||||
include(make_path("pgui" .. ".lua"))
|
||||
|
||||
particles_list = {
|
||||
BLINK={
|
||||
life=4,
|
||||
spriteIndex=81
|
||||
},
|
||||
EXPLOSION={
|
||||
life=8,
|
||||
spriteIndex=83
|
||||
}
|
||||
}
|
||||
|
||||
bullets_list = {
|
||||
BASIC={
|
||||
spriteIndex=80,
|
||||
damage=1,
|
||||
speed=2,
|
||||
life=100,
|
||||
radius=4,
|
||||
particle=particles_list.BLINK
|
||||
}
|
||||
}
|
||||
|
||||
weapons_list = {
|
||||
ICE_BLASTER={
|
||||
name = "Ice Blaster",
|
||||
rate_of_fire = 8,
|
||||
bullet=bullets_list.BASIC,
|
||||
spriteIndex=104,
|
||||
--shoot=function(self,x,y,dir_x,dir_y)
|
||||
-- create_bullet(self.bullet, x, y, dir_x, dir_y)
|
||||
--end
|
||||
},
|
||||
SPAGHETTI={
|
||||
name = "Spaghetti",
|
||||
rate_of_fire = 80,
|
||||
bullet=bullets_list.BASIC,
|
||||
spriteIndex=105,
|
||||
}
|
||||
}
|
||||
|
||||
LAYERS = {
|
||||
{index=4, name="background", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=3, name="solid", render=true, render_objects=true, spawn_objects=false},
|
||||
{index=2, name="foreground", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=1, name="objects", render=false, render_objects=false, spawn_objects=true}
|
||||
}
|
||||
|
||||
actors_db = {
|
||||
{name="teleporter",sprite=88,actor=nil},
|
||||
{name="barrel",sprite=3,actor=Barrel},
|
||||
{name="strawberry",sprite=72,actor=Strawberry},
|
||||
{name="player",sprite=65,actor=nil},
|
||||
{name="box",sprite=4,actor=Box},
|
||||
{name="alarm",sprite=19,actor=nil},
|
||||
{name="fan",sprite=16,actor=nil}
|
||||
}
|
||||
|
||||
|
||||
|
||||
tile_width = 16
|
||||
tile_height = 16
|
||||
|
||||
|
|
@ -101,6 +160,7 @@ function _update()
|
|||
{"text_box",{text=string.format("Actors: %d", count(actors)),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"text_box",{text=string.format("%.4f %dfps",stat(1),stat(7)),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"text_box",{text=string.format("Bullets: %d", count(bullets)),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"text_box",{text=string.format("Particles: %d", count(particles)),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"text_box",{text=string.format("Weapon: %s", cirnoInstance.weapon.data.name),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"text_box",{text=string.format("Weapon timer: %d", cirnoInstance.weapon.timer),margin=2,stroke=true,active=false,hover=false}},
|
||||
{"sprite_box",{sprite=cirnoInstance.weapon.data.spriteIndex,margin=2,stroke=true,active=false,hover=false}},
|
||||
|
|
@ -109,22 +169,7 @@ function _update()
|
|||
--pgui:component("text_box",{text=string.format("Actors: %d", count(actors)),margin=2,stroke=true,active=false,hover=false})
|
||||
end
|
||||
|
||||
LAYERS = {
|
||||
{index=4, name="background", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=3, name="solid", render=true, render_objects=true, spawn_objects=false},
|
||||
{index=2, name="foreground", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=1, name="objects", render=false, render_objects=false, spawn_objects=true}
|
||||
}
|
||||
|
||||
actors_db = {
|
||||
{name="teleporter",sprite=88,actor=nil},
|
||||
{name="barrel",sprite=3,actor=Barrel},
|
||||
{name="strawberry",sprite=72,actor=Strawberry},
|
||||
{name="player",sprite=65,actor=nil},
|
||||
{name="box",sprite=4,actor=Box},
|
||||
{name="alarm",sprite=19,actor=nil},
|
||||
{name="fan",sprite=16,actor=nil}
|
||||
}
|
||||
|
||||
actors = {}
|
||||
bullets = {}
|
||||
|
|
@ -165,6 +210,7 @@ include(make_path("error_explorer") .. ".lua")
|
|||
|
||||
function spawn_objects()
|
||||
|
||||
-- Map width and height, TODO: unhardcode
|
||||
local width = 32
|
||||
local height = 32
|
||||
|
||||
|
|
@ -177,6 +223,7 @@ function spawn_objects()
|
|||
if (a) then
|
||||
local ai = a:new(x*tile_width,y*tile_height)
|
||||
--local ai = Barrel:new(x*tile_width,y*tile_height)
|
||||
--error("ads")
|
||||
add(actors,ai)
|
||||
end
|
||||
|
||||
|
|
@ -256,7 +303,7 @@ function check_collisions()
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue