Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Dec 20, 2024
1 parent 345c37d commit 575da44
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion entities/octopus.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"width": 94,
"height": 75
},
"duration": 120
"duration": 120,
"singleshoot": true
}
]
},
Expand Down
31 changes: 31 additions & 0 deletions scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local vitality
local key_states = {}
local bullet_pool = {}
local explosion_pool = {}
local jet_pool = {}

local timer = false

Expand All @@ -36,6 +37,15 @@ local behaviors = {

explosion.placement:set(x + offset_x, y + offset_y)
explosion.action:set("default")

timemanager:singleshot(math.random(100, 600), function()
if #jet_pool > 0 then
local jet = table.remove(jet_pool)
jet.placement:set(980, 812)
jet.action:set("default")
jet.velocity.x = -200 * math.random(3, 6)
end
end)
end

self.action:set("attack")
Expand Down Expand Up @@ -103,6 +113,7 @@ function setup()

destroy(bullet_pool)
destroy(explosion_pool)
destroy(jet_pool)

entitymanager:destroy(octopus)
octopus = nil
Expand Down Expand Up @@ -135,6 +146,9 @@ function setup()
end
end
end)
octopus:on_animationfinished(function(self)
self.action:set("idle")
end)

princess = entitymanager:spawn("princess")
princess.action:set("default")
Expand Down Expand Up @@ -170,6 +184,19 @@ function setup()
table.insert(explosion_pool, explosion)
end

for _ = 1, 9 do
local jet = entitymanager:spawn("jet")
jet.placement:set(3000, 3000)
jet:on_update(function(self)
if self.x <= -300 then
self.action:unset()
self.placement:set(3000, 3000)
table.insert(jet_pool, self)
end
end)
table.insert(jet_pool, jet)
end

scenemanager:set("ship")
end

Expand All @@ -196,6 +223,10 @@ function loop()
if not key_states[KeyEvent.space] then
key_states[KeyEvent.space] = true

if octopus.kv:get("life") <= 0 then
return
end

if #bullet_pool > 0 then
local bullet = table.remove(bullet_pool)
local x = (player.x + player.size.width) + 100
Expand Down

0 comments on commit 575da44

Please sign in to comment.