Love with Coroutine Window say's "Not Responding."
Posted: Sat Jun 17, 2023 10:19 pm
Can someone tell me what this could be ? I tried so much stuff now and not 1 single thing worked.
The command prompt is printing the coord's but the love window doesn't show anything and just say "not responding".
The command prompt is printing the coord's but the love window doesn't show anything and just say "not responding".
thanks in advance !Code: Select all
[b]main.lua[/b] local she = require("she") local She = she.new("She", 100, 200) She:start() local image function love.load() love.graphics.setBackgroundColor(255, 255, 255) image = love.graphics.newImage("assets/She/She.png") end function love.update(dt) She:update() -- Call the update function of the She instance end function love.draw() love.graphics.draw(image, She.x, She.y) end // put your code here [b]She.lua[/b] local she = {} local she_meta = { __index = she } function she.new(name, x, y) local instance = { sheActive = false, name = name, x = x, y = y, updateCoroutine = nil } setmetatable(instance, she_meta) function instance:start() self.sheActive = true self.updateCoroutine = coroutine.create(self.update) coroutine.resume(self.updateCoroutine, self) end function instance:move() local randomNumberX = math.random(-1, 1) local randomNumberY = math.random(-1, 1) self.x = self.x + randomNumberX self.y = self.y + randomNumberY end function instance:update() while self.sheActive do self:move() print(self.x, self.y) end end return instance end return she