电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>电子资料>液晶游戏机开源分享

液晶游戏机开源分享

2022-11-22 | zip | 0.13 MB | 次下载 | 2积分

资料介绍

描述

您好,它非常简单,因此无需解释,只需获取零件并使用接线图复制代码即可!

怎么玩!

PITF-ARD 点击开始。向右走找到门钥匙以完成关卡。向上移动操纵杆跳跃。

#include 
#include 
#include 
LiquidCrystal_I2C lcd(0x27,16,2);
// VARIABLES DECLARATION
int game = 0;
int gameover = 0;
int le = 0;
float ll = 0;
int key = LOW;
int mov=0;
int cc=1;
int screen1[202];
int screen2[202];
int ind = 0;
int randomNumber=0;
int ax=0;
int ay=0;
int timegame=2000;
int clef = 0;
int jump = 0;
int path = 42;
int ck = 2;
// CHARS DECLARATION
byte man1[] = {0x04, 0x0E, 0x0E, 0x0E, 0x04, 0x04, 0x1F, 0x1F} ;
byte man2[] = {0x04, 0x1E, 0x05, 0x04, 0x0B, 0x10, 0x1F, 0x1F} ;
byte man3[] = {0x04, 0x0F, 0x14, 0x04, 0x1A, 0x01, 0x1F, 0x1F} ;
byte man4[] = {0x15, 0x0E, 0x04, 0x0E, 0x11, 0x00, 0x00, 0x00} ;
byte man5[] = {0x15, 0x0E, 0x04, 0x0E, 0x11, 0x00, 0x1F, 0x1F} ;
byte man6[] = {0x00, 0x00, 0x04, 0x0E, 0x04, 0x04, 0x1F, 0x1F} ;
byte flat[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F};
byte hole[] = {0x0E, 0x1F, 0x15, 0x1B, 0x0E, 0x04, 0x1F, 0x1F} ;
byte m1[] = {0x1F, 0x1F, 0x1F, 0x19, 0x10, 0x00, 0x00, 0x00} ;
byte m2[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x06, 0x00} ;
byte m3[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0C, 0x00, 0x00} ;
byte m4[] = {0x1F, 0x1F, 0x00, 0x0A, 0x00, 0x0A, 0x00, 0x0A} ;
byte m5[] = {0x1F, 0x1F, 0x1F, 0x00, 0x0A, 0x00, 0x0A, 0x00} ;
byte m6[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x0A, 0x00} ;
byte keys[8] = {0x00, 0x03, 0x1F, 0x13, 0x00, 0x00, 0x1F, 0x1F} ;
byte dooro[8] = {0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F} ;
byte door[8] = {0x1F, 0x1F, 0x1D, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F} ;
void setup(){
 lcd.init();
 lcd.backlight();
 lcd.home();
 lcd.clear();
// CHARACTER ASSOCIATION
 lcd.createChar(1, man1);
 lcd.createChar(2, flat);
 lcd.createChar(3, hole);
 lcd.createChar(8, keys);
 lcd.createChar(7, door);
}
void loop(){
 if (game == 0)
 {
   if (gameover == 0)
     {
     // TITLE SCREEN SCREEN
       lcd.home();
       lcd.setCursor(0, 0);
       lcd.print("  Key game");
       lcd.setCursor(0, 1);
       lcd.print(" 2020"); 
       key = digitalRead(7);
       if (key == LOW)
           {
           // INIT GAME
           lcd.clear();
           lcd.home();
           le = 0;
           ll = 0;
           gameover = 1;
           cc=2;
           jump = 0;
           path = 16;
           } 
      }
    else
      {
          // NEW SCREEN - START
           randomSeed(analogRead(0));
           game = 1;
           key = LOW;
           le = le + 1;
           ll = ll + 1;
           path = path + 10;
           if (path>202)
           {
           path = 202;
           }
           ind = 0;
           for(int s=0;s<(path + 10);s++)
            {
            screen1[s] = 2;        
            }
           for(int s=11;s<(path -2 );s=s+3)
            {
            randomNumber = int(random(2, 4));
            //randomNumber = 3;
            screen1[s] = randomNumber;        
            }
           screen1[6]=7;
           screen1[path + 1]=8;
           for(int s=0;s<(path+10);s++)
            {
            randomNumber = int(random(4, 7));
            screen2[s] = randomNumber;        
            }
          if ((ll/2) == int(ll/2))
            {
             lcd.createChar(4, m4);
             lcd.createChar(5, m5);
             lcd.createChar(6, m6);
            }
            else
            {
             lcd.createChar(4, m1);
             lcd.createChar(5, m2);
             lcd.createChar(6, m3);
            }
          timegame = 2000;
          clef = 0;
          lcd.createChar(7, door);
          cc = 2;
          ck = 2;
    }
 }
 else
 {
 // GAME LOOP
     if (jump == 3)
     {
     jump = 0;
     }
     lcd.home();
     timegame = timegame - le;
     for(int s=ind;s<(ind+16);s++)
     {
      lcd.setCursor(s-ind, 0);
      lcd.write(byte(screen2[s]));
      lcd.setCursor(s-ind, 1);
      lcd.write(byte(screen1[s]));
     }
     if (timegame < 0)
     {
       timegame = 0;
     }
     lcd.setCursor(16-String(timegame).length(), 0);
     lcd.print(timegame);
if (jump == 0)
{
    lcd.setCursor(7, 1);
    lcd.write(byte(1));
    ck = screen1[ind+7];
    if (mov == 1)
     {
     if (cc==1)
     {
       lcd.createChar(1, man1);
     }
     else
     {
       lcd.createChar(1, man1);
     }
     mov = 0;
     }
     else
     {
     lcd.createChar(1, man1);
     mov = 1;
     }
}
if (jump > 0)
{
      lcd.setCursor(7, 0);
      lcd.write(byte(1));
      lcd.createChar(1, man4);
      if (cc == 2)
      {
      ind = ind + 1;
      }
      else
      {
      ind = ind - 1;
      }
 if (jump == 1)
 {
      jump = 2;
 }
 else
 {
      jump = 3;
 }
}    
     // CHECK LIVE OR DIE - LOOP GAME OR GAME OVER
     if ((ck == 2)&&(timegame>0))  // SET THE VARIABLE TO CHECK
     {
     ay = analogRead(1);   
     ax = analogRead(0);
     if ((ax > 600) && (jump == 0))
       {
           if (ind<(path-7))
           {
           ind = ind + 1;
           cc = 2;
           }
           else
           {
             screen1[path + 1]=2;
             clef = 1;
             lcd.createChar(7, dooro);
           }
       }
     if ((ax < 200) && (jump == 0))
     {
           if (ind>0)
           {
              ind = ind - 1;
              cc = 1;
           }
           else
           {
            if (clef==1)
            {
             // CHECK LEVEL CLEAR - START
           lcd.setCursor(0, 1);
           lcd.print("                ");
           lcd.setCursor((int(10-String(le).length())/2),1);
           lcd.print("LEVEL ");
           lcd.print(le+1);
           delay(4000);
           lcd.clear();    
           game = 0;
           gameover = 1;
//  CHECK LEVEL CLEAR - END
             }
           }
     }
     if ((ay < 200) && (ind >1) && (ind <(path - 8)) && (jump == 0))
     {
     jump = 1;
     }
     delay(200);
// GAME LOOP - END
 }
 else
 {
//  GAME OVER - START
   if (timegame>0)
     {
     lcd.setCursor(0, 0);
     lcd.print("   GAME  OVER :(   ");
     lcd.setCursor(7, 1);
     lcd.write(byte(1));
     lcd.createChar(1, man6);
     }
     else
     {
     lcd.setCursor(0, 1);
     lcd.print("   TIME  OVER   ");  
     }
     delay(4000);
     lcd.clear();    
     game = 0;
     gameover =0;
//  GAME OVER - END
   }
 }
}

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费