123456789101112131415161718192021222324252627282930313233 |
- Bullet = class()
- function Bullet:init(x, y, vx, vy)
- self.x = x
- self.y = y
- self.vx = vx
- self.vy = vy
- self.dead = false
- end
- function Bullet:update(world)
- self.x = self.x + self.vx
- self.y = self.y + self.vy
- if self.x < 1 or self.x > WIDTH or self.y < 1 or self.y > HEIGHT then
- self.dead = true
- end
- end
- function Bullet:draw(text)
- local chars
- chars = {
- { '\\', '^', '/' },
- { '<', '+', '>' },
- { '/', 'v', '\\' }
- }
- text[self.y][self.x] = {
- char = chars[self.vy + 2][self.vx + 2],
- color = COLOR.BULLET
- }
- end
|