⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 check.c

📁 号作品是一个简单的全屏小游戏
💻 C
字号:
#include <stdio.h>
#include <allegro.h>
#include "rhythm.h"
#include "timer.h"

int play_rhythm(){
    
    int i, j, p, mytime;
    
    
    fscanf(fp, "%d", &rhy_len);
    timer_t = 0;
    p = 0;
    memset(rhy_b, 0, sizeof(rhy_b));
    for (i = 0; i < rhy_len; ++i){
        fscanf(fp, "%d", &rhy_notes[i]);
        for (j = 0; j < 5; ++j){
            rhy_b[rhy_notes[i]+j] = 1;
        }
    }
    tot_time = rhy_notes[rhy_len-1]+20;
        
    while (p < rhy_len){
        if (timer_t > rhy_notes[p]){
            ++p;
            sound();
            if (p == rhy_len){
                rest(500);
            }
        }
    }
    return rhy_len;
}

int check(int rhy_len_che){
    int i, old_t, tot_err, rhy_che_sum, rhy_che_len;
    
    rhy_che_len=rhy_len_che;
    timer_t = 0;
    old_t = 0;
    rhy_che_sum=0;
    while (timer_t < tot_time)
    {
        if (key[KEY_SPACE])
        {
            if (timer_t != old_t)
            {
                old_t = timer_t;
                for (i = 0; i < 5; ++i)
                {
                    rhy_b[old_t+i]--;
                }   
                sound();
                rhy_che_sum++;
            }
        }
        if (key[KEY_ESC]){
            exit_flag = 1;
            return;
        }
    }
    if(rhy_che_len!=rhy_che_sum)
    {
          return 0;
    }
    else
    {
        tot_err = 0;
        for (i = 0; i < tot_time; ++i)
        {
            if (rhy_b[i] != 0)
            {
                    ++tot_err;
            }
        }
        textprintf_ex(screen, font, 10, 10, makecol(255, 100, 200),-1, "Score: %d", tot_err);
        if (tot_err < 30)
        {
           return 1;
        }
        else
        {
             return 0;
        }
    }
}
    
    


    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -