前言

本来是想打一个小游戏的……

可是打到一半思路断了……

只打出了模板……先把模板拿出来放着

Code

//head
#include <iostream>
#include <cstdio>
#include <cstring>
#include <windows.h>
#include <conio.h>
using namespace std;
//*head

//define
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define Row_down KEY_DOWN(VK_MBUTTON)
#define Left_down KEY_DOWN(VK_LBUTTON)
#define fup(a,b) for(int i = (a); i < (b); i++)
#define sup(a,b) for(int j = (a); j < (b); j++)
//*define

//struct
struct player{
    int x;
    int y;
    int money;
}pl;
struct jump{
    int time;
    int hel;
    void helfresh()
    {

    }
}jup;
//*struct

//char
char map[16][31] = {
"                              ",
"                              ",
"  ...                    ...  ",
"           .......            ",
"                              ",
"   ...                  ...   ",
"                              ",
"       ..          ..         ",
" ...       ..   ..        ... ",
"           .     .            ",
"         ..  ...  ..          ",
"                              ",
"      ..................      ",
"                              ",
"                              "
};
char index[30][30];
//*char

//int
//*int

//bool
bool run_ch = true;
//*bool

//function
void gotoxy(int y, int x)
{
    COORD pos = {x,y};
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hOut, pos);
}

void init()
{
    pl.x = 0;
    pl.y = 0;
    int i, j = 30;
    for(i = 0; i <= 15; i++)
    {
        gotoxy(i, j);
        cout<<"*";
    }
    i = 15;
    for(j = 0; j <= 30; j++)
    {
        gotoxy(i, j);
        cout<<"*";
    }
    for(i = 0; i < 15; i ++)
    {
        for(j = 0; j < 30; j++)
        {
            gotoxy(i, j);
            cout<<map[i][j];
        }
    }
}

void shop()
{

}

bool arv(int a, int b)
{
    if(map[a][b]=='*'||map[a][b]=='.'||map[a][b]=='|'||a<0||b<0||a>=15||b>=30)
        return false;
    return true;
}

char cnt_char;int cnt = 0;
void run_read(char ch)
{
    if(ch == 'a')
    {
        int nx = pl.x;
        int ny = pl.y - 1;
        if(!arv(nx, ny))
            return;

        gotoxy(pl.x, pl.y);
        cout<<" ";
        pl.x = nx;
        pl.y = ny;
        gotoxy(pl.x, pl.y);
        cout<<"A";
    }

    if(ch == 'd')
    {
        int nx = pl.x;
        int ny = pl.y + 1;
        if(!arv(nx, ny))
            return;

        gotoxy(pl.x, pl.y);
        cout<<" ";
        pl.x = nx;
        pl.y = ny;
        gotoxy(pl.x, pl.y);
        cout<<"A";
    }
    if(ch == 's')
    {
        int nx = pl.x + 1;
        int ny = pl.y;
        if(!arv(nx, ny))
            return;

        gotoxy(pl.x, pl.y);
        cout<<" ";
        pl.x = nx;
        pl.y = ny;
        gotoxy(pl.x, pl.y);
        cout<<"A";
    }
    if(ch == 'k')
    {
        if(jup.hel > 0 && map[pl.x + 1][pl.y] != '.' && pl.x != 14)
        {
            jup.hel--;
            goto next2;
        }
        if(map[pl.x + 1][pl.y] != '.' && pl.x != 14)
            return;

        next2:
        jup.time = 3;
        if(cnt_char == 'd')
            run_read('d');
        if(cnt_char == 'a')
            run_read('a');
    }
    if(ch == 'w')
    {
        int nx = pl.x - 1;
        int ny = pl.y;
        if(!arv(nx, ny))
            return;

        gotoxy(pl.x, pl.y);
        cout<<" ";
        pl.x = nx;
        pl.y = ny;
        gotoxy(pl.x, pl.y);
        cout<<"A";
    }
    if(ch == 'n')
    {
        jup.time = 0;
        cnt_char = ' ';
        cnt = 0;
    }
    if(ch == 'f')
    {
        shop();
    }
}

void run()
{
    char ch;
    while(run_ch)
    {
        if(map[pl.x + 1][pl.y] == '.' || pl.x == 14)
        {
            jup.hel = 0;
            jup.helfresh();
        }
        if(!kbhit())
        {
            cnt++;
            if(cnt > 3)
                cnt_char = ' ', cnt = 0, ch = ' ';
            goto run_next;
        }

        ch = getch();
        if(ch == 'w')
            goto run_next;
        run_read(ch);

        run_next:

        gotoxy(16,0);
        cout<<pl.x<<"  "<<pl.y<"   ";
        if(ch == 'k')
            ch = cnt_char;
        else
            cnt_char = ch;

        if(jup.time == 0)
        {
            run_read('s');
            run_read(cnt_char);
            Sleep(100);
        }
        else
        {
            run_read('w');
            run_read(cnt_char);
            jup.time--;
            Sleep(100);
        }
        Sleep(20);
    }
}
//*function

//main
int main()
{
    init();
    run();
    return 0;
}
//*main

效果图:

(图片有可能烂掉,因为我的图片放在博客园,我会尽快换到聚合图床)

后面我会将代码贴上注释,这样你萌就可以改了(其实自己也是看得懂的)。

不得不说我的效果做的垃圾的一批,可是我不会其他开发啊,不知道在哪学,只能自己慢慢找一些开发实例看一些代码。

[C++]Game模板-正面视角的更多相关文章

  1. 快速完成网页设计,10个顶尖响应式HTML5网页模板助你一臂之力

    为了寻找一个优质的网页模板,网页设计师和开发者往往可能会花上大半天的时间.不过幸运的是,现在的网页设计师和开发人员已经开始共享HTML5,Bootstrap和CSS3中的免费网页模板资源.鉴于网站模板 ...

  2. Unity入门教程(上)

    一.介绍 目的:通过尝试制作一款使用玩家角色把小球弹飞的简单小游戏,熟悉使用Unity进行游戏开发的基本流程. 软件环境:Unity 2017.3.0f3,Visual Studio 2013 二.创 ...

  3. ECCV 2018 | 旷视科技提出GridFace:通过学习局部单应变换实现人脸校正

    全球计算机视觉三大顶会之一 ECCV 2018(European Conference on Computer Vision)即将于 9 月 8 -14 日在德国慕尼黑拉开帷幕,旷视科技有多篇论文被此 ...

  4. HTML5 + CSS3 实现地球绕太阳公转

    使用的是正面视角,主要是用 HTML5 + CSS3 来实现,JS只是用来画图. test.html: <!DOCTYPE html> <html> <head> ...

  5. WPF Viewport3D 解决透视模式时窗体模糊

    最近折腾Viewport3D玩,遇到了一些诡异的问题,研究一下略有心得,特此和大家分享~ 三维图形概述: https://msdn.microsoft.com/zh-cn/library/ms7474 ...

  6. thinkphp5杂谈--项目架构和模板搭建(view视角)

    nginx网站配置 项目架构 项目文件夹 视图模板 一种出幺蛾子的访问办法 访问相关特色模块并渲染视图

  7. 6款程序员不得不爱的bootstrap模板

    Bootstrap是基于jQuery框架开发的,它在jQuery框架的基础上进行了更为个性化和人性化的完善,形成一套自己独有的网站风格,并兼容大 部分jQuery插件.Bootstrap中包含了丰富的 ...

  8. 50款免费 PSD 名片设计模板源文件下载《下篇》

    名片是陌生人之间建立联系的最便捷.最有效的工具.名片它可能是给你的客户留下正面的印象第一步,另一方面,名片是一个企业最重要和最符合成本效益的营销工具之一,尤其是对于刚刚起步的企业.这里收集了50款免费 ...

  9. 13. 星际争霸之php设计模式--正面模式

    题记==============================================================================本php设计模式专辑来源于博客(jymo ...

随机推荐

  1. Jquery使用ajax与Flask后端进行数据交互

    最近做项目碰到一个坑,jquery使用ajax向flask传输数据的时候,在后端采用request.data无论如何都获取不到数据,代码如下: 前端: <script> function ...

  2. selenium滑块操作

    from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from ...

  3. Rabbit安装(单机及集群,阿里云)

    Rabbit安装(单机及集群,阿里云) 前言 虽然我并不是部署人员,但是自己私人测试环境的各类东东还是得自己安装的. 尤其在规模不大的公司,基本安装部署工作都是后端的份内之事. 那么最令人痛苦的,莫过 ...

  4. 什么是RMI?

    RMI(Remote Method Invocation,远程方法调用)是用Java在JDK1.2中实现的,它大大增强了Java开发分布式应用的能力.Java作为一种风靡一时的网络开发语言,其巨大的威 ...

  5. round分析

    Python 所谓的奇进偶弃,因为浮点数的表示在计算机中并不准确,用的时候可能要注意一下. 测试如下 print() 由运行得出结论: 当小数点左边为偶数:小数点右边X<6,舍 当小数点左边为偶 ...

  6. SpringCloud分布式配置中心

    一.什么是配置中心 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud c ...

  7. C# MySql Transaction Async

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. 守护线程,需要通过调用线程方法:setDaemon(boolean on)来进行设置

    package seday08.thread;/*** @author xingsir * 守护线程又称为后台线程,默认创建出来的线程都是普通线程, 守护线程需要通过调用线程方法:setDaemon( ...

  9. SpringCloud-服务注册与实现-Eureka创建服务注册中心(附源码下载)

    场景 SpringCloud学习之运行第一个Eureka程序: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/90611451 S ...

  10. CentOS 磁盘在线扩容

    场景介绍: 操作系统Centos7.x 系统有一块vdisk,容量为20G,共分为3个区(swap和boot分区为标准分区xfs文件系统,根分区为LVM分区,xfs文件系统) 业务需求:在VM系统不关 ...