huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
    int x = 0;
    int y = 0;
    int px = 5;
    int py = 5;
    bool isp = true;
    char input;
    while ((input = _getch()))
    {
        switch (input)
        {
            case 'w': if (y > 0)y--; break;
            case 's': if (true)y++; break;
            case 'a': if (x > 0)x--; break;
            case 'd': if (true)x++; break;
        }
        // redraw
        system("cls");
        printf("Simple Game\n");
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                if (i == y && j == x)
                {
                    printf("o");
                }
                else
                {
                    if (j == px && i == py && isp)
                    {
                        printf("x");
                    }
                    printf(" ");
                }
            }
            printf("\n");
        }
        if (x == px && y == py && isp)
        {
            printf("you pick up the box");
            isp = false;
        }
    }
    return 0;
}




返回首页


Copyright (C) 2018-2024 huidong