Enhance enemy AI and introduce Force class: update speed dynamics based on Lorentz field effects, refactor enemy spawning to utilize Force, and add sprite loading for Force.

This commit is contained in:
2026-03-30 16:31:08 +00:00
parent ccadcf660c
commit 60a89ed128
7 changed files with 61 additions and 13 deletions
+26 -7
View File
@@ -3,6 +3,23 @@ require_relative 'ai'
class Enemy
attr_accessor :x, :y, :w, :h
def self.load(path, w, h, s)
# Once artwork is done need to load each animation here.
# But as artwork takes time, for now just load a single image.
@sprite = Gosu::Image.new(path, retro: true)
@i_w = w
@i_h = h
@s = s
end
def self.sprite
@sprite
end
def self.frame_size
[@i_w, @i_h, @s]
end
def initialize(x, y)
@x = x
@y = y
@@ -36,15 +53,17 @@ class Enemy
screen_x = @x - cam_x
screen_y = @y - cam_y
Gosu.draw_rect(
screen_x - @w / 2,
screen_y - @h / 2,
@w,
@h,
Gosu::Color::RED,
screen_y - @h / 2
self.class.sprite.draw(
screen_x - self.class.frame_size[0],
screen_y - self.class.frame_size[1],
screen_y - self.class.frame_size[1],
self.class.frame_size[2],
self.class.frame_size[2]
)
Gosu.draw_rect(screen_x - @w / 2, screen_y - @h / 2, @w, @h, Gosu::Color.new(0x40FF0000), Float::INFINITY) if $bus.get(:settings, :debug)
@ai.draw
end
end