feur


Code:

-- motion input
-- by ajinis
motion_sequence = {}
motion_timer = 0
max_motion_time = 30
correct_motion = {⬇️, ➡️}
motion_index = 1
input_detected = false
result_message = ""
message_timer = 60
function _init()
   
    reset_motion()
end
function reset_motion()
    motion_sequence = {}
    motion_timer = max_motion_time
    motion_index = 1
    input_detected = false
end
function detect_motion()
    local input = nil
    
    
    if btn(⬇️) then
        input = "down"
    elseif btn(➡️) then
        input = "right"
    elseif btn(⬅️) then
        input = "left"
    elseif btn(⬆️) then
        input = "up"
    end
    
    return input
end
function _update()
   
    if motion_timer > 0 then
        motion_timer -= 1
    else
        reset_motion() 
    end          if message_timer > 0 then         message_timer -= 1     else         result_message = ""     end               local input = detect_motion()     if input then                 motion_sequence[motion_index] = input         motion_index += 1         motion_timer = max_motion_time
        input_detected = true     else         input_detected = false     end          -- verifie la sequance     if #motion_sequence == #correct_motion then         local success = true         for i=1,#correct_motion do             if (correct_motion[i] == ⬇️ and motion_sequence[i] ~= "down") or                (correct_motion[i] == ➡️ and motion_sequence[i] ~= "right") then                 success = false                 break             end         end                  if success then             -- sequence bonne             result_message = "hadouken!"         else             -- sequence mauvaise             result_message = "trop naze."         end                  -- reinisialiser         reset_motion()         message_timer = 60 -- durれたe du message (1 seconde れき 30 fps)     end end function _draw()     cls()              print("fais un quart de cercle avant", 5, 5)     print("(⬇️➡️):")     for i=1,#motion_sequence do         print(motion_sequence[i], 5, 20 + i*10)     end              if input_detected then         print("input detecte !", 5, 60)     else         print("aucun input...", 5, 60)     end               if result_message ~= "" then         print(result_message, 5, 80)         end                      print("timer: "..motion_timer, 5, 70) end

StatusPrototype
PlatformsHTML5
AuthorAjinis
GenreFighting
Made withPICO-8