changed something

This commit is contained in:
Maddo 2024-04-30 17:50:28 +02:00
commit 16c3ddc79f
2 changed files with 36 additions and 33 deletions

View file

@ -10,6 +10,8 @@ function NPC:new(x,y)
n.found = false
n.raycast_enabled = false
n.enemy_x_debug = 0
n.enemy_x_debug = 0
@ -39,7 +41,7 @@ function NPC:update()
self.raycast_frames += 1
if (self.raycast_frames % self.raycast_frames_to_wait == 0) then
if (self.raycast_enabled and self.raycast_frames % self.raycast_frames_to_wait == 0) then
local hit_x, hit_y, hit_status = raycast(self.x, self.y, enemy_x, enemy_y, self.range, 2)
--if (raycast_hit) then
@ -56,13 +58,14 @@ function NPC:draw()
--circfill(self.x,self.y,self.range,18)
local col = 30
spr(self.spriteIndex,self.x,self.y)
if self.raycast_enabled then
print(string.format("Found: %s", tostring(self.found)),self.x,self.y-16,col)
--print(string.format("dir_x: %.2f dir_y: %.2f",self.dir_vec_debug_x, self.dir_vec_debug_y),self.x,self.y-8,28)
--print(string.format("hit_x: %.2f dir_y: %.2f", self.hit_x, self.hit_y),self.x, self.y,28)
--line(self.x,self.y, self.enemy_x_debug, self.enemy_y_debug, 14)
line(self.x,self.y, self.hit_x, self.hit_y, col)
end
end