使用c++编程实现简单的打字小游戏

目录

你是否对键盘熟悉?

“qwertyuiopasdfghjklzxcvbnm”是否已经印在你的脑海里?

NO?

没有关系,今天,让我来帮你对键盘有一个更深一步的了解吧!

#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
#include"conio.h"
void entry_place(int num)
{
 for(int i;i<num;i++)
 printf(" ");
}
void enter_line(int num)
{
 int i;
 for(i=0;i<num;i++)
 {
  printf("\n");
 }
}
int main()
{
 enter_line(15);
 entry_place(40);
 printf("press anykey to start");
 getchar();
 system("cls");
 int  levels=0,score=0,lines=0,num=0,col=0;
    while(1)
    {
     system("cls");
    for(int i=0;i<20;i++)
 {
  printf(" ");
 }
 printf("levels:%d",levels);
 entry_place(10);
 printf("score:%d",score);
    printf("\n");
 entry_place(20);
 printf("1---Pause");
 entry_place(9);
    printf("0---Exit");
    printf("\n");
 for(int i=0;i<80;i++)
 {
  printf("_");
 }
 enter_line(1);
 num=rand()%26;
 col=rand()%80;
 while(1)
 {
 lines++;
 if(lines>25)
 {
  lines=0;
  score-=10;
  if(score<-50)
  {
   system("cls");
   enter_line(15);
   entry_place(40);
   printf("sorry,you faile!");
   getch();
   exit(0);
  }
  break;
 }
 entry_place(col);
 printf("%c",'a'+num);
 Sleep(180);
 printf("\b \n");

 if(kbhit())
 {
  char c=getch();
  if(c=='a'+num)
  {
   score+=10;
   break;
  }
 }
   }
   }
 return 0;
 }

这样,不论你是什么人,你都会对键盘的了解更深刻。

ok了,今天的内容就是这样,我们下章再见!

更多关于c++实现小游戏的资料请关注我们其它相关文章!

(0)

相关推荐

  • C++实现的打字母游戏示例

    本文实例讲述了C++实现的打字母游戏.分享给大家供大家参考,具体如下: // 打字母的游戏 // 编译代码请先安装 VC 绘图库(V20091123) #include <graphics.h> #include <conio.h> #include <time.h> // 欢迎界面 void welcome() { // 输出屏幕提示 cleardevice(); setcolor(YELLOW); setfont(64, 0, "黑体"); ou

  • 利用c++编写简易版2048小游戏

    目录 1.程序初始化 2.画图操作 3.字符控制 4.判断游戏结束和游戏胜利 别的不多说,先上效果图 我们都知道2048是个4 4的方格,为了方便数组下表我们生成5 5的数组,只用到1~4的下标. 初始化时候先随便生成两个目标 1.程序初始化 // 程序初始化 void init() { score = 0; memset(a, 0, sizeof(a)); int x1 = rand() % 4 + 1, y1 = rand() % 4 + 1, x2 = rand() % 4 + 1, y2

  • C++实现简单射击小游戏

    使用c++制作简单的横板射击小游戏,供大家参考,具体内容如下 #include <easyx.h> #include <time.h> #include <conio.h> class Bullet; class Tank; class E_Bullet; class Boss; bool dead = false; bool wined = false; struct pos//坐标类 { int a; int b; }; class E_Bullet//敌人打出的子

  • 神奇的c/c++小游戏((提高你的编程兴趣)

    目录 神奇的c/c++ 神奇的c/c++ 以下代码在Dev,codeblocks,VC上都能运行 #include<stdio.h> #include<time.h> #include<stdlib.h> #include<conio.h> #include<windows.h> //下面Sleep()函数的头文件 #include<mmsystem.h> void menu() { printf(" ***********

  • 使用c++编程实现简单的打字小游戏

    目录 你是否对键盘熟悉? "qwertyuiopasdfghjklzxcvbnm"是否已经印在你的脑海里? NO? 没有关系,今天,让我来帮你对键盘有一个更深一步的了解吧! #include"stdio.h" #include"stdlib.h" #include"windows.h" #include"conio.h" void entry_place(int num) { for(int i;i<

  • C#实现简单打字小游戏

    本文实例为大家分享了C#实现简单打字小游戏的具体代码,供大家参考,具体内容如下 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.For

  • 原生js实现的金山打字小游戏(实例代码详解)

    首先先来看一下效果图 如果感兴趣的就来看一下Js源码吧 //计分板 var board = { dom: document.getElementById("score"), maxLost: 3, //最大丢失量 lost: 0, //当前丢失了多少个 score: 0, //当前分数 render: function() { //显示 this.dom.innerHTML = "<p>得分:" + this.score + "</p&g

  • java编写的简单移动方块小游戏代码

    本文实例讲述了java编写的简单移动方块小游戏代码.分享给大家供大家参考,具体如下: 运行效果截图如下: 第一次用java编写图形化的界面,还是有些青涩..以后继续努力!!具体代码如下: //Little Box Game by AlexYui //Game.java By 1093710210@ HIT import javax.swing.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.*; import

  • C语言实现最简单的剪刀石头布小游戏示例

    本文实例讲述了C语言实现最简单的剪刀石头布小游戏.分享给大家供大家参考,具体如下: #include<stdio.h> #include<stdlib.h> #include<time.h> /*************\ * 剪刀 石头 布 * * 最简单小游戏 * \*************/ int main(void){ char gesture[3][10] = {"scissor","stone","clo

  • C#实现打字小游戏

    本文实例为大家分享了C#实现打字小游戏的具体代码,供大家参考,具体内容如下 using System; using System.Drawing; using System.Windows.Forms; namespace 打字游戏 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //创建飞机 PictureBox plan = new PictureBox(); Button kai

  • C语言简单实现扫雷小游戏

    本文实例为大家分享了C语言简单实现扫雷小游戏 的具体代码,供大家参考,具体内容如下 游戏规则: 以9*9棋盘为例,棋盘上随机分布着10个地雷,玩家在棋盘上进行点击,如果被点击的格子是地雷,则玩家被炸"死",游戏结束:如果被点击的格子上没有地雷,与被点击的格子相邻的格子(被点击格子的上下左右还有斜向,共八个格子)有地雷,则在被点击的格子上显示这些地雷的总数,如果与被点击的格子相邻的八个格子都没有地雷,则棋盘自动展开,直到与展开的格子相邻的格子有地雷才停止.此时最后被展开的格子显示其相邻格

  • Python实现简单的2048小游戏

    本文实例为大家分享了Python实现简单的2048小游戏的具体代码,供大家参考,具体内容如下 运行效果: 1.项目结构 2.代码 configs.py import argparse def parse_args(): parser = argparse.ArgumentParser(description='Game 2048') # Form """ screen_width: Width of the form screen_height: Height of the

  • C#实现简单飞行棋小游戏

    本文实例为大家分享了C#实现简单飞行棋小游戏的具体代码,供大家参考,具体内容如下 目标:实现飞行棋游戏基础功能 玩家在地图触发道具: 1.获得道具,可以进行一次选择 1–交换位置 2–让对方退随机格子 2.踩到炸弹,让对方暂停一回合 3.乘上了飞机,前进10格 4.进入隧道,将随机从其他隧道口出来 using System; namespace FXQGame { class Program { //储存地图数组 static int[] mMaps = new int[120]; //储存两个

  • C++实现简单贪吃蛇小游戏

    本文实例为大家分享了C++实现简单贪吃蛇小游戏的具体代码,供大家参考,具体内容如下 1 贪吃蛇游戏原理 1.1 构造蛇身:定义一个坐标数组,存放的是蛇的每一节蛇身所在的坐标位置. 1.2 移动效果:每次移动时,将每一节蛇身(蛇头除外)依次往前移动一节,去掉蛇的最后一节,确定蛇的方向 1.3 移动判断:每次移动时,判断蛇头是否触碰食物,如果碰到了食物,只进行前移蛇身和增加蛇头的操作,不进行擦除蛇尾的操作 2游戏设计 2.1 游戏首页 2.2 开始游戏 2.3 退出游戏 3.游戏实现 3.1 游戏首

随机推荐