zoukankan      html  css  js  c++  java
  • 一个超级无聊的小游戏,来体验吧

    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <windows.h >
    void gotoxy(int x,int y)  //cursor an gewuenschte position auf dem bildschirm setzen
    {
    CONSOLE_SCREEN_BUFFER_INFO  csbiInfo;  //variablendklaration
    HANDLE  hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
    csbiInfo.dwCursorPosition.X = x;  //cursorposition X koordinate festlegen
    csbiInfo.dwCursorPosition.Y = y;  //cursorposition Y koordinate festlegen
    SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);  //den cursor an die
    //festgelegte koordinate setzen;
    }
    int x=10, y=10,ch,i,j,n,m;
    int map[15][15]={
    1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
    1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
    };
    void tell()
    {
    if(map[y-1][x-1]==1){map[y-1][x-1]=0;n++;}
    if(n>=m){system("cls");printf("win");getch();}
    }
    void draw(int x,int y)
    {
    system("cls");
    for(i=0;i<15;i++)
    for(j=0;j<15;j++)
    {
    if(map[i][j]==1){gotoxy(j+1, i+1);printf("%c",3);}
    }
    gotoxy(x, y);
    printf("%c",2);
    }
    int main()
    {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
    FOREGROUND_INTENSITY | FOREGROUND_BLUE);
    for(i=0;i<15;i++)
    for(j=0;j<15;j++)
    if(map[j][i]==1)m=m+1;
    draw(x,y);
    while("")
    {
    ch=getch();
    switch(ch)
    {
    case 72:
    y-=1;tell();draw(x,y);break;
    case 80:
    y+=1; tell();draw(x,y);break;
    case 75:
    x-=1;tell(); draw(x,y);break;
    case 77:
    x+=1; tell();draw(x,y);break;
    }
    }
    }
    真的好无聊
  • 相关阅读:
    贪心算法 Wooden Sticks
    HDOJ 2189 悼念512汶川大地震遇难同胞——来生一起走
    hdoj1069 Monkey and Banana(最长上升子序列)
    2012级计科《程序设计基础Ⅱ》期末上机考试
    Constructing Roads In JGShining's Kingdom
    c语言学习随笔之指针(二)
    c语言学习随笔之指针(一)
    遍历网页框架结构
    笔记本测试软件(让奸商头疼的软件)0
    ResizePicturevb.net
  • 原文地址:https://www.cnblogs.com/mayitao/p/5983570.html
Copyright © 2011-2022 走看看