来自童晶老师的游戏开发课程作业-flappy bird

此作业的要求:https://edu.cnblogs.com/campus/nenu/2020Fall/homework/11577

一、代码及git

版本控制:https://github.com/18244088809/flappy-bird.git

二、功能和截图,讲解关键技术和代码片断。

功能:场景移动以及撞击检测

当鸟移动到柱子的坐标时,进行判断。若鸟的位置在柱子的空隙中分数加一,不在则意为碰到柱子,游戏退出。
柱子的坐标移动到头时,将柱子的坐标重新设置。并且缺口位置随机生成。

代码:

void updateWithOutInput(){
    if(bar_y==bird_y){
        if(bird_x>bar_xTop&&bird_x<bar_xDown){
            score++;
        }else{
            exit(0);
        }
    }
    bird_x++;
    if(bar_y>0){
        bar_y--;
    }else{
        bar_y = width;
        int randPosition = rand()%(high-5);
        bar_xTop = randPosition; 
        bar_xDown = randPosition+high/4;
    }
}

实现效果

三、WBS:

估算时间(分钟) 实际耗时(分钟)
分析 30 42
初始化 30 60
撞击检测 60 65
调试 30 52

四、PSP:

任务 开始时间 结束时间 中断时间(分钟) delta时间(分钟)
初始化数据 12.7 20:09 12.7 21:09 0 60
按键起跳 12.8 9:31 12.8 10:07 0 36
柱子显示、移动 12.8 10:07 12.8 10:37 0 30
场景横移 12.8 15:45 12.8 16:00 0 15
撞击检测、计分 12.8 17:00 12.8 18:05 0 65
调试 12.8 18:05 12.8 18:57 0 52
原文地址:https://www.cnblogs.com/dul843/p/14099288.html