LaDissertation.com - Dissertations, fiches de lectures, exemples du BAC
Recherche

Casse Brique en LUA

Guide pratique : Casse Brique en LUA. Recherche parmi 297 000+ dissertations

Par   •  1 Juin 2020  •  Guide pratique  •  821 Mots (4 Pages)  •  403 Vues

Page 1 sur 4

io.stdout:setvbuf('no')

love.graphics.setDefaultFilter('nearest')

if arg[#arg] == "-debug" then require("mobdebug").start() end

local sndtouch = love.audio.newSource("sons/Blip_Select5.wav","static")

local sndBriqueTouch = love.audio.newSource("sons/Pickup_Coin19.wav","static")

local sndFond = love.audio.newSource("sons/8-bit-Arcade4-nosfx.mp3","stream")

sndFond:setLooping(true)

local balle = {}

local pad = {}

local brique = {}

local niveau = {}

balle.vx = 0

balle.vy = 0

balle.speed = 3

balle.x = 0

balle.y = 0

balle.rayon = 10

balle.colle = false

pad.largeur = 100

pad.hauteur = 20

pad.x = 0

pad.y = 0

brique.statutOK = true

function start()

balle.colle = true

niveau = {}

local l,c

for l=1,6 do

niveau[l] = {}

for c=1,15 do

niveau[l][c] = math.random(0,5)

print(niveau[l][c])

end

end

end

function love.load()

start()

sndFond:play()

largeur = love.graphics.getWidth()

hauteur = love.graphics.getHeight()

brique.hauteur = 25

brique.largeur = largeur /15

pad.y = hauteur - (pad.hauteur /2)

end

function love.update(dt)

pad.x = love.mouse.getX()

if balle.colle == true then

balle.x = pad.x

balle.y = pad.y - pad.hauteur/2 - balle.rayon

else

balle.x = balle.x + (balle.vx*dt)

balle.y = balle.y + (balle.vy*dt)

end

local c = math.floor(balle.x / brique.largeur) + 1

local l = math.floor(balle.y /brique.hauteur) + 1

if l >= 1 and l <= #niveau and c >= 1 and c <= 15 then

if niveau[l][c] >= 1 then

balle.vy = 0 - balle.vy

niveau[l][c] = niveau[l][c] -1

sndBriqueTouch:play()

end

end

if balle.x > largeur then

balle.vx = 0 - balle.vx

...

Télécharger au format  txt (3.8 Kb)   pdf (38.5 Kb)   docx (9.8 Kb)  
Voir 3 pages de plus »
Uniquement disponible sur LaDissertation.com