ca clignote :)
This commit is contained in:
parent
a2b0006d11
commit
61442993eb
1 changed files with 23 additions and 1 deletions
|
@ -13,7 +13,7 @@ console("Connecting...")
|
||||||
client:connect("student", password)
|
client:connect("student", password)
|
||||||
console("Connected !")
|
console("Connected !")
|
||||||
|
|
||||||
if neo ~= nil then
|
if neo == nil then
|
||||||
-- connecte la bande de led sur le pin 21
|
-- connecte la bande de led sur le pin 21
|
||||||
neo = neopixel.attach(neopixel.WS2812B, pio.GPIO21, 8)
|
neo = neopixel.attach(neopixel.WS2812B, pio.GPIO21, 8)
|
||||||
end
|
end
|
||||||
|
@ -37,6 +37,26 @@ function get_public_word()
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function set_color(r, g, b)
|
||||||
|
for i=0, 7 do
|
||||||
|
neo:setPixel(i, r, g, b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function blink(positive)
|
||||||
|
thread.start(function()
|
||||||
|
if positive then
|
||||||
|
set_color(0, 5, 0)
|
||||||
|
else
|
||||||
|
set_color(5, 0, 0)
|
||||||
|
end
|
||||||
|
neo:update()
|
||||||
|
tmr.delayms(50)
|
||||||
|
set_color(0, 0, 0)
|
||||||
|
neo:update()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function draw_ui()
|
function draw_ui()
|
||||||
cls()
|
cls()
|
||||||
if playing then
|
if playing then
|
||||||
|
@ -129,6 +149,7 @@ function handle_letter(len, message, topic_len, topic_name)
|
||||||
end
|
end
|
||||||
letters_played = letters_played .. message
|
letters_played = letters_played .. message
|
||||||
if not is_in_word(message) then
|
if not is_in_word(message) then
|
||||||
|
blink(false)
|
||||||
lives = lives - 1
|
lives = lives - 1
|
||||||
if lives == 0 then
|
if lives == 0 then
|
||||||
playing = false
|
playing = false
|
||||||
|
@ -141,6 +162,7 @@ function handle_letter(len, message, topic_len, topic_name)
|
||||||
console("du mot...")
|
console("du mot...")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
blink(true)
|
||||||
if not is_won() then
|
if not is_won() then
|
||||||
draw_ui()
|
draw_ui()
|
||||||
console(message .. " trouve ! Bien joue !")
|
console(message .. " trouve ! Bien joue !")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue