Add new maps and tileset for the game world
- Created room1.tmx and room1.lua for the first room in the game, including tiles, collision objects, and NPCs. - Added room2.tmx and room2.lua for the second room, featuring tiles, collision objects, and an enemy. - Introduced a world template to manage map transitions and layout. - Implemented a new tileset (castle.tsx and castle.lua) for the castle theme, including tile properties and image references.
This commit is contained in:
30
scripts/battle/waves/aiming.lua
Normal file
30
scripts/battle/waves/aiming.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local Aiming, super = Class(Wave)
|
||||
|
||||
function Aiming:onStart()
|
||||
-- Every 0.5 seconds...
|
||||
self.timer:every(1 / 2, function()
|
||||
-- Get all enemies that selected this wave as their attack
|
||||
local attackers = self:getAttackers()
|
||||
|
||||
-- Loop through all attackers
|
||||
for _, attacker in ipairs(attackers) do
|
||||
|
||||
-- Get the attacker's center position
|
||||
local x, y = attacker:getRelativePos(attacker.width / 2, attacker.height / 2)
|
||||
|
||||
-- Get the angle between the bullet position and the soul's position
|
||||
local angle = MathUtils.angle(x, y, Game.battle.soul.x, Game.battle.soul.y)
|
||||
|
||||
-- Spawn smallbullet angled towards the player with speed 8 (see scripts/battle/bullets/smallbullet.lua)
|
||||
self:spawnBullet("smallbullet", x, y, angle, 8)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Aiming:update()
|
||||
-- Code here gets called every frame
|
||||
|
||||
super.update(self)
|
||||
end
|
||||
|
||||
return Aiming
|
||||
Reference in New Issue
Block a user