I want the red rectangle to collide with the green rectangle!
here is what I mean hope anyone can help me
can for loop fix my problem or is there another way to do it base on how I made it???
Code: Select all
function actor:draw()
love.graphics.setColor(self.hurt.color)
love.graphics.rectangle("line", self.hurt.x ,self.hurt.y , self.hurt.w, self.hurt.h)
love.graphics.setColor(self.hit.color)
love.graphics.rectangle("line", self.hurt.x+20 ,self.hurt.y , self.hit.w, self.hit.h)
end
Code: Select all
self.hit={x=0, y=0, w=30, h=10, color={255,0,0} }
Code: Select all
self.hit.x = self.hurt.x+20
self.hit.y = self.hurt.y
if love.keyboard.isDown("a") then
self.hurt.x = self.hurt.x - self.fuel*dt
self.hit.x = self.hit.x - self.fuel*dt
end
if love.keyboard.isDown("d") then
self.hurt.x = self.hurt.x + self.fuel*dt
self.hit.x = self.hit.x + self.fuel*dt
end
Code: Select all
love.graphics.setColor(self.hit.color)
love.graphics.rectangle("line", self.hurt.x+20 ,self.hurt.y , self.hit.w, self.hit.h)
Code: Select all
love.graphics.setColor(self.hit.color)
love.graphics.rectangle("line", self.hit.x ,self.hit.y , self.hit.w, self.hit.h)
Np! Essentially, it would be doing the exact same thing, but I would personally change it to the latter piece of code.pielago wrote: BTW I dont need to touch the draw function right? leave it a it is? taking the extra pixels???to thisCode: Select all
love.graphics.setColor(self.hit.color) love.graphics.rectangle("line", self.hurt.x+20 ,self.hurt.y , self.hit.w, self.hit.h)Code: Select all
love.graphics.setColor(self.hit.color) love.graphics.rectangle("line", self.hit.x ,self.hit.y , self.hit.w, self.hit.h)
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests