最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C語言實(shí)現(xiàn)Flappy Bird小游戲

 更新時(shí)間:2018年12月24日 08:37:07   作者:一個(gè)全棧游戲開發(fā)者  
這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)Flappy Bird小游戲,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語言實(shí)現(xiàn)Flappy Bird小游戲的具體代碼,供大家參考,具體內(nèi)容如下

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include<Windows.h>
/********函數(shù)變量聲明********/
#define PR_Box printf("■")
#define PR_Gold printf("★")
#define PR_Ag printf("☆")
#define PR_FBird printf("Ю")
#define PR_DBird printf("Ф")
#define PR_Land printf("┳┳┯")
#define PR_Bg_TL printf("╔")
#define PR_Bg_TR printf("╗")
#define PR_Bg_DL printf("╚")
#define PR_Bg_DR printf("╝")
#define PR_Bg_X printf("═")
#define PR_Bg_Y printf("║")
#define PR_Blank printf(" ");
int Grade = 1, C_Gold = 0, C_Ag = 0, Score = 0, Delay_time = 1000, Max_blank = 9, Distance = 18;
typedef struct Birds {
  int x, y;
  int condition;
}Birds;
 
Birds * Bird;
 
typedef struct Bg {
  int x, y;
  int l_blank;
  int reward[9];
  struct Bg * pri;
  struct Bg * next;
}Bg;
Bg * Bg1;
 
void Position(int x, int y) {
  COORD pos = {
    x - 1, y - 1
  };
  HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
  SetConsoleCursorPosition(Out, pos);
}
void CreatBird() {
  Bird -> x = 41;
  Bird -> y = 10;
  Bird -> condition = 0;
}
void CreatBg() {
  Bg * Bg2 = (Bg * ) malloc(sizeof(Bg));
  Bg1 -> x = 90;
  Bg1 -> y = 8;
  Bg2 -> x = Bg1 -> x + Distance;
  Bg2 -> y = 9;
  Bg1 -> l_blank = Max_blank - Grade;
  Bg2 -> l_blank = Max_blank - Grade;
  Bg1 -> next = Bg2;
  Bg1 -> pri = Bg2;
  Bg2 -> next = Bg1;
  Bg2 -> pri = Bg1;
}
void InsertBg(Bg * p) {
  int temp;
  Bg * Bgs = (Bg * ) malloc(sizeof(Bg));
  Bgs -> x = p -> pri -> x + Distance;
  Bgs -> l_blank = Max_blank - Grade;
  srand((int) time(0));
  temp = rand();
  if (temp % 2 == 0) //++
  {
    if ((temp % 4 + p -> pri -> y + Max_blank - Grade) < 21)
      Bgs -> y = p -> pri -> y + temp % 4;
    else
      Bgs -> y = p -> pri -> y;
  } else {
    if ((p -> pri -> y - temp % 4) > 2)
      Bgs -> y = p -> pri -> y - temp % 4;
    else
      Bgs -> y = p -> pri -> y;
  }
  Bgs -> pri = p -> pri;
  Bgs -> next = p;
  p -> pri -> next = Bgs;
  p -> pri = Bgs;
}
void Check_Bg(Bg * q) {
  Bg * p = q;
  int i = 0, temp;
  while (++i <= 5) {
    if (p -> x > -4)
      p = p -> next;
    else {
      srand((int) time(0));
      temp = rand();
      if (temp % 2 == 0) //++
      {
        if ((temp % 4 + p -> y + Max_blank - Grade) < 21)
          p -> y = p -> y + temp % 4;
        else
          p -> y = p -> y;
        p -> x = p -> pri -> x + Distance;
        p -> l_blank = Max_blank - Grade;
      } else {
        if ((p -> y - temp % 4) > 2)
          p -> y = p -> y - temp % 4;
        else
          p -> y = p -> y;
        p -> x = p -> pri -> x + Distance;
        p -> l_blank = Max_blank - Grade;
      }
    }
  }
}
void Loop_Bg(Bg * q) {
  Bg * p = q;
  int i = 0;
  while (++i <= 5) {
    p -> x = p -> x - 1;
    p = p -> next;
    if (Bird -> x == p -> x) {
      Score += 1;
      if (Score % 4 == 0 && Grade < 4)
        Grade++;
    }
  }
}
void Prt_Bg(Bg * q) {
  Bg * p = q;
  int i = 0, k, j;
  while (++i <= 5) {
    if (p -> x > 0 && p -> x <= 78) {
      for (k = 2; k < p -> y; k++) {
        Position(p -> x + 1, k);
        PR_Box;
        PR_Box;
        PR_Blank
      }
      Position(p -> x, p -> y);
      PR_Box;
      PR_Box;
      PR_Box;
      PR_Blank;
      Position(p -> x, p -> y + p -> l_blank);
      PR_Box;
      PR_Box;
      PR_Box;
      PR_Blank;
      k = k + p -> l_blank + 1;
      for (k; k <= 22; k++) {
        Position(p -> x + 1, k);
        PR_Box;
        PR_Box;
        PR_Blank;
      }
      Position(p -> x, 23);
      for (k = 1; k < Distance / 3 - 2; k++)
        PR_Land;
    }
    p = p -> next;
    if (p -> x == 0) {
      for (j = 2; j < p -> y; j++) {
        Position(p -> x + 1, j);
        PR_Blank;
        PR_Blank;
      }
      Position(p -> x + 1, p -> y);
      PR_Blank;
      PR_Blank;
      PR_Blank;
      Position(p -> x + 1, p -> y + Max_blank - Grade);
      PR_Blank;
      PR_Blank;
      PR_Blank;
      j = j + Max_blank - Grade + 1;
      for (j; j <= 22; j++) {
        Position(p -> x + 1, j);
        PR_Blank;
        PR_Blank;
      }
    }
  }
}
void PrtBg() {
  int i;
  Position(1, 1);
  PR_Bg_TL;
  Position(79, 1);
  PR_Bg_TR;
  Position(1, 24);
  PR_Bg_DL;
  Position(79, 24);
  PR_Bg_DR;
  for (i = 3; i <= 78; i += 2) {
    Position(i, 1);
    PR_Bg_X;
    Position(i, 24);
    PR_Bg_X;
  }
}
void PrtBird() {
  Position(Bird -> x, Bird -> y - 1);
  PR_Blank;
  Position(Bird -> x, Bird -> y);
  PR_FBird;
  Position(38, 2);
  printf("Score:%d", Score);
}
int CheckYN(Bg * q) {
  Bg * p = q;
  int i = 0;
  while (++i <= 5) {
    if (Bird -> y > 23)
      return 0;
    if (Bird -> x == p -> x && Bird -> y <= p -> y)
      return 0;
    if ((Bird -> x == p -> x || Bird -> x == p -> x + 1 || Bird -> x == p -> x + 2) && Bird -> y == p -> y)
      return 0;
    if (Bird -> x == p -> x && Bird -> y > p -> y + p -> l_blank)
      return 0;
    if ((Bird -> x == p -> x || Bird -> x == p -> x + 1 || Bird -> x == p -> x + 2) && Bird -> y == p -> y +
      p -> l_blank)
      return 0;
    p = p -> next;
  }
  return 1;
}
void Prtfirst() {
  printf("══════════════════════════════════════\n");
  printf(" ■■ ■■\n");
  printf(" ■■ ■■\n");
  printf(" ■■ ■■ C語言版 Flappy Bird\n");
  printf(" ■■ ■■ 瞎搞人:yyposs\n");
  printf(" ■■ ■■ 瞎搞日期:2014.2\n");
  printf(" ■■ ■■ 耗時(shí):4小時(shí)\n");
  printf(" ■■■ ■■ 游戲說明:\n");
  printf(" ■■ 1-按上箭頭使鳥起飛\n");
  printf(" ■■ 2-等級(jí)越高,難度越大!\n");
  printf(" Ю ■■■\n");
  printf("\n");
  printf(" ■■■ 歡迎各路大神一起探討\n");
  printf(" ■■\n");
  printf(" ■■\n");
  printf(" ■■ ■■■ 【無版權(quán),隨意修改】\n");
  printf(" ■■ ■■\n");
  printf(" ■■ Ф ■■\n");
  printf(" ■■ ■■\n");
  printf(" ■■ ■■\n");
  printf(" ■■ ■■\n");
  printf(" ■■ ■■\n");
  printf(" ┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳\n");
  system("pause");
  Position(1, 1);
  int i = 0;
  while (i++ < 40 * 25)
    PR_Blank;
}
 
void main() {
 
  int i = 0;
  Bird = (Birds * ) malloc(sizeof(Birds));
  Bg1 = (Bg * ) malloc(sizeof(Bg));
  Prtfirst();
  PrtBg();
  CreatBg();
  InsertBg(Bg1);
  InsertBg(Bg1);
  InsertBg(Bg1);
  CreatBird();
  while (1) {
    if (!CheckYN(Bg1))
      break;
    Check_Bg(Bg1);
    Prt_Bg(Bg1);
    PrtBird();
    Loop_Bg(Bg1);
    Bird -> y = Bird -> y + 1;
    if (GetAsyncKeyState(VK_UP)) {
      Position(Bird -> x, Bird -> y - 1);
      PR_Blank;
      Bird -> y = Bird -> y - 4;
    }
    while (i++ < 500); {
      Sleep(100);
    }
    i = 0;
  }
  Position(38, 10);
  printf("You Lost!");
  Position(1, 25);
  system("pause");
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C++ 微信多開的實(shí)現(xiàn)

    C++ 微信多開的實(shí)現(xiàn)

    本文主要介紹了C++ 微信多開的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • C++字符串提取和分割的多種方法

    C++字符串提取和分割的多種方法

    在C++編程中,字符串處理是一個(gè)常見的任務(wù),尤其是在需要從字符串中提取特定數(shù)據(jù)時(shí),本文將詳細(xì)探討如何使用C++標(biāo)準(zhǔn)庫中的工具來提取和分割字符串,并分析不同方法的適用場(chǎng)景和優(yōu)缺點(diǎn),我們將通過多個(gè)示例代碼逐步講解,幫助讀者掌握字符串處理的技巧,需要的朋友可以參考下
    2025-03-03
  • C語言中如何利用循環(huán)嵌套輸出一個(gè)菱形

    C語言中如何利用循環(huán)嵌套輸出一個(gè)菱形

    這篇文章主要介紹了C語言中如何利用循環(huán)嵌套輸出一個(gè)菱形問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • 一文秒懂C語言/C++內(nèi)存管理(推薦)

    一文秒懂C語言/C++內(nèi)存管理(推薦)

    在C++中,內(nèi)存分為:棧、堆、自由存儲(chǔ)區(qū)、全局/靜態(tài)存儲(chǔ)區(qū)、常量存儲(chǔ)區(qū)。這篇文章主要介紹了一文秒懂C語言/C++內(nèi)存管理,需要的朋友可以參考下
    2020-11-11
  • Qt實(shí)現(xiàn)實(shí)時(shí)鼠標(biāo)繪制圖形

    Qt實(shí)現(xiàn)實(shí)時(shí)鼠標(biāo)繪制圖形

    這篇文章主要介紹了Qt中QGraphicsView架構(gòu)下如何實(shí)現(xiàn)實(shí)時(shí)鼠標(biāo)繪制圖形,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起動(dòng)手試一試
    2022-02-02
  • opencv車道線檢測(cè)的實(shí)現(xiàn)方法

    opencv車道線檢測(cè)的實(shí)現(xiàn)方法

    這篇文章主要介紹了opencv車道線檢測(cè)的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • C語言實(shí)現(xiàn)Linux下的socket文件傳輸實(shí)例

    C語言實(shí)現(xiàn)Linux下的socket文件傳輸實(shí)例

    這篇文章主要介紹了C語言實(shí)現(xiàn)Linux下的socket文件傳輸?shù)姆椒?較為詳細(xì)的分析了C語言文件Socket文件傳輸客戶端與服務(wù)器端相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2015-06-06
  • 關(guān)于C++地址交換的實(shí)現(xiàn)

    關(guān)于C++地址交換的實(shí)現(xiàn)

    在C++中,地址交換通常是指通過指針操作改變兩個(gè)變量之間的內(nèi)存地址引用,當(dāng)你有兩個(gè)指針分別指向兩個(gè)變量時(shí),你可以通過某種機(jī)制交換這兩個(gè)指針的內(nèi)容,使得它們各自指向?qū)Ψ皆瓉淼奈恢?本介紹了關(guān)于C++地址交換的實(shí)現(xiàn),需要的朋友可以參考下
    2024-11-11
  • 基于C語言實(shí)現(xiàn)創(chuàng)意多彩貪吃蛇游戲

    基于C語言實(shí)現(xiàn)創(chuàng)意多彩貪吃蛇游戲

    這篇文章主要介紹了如何利用C語言實(shí)現(xiàn)一個(gè)創(chuàng)意多彩貪吃蛇游戲,這是一個(gè)純C語言外加easyx庫的繪圖函數(shù)制作而成的有趣小游戲,無需引入額外資源,感興趣的可以動(dòng)手嘗試一下
    2022-08-08
  • C++?STL容器適配器使用指南

    C++?STL容器適配器使用指南

    C++?STL(標(biāo)準(zhǔn)模板庫)是一套功能強(qiáng)大的?C++?模板類,提供了通用的模板類和函數(shù),這些模板類和函數(shù)可以實(shí)現(xiàn)多種流行和常用的算法和數(shù)據(jù)結(jié)構(gòu),如向量、鏈表、隊(duì)列、棧,今天我們來探究一下stl容器適配器的使用吧
    2021-11-11

最新評(píng)論

渭南市| 九龙县| 大姚县| 马公市| 翼城县| 贵德县| 承德县| 吉水县| 金湖县| 左贡县| 禄劝| 临汾市| 锡林浩特市| 永和县| 邢台市| 遵化市| 吴堡县| 双鸭山市| 偃师市| 安仁县| 江达县| 武隆县| 牡丹江市| 贡山| 安平县| 巴中市| 汶上县| 长子县| 丰顺县| 牡丹江市| 沅陵县| 铁岭县| 合阳县| 南充市| 屏南县| 平定县| 新竹市| 东辽县| 长子县| 土默特左旗| 龙江县|