Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Cette ligne permet d'afficher des traces dans la console pendant l'éxécution
- io.stdout:setvbuf('no')
- -- Cette ligne permet de déboguer pas à pas dans ZeroBraneStudio
- if arg[#arg] == "-debug" then require("mobdebug").start() end
- vaisseau = {}
- vaisseau.canvas = love.graphics.newCanvas(20,30)
- vaisseau.x = 0
- vaisseau.y = 0
- vaisseau.angle = 270
- vaisseau.vx = 0
- vaisseau.vy = 0
- vaisseau.speed = 3
- function love.load()
- largeur = love.graphics.getWidth()
- hauteur = love.graphics.getHeight()
- vaisseau.x = largeur / 2
- vaisseau.y = hauteur / 2
- love.graphics.setCanvas(vaisseau.canvas)
- love.graphics.setColor(255,128,128)
- love.graphics.setLineWidth(1.5)
- love.graphics.polygon("line", {0, 0, 10, 30, 20, 0, 10, 10})
- love.graphics.setCanvas()
- end
- function love.update(dt)
- if love.keyboard.isDown("right") then
- vaisseau.angle = vaisseau.angle + (90 * dt)
- if vaisseau.angle > 360 then vaisseau.angle = 0 end
- end
- if love.keyboard.isDown("left") then
- vaisseau.angle = vaisseau.angle - (90 * dt)
- if vaisseau.angle < 0 then vaisseau.angle = 360 end
- end
- if love.keyboard.isDown("up") then
- local angle_radian = math.rad (vaisseau.angle)
- local force_x = math.cos(angle_radian) * (vaisseau.speed * dt)
- local force_y = math.sin(angle_radian) * (vaisseau.speed * dt)
- vaisseau.vx = vaisseau.vx + force_x
- vaisseau.vy = vaisseau.vy + force_y
- end
- --vaisseau.vy = vaisseau.vy + (0.6 * dt)
- -- if math.abs(vaisseau.vx) > 1 then
- -- if vaisseau.vx > 0 then
- -- vaisseau.vx = 1
- -- else
- -- vaisseau.vx = -1
- -- end
- -- end
- -- if math.abs(vaisseau.vy) > 1 then
- -- if vaisseau.vy > 0 then
- -- vaisseau.vy = 1
- -- else
- -- vaisseau.vy = -1
- -- end
- -- end
- -- vaisseau.x = vaisseau.x + vaisseau.vx
- -- vaisseau.y = vaisseau.y + vaisseau.vy
- end
- function love.draw()
- love.graphics.draw(vaisseau.canvas,vaisseau.x,vaisseau.y,vaisseau.angle,1,1)
- --love.graphics.polygon('fill', 125, 100, 135, 75, 145, 100)
- love.graphics.print("Score : 0", 10, 10)
- love.graphics.print("Vie : 3", 10, 30)
- end
- function love.keypressed(key)
- print(key)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement