Compare commits

...

4 commits

Author SHA1 Message Date
7f86166f8d exercise 89 2025-11-11 23:09:46 -03:00
4e06585f12 return GameObject in emmylua 2025-11-11 23:01:19 -03:00
829d35c2ca exercise 87 2025-11-11 22:54:29 -03:00
77c9bf03f5 exercise 86 2025-11-11 22:41:01 -03:00
2 changed files with 3 additions and 1 deletions

View file

@ -49,6 +49,7 @@ end
---@param x number|nil horizontal position
---@param y number|nil vertical position
---@param opts table|nil additional arguments
---@return GameObject
function Area:addGameObject(game_object_type, x, y, opts)
local game_object = _G[game_object_type](self, x or 0, y or 0, opts or {})
table.insert(self.game_objects, game_object)

View file

@ -72,7 +72,8 @@ function Player:shoot()
local d = 1.2*self.w
local offset_x, offset_y = self.x + d*math.cos(self.r), self.y + d*math.sin(self.r)
self.area:addGameObject('ShootEffect', offset_x, offset_y, {player = self, d = d})
self.area:addGameObject('Projectile', offset_x, offset_y, {r = self.r})
local proj = self.area:addGameObject('Projectile', offset_x, offset_y, {v = 100 ,r = self.r})
proj.timer:tween(0.5, proj, {v = 400}, 'linear')
end
return Player