Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- largeur = love.graphics:getHeight()
- hauteur = love.graphics:getWidth()
- Carre_Bleu = {}
- Carre_Bleu.x = largeur/2
- Carre_Bleu.y = hauteur/2
- Carre_Bleu.w = 100
- Carre_Bleu.h = 100
- Carre_Rouge = {}
- Carre_Rouge.x = largeur/2
- Carre_Rouge.y = hauteur/2
- Carre_Rouge.w = 100
- Carre_Rouge.h = 100
- function love.load()
- image1 = love.graphics.newImage("image/Carre Bleu.png")
- image2 = love.graphics.newImage("image/Carre Rouge.png")
- image3 = love.graphics.newImage("image/Carre Vert.png")
- end
- function love.update(dt)
- --ici on test la collision entre les deux carrés si ils sont en contact "collision ok" est ecrit dans le terminal
- if Carre_Bleu.x < Carre_Rouge.x + Carre_Rouge.w and
- Carre_Bleu.x + Carre_Bleu.w > Carre_Rouge.x and
- Carre_Bleu.y < Carre_Rouge.y + Carre_Rouge.h and
- Carre_Bleu.h + Carre_Bleu.y > Carre_Rouge.y then
- print("collision ok")
- end
- if love.keyboard.isDown("right") then
- Carre_Bleu.x = Carre_Bleu.x + 4
- end
- if love.keyboard.isDown("left") then
- Carre_Bleu.x = Carre_Bleu.x - 4
- end
- if love.keyboard.isDown("up") then
- Carre_Bleu.y = Carre_Bleu.y - 4
- end
- if love.keyboard.isDown("down") then
- Carre_Bleu.y = Carre_Bleu.y + 4
- end
- if love.keyboard.isDown("q") then
- Carre_Rouge.x = Carre_Rouge.x + 4
- end
- if love.keyboard.isDown("d") then
- Carre_Rouge.x = Carre_Rouge.x - 4
- end
- if love.keyboard.isDown("z") then
- Carre_Rouge.y = Carre_Rouge.y - 4
- end
- if love.keyboard.isDown("s") then
- Carre_Rouge.y = Carre_Rouge.y + 4
- end
- end
- function love.draw()
- love.graphics.draw(image1, Carre_Rouge.x, Carre_Rouge.y)
- love.graphics.draw(image2, Carre_Bleu.x, Carre_Bleu.y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement