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

📄 打字母游戏tt.v1.02.txt

📁 打字母游戏,经典好玩的游戏
💻 TXT
字号:
//进入后,别忘了先按下capslock键
//用的技术还是比较落后的,也没有什么算法
//希望能够多多交流,抛砖引玉
#define  SIZE 26
#include <graphics.h>
#include <iostream.h>
#include <dos.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <bios.h>
#include <math.h>
#define ESC 27 


void *buf[27];             //定义存放26个字母的指针数组和子弹
int maxx,maxy,game_speed;
int suffix,x,y=0;
char key;

struct character
{
    char ch;
    int color;
}character[SIZE];

struct Bullet             //子弹的结构体
{
    int x;
    int y;
}Bullet;

void Init()
{
    randomize();
    char buffer0[5];
    int gdriver=DETECT,gmode;
    initgraph(&gdriver,&gmode,"");
    maxx=getmaxx();
    maxy=getmaxy();
    settextjustify(1,1);
    settextstyle(0,0,2);
    setcolor(BLUE);
    outtextxy(maxx/2,maxy/2,"Welcome To TT!");
    settextstyle(0,0,1);
    setcolor(LIGHTGRAY);
    outtextxy(maxx/2+100,maxy/2+100,"Made By VC.Blood Night Flamen");
    key=getch();
    cleardevice();
    for(int i=0,j=65;i<26;i++,j++)
       character[i].ch=j;
}

void Draw()
{
    int size,size_bullet,i=0;
    char Alphabet,buffer[10];
    settextjustify(1,1);
    size=imagesize(95,95 ,105,105);
    setcolor(4);
    fillellipse(100,100,1,1);
    size_bullet=imagesize(99,99,101,101);
    buf[26]=malloc(size_bullet);
    getimage(99,99 ,101,101,buf[26]);
    cleardevice();
    for(Alphabet=65;Alphabet<91;Alphabet++,i++)
    {
        character[i].color=rand()%15+1;
        setcolor(character[i].color);
        sprintf(buffer, "%c",Alphabet);
        outtextxy(100,100,buffer);
        buf[i]=malloc(size);
        getimage(95,95,105,105,buf[i]);
        cleardevice();
    }
}

void MakeSound()
{
    for(int i=700;i<800;)
    {
        sound(i);
        delay(10);
        nosound();
        i+=10;
    }
}

void Alphabet_move()
{
    y++;
    putimage(x,y, buf[suffix], COPY_PUT);
    if(y>maxy)
       y=-1;
    delay(5);
}

int Bullet_move()
{
    Bullet.y=maxy+10;
    while(Bullet.y>y)
    {
        putimage(x,Bullet.y,buf[26],XOR_PUT);
        Bullet.y-=3;
        putimage(x,Bullet.y,buf[26],XOR_PUT);
        if(fabs(Bullet.y-y)<5)
        {
            MakeSound();
            y=-1;
            return 0;
        }
        Alphabet_move();
        delay(3);
    }
    return 0;
}

void main()
{
    Init();
    Draw();
    suffix=rand()%26;
    x=rand()%(maxx-40)+20;
    while(key!=ESC)
    {
        if(y==-1)
        {
            suffix=rand()%26;
            x=rand()%(maxx-40)+20;

        }
        Alphabet_move();
        if(kbhit())
        {
            key=getch();
            if(key==character[suffix].ch)
            {
                Bullet_move();
                cleardevice();
            }
        }
    }
    getch();
    closegraph();
}

⌨️ 快捷键说明

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