[C++]Game模板-正面视角
前言
本来是想打一个小游戏的……
可是打到一半思路断了……
只打出了模板……先把模板拿出来放着
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模板-正面视角的更多相关文章
- 快速完成网页设计,10个顶尖响应式HTML5网页模板助你一臂之力
为了寻找一个优质的网页模板,网页设计师和开发者往往可能会花上大半天的时间.不过幸运的是,现在的网页设计师和开发人员已经开始共享HTML5,Bootstrap和CSS3中的免费网页模板资源.鉴于网站模板 ...
- Unity入门教程(上)
一.介绍 目的:通过尝试制作一款使用玩家角色把小球弹飞的简单小游戏,熟悉使用Unity进行游戏开发的基本流程. 软件环境:Unity 2017.3.0f3,Visual Studio 2013 二.创 ...
- ECCV 2018 | 旷视科技提出GridFace:通过学习局部单应变换实现人脸校正
全球计算机视觉三大顶会之一 ECCV 2018(European Conference on Computer Vision)即将于 9 月 8 -14 日在德国慕尼黑拉开帷幕,旷视科技有多篇论文被此 ...
- HTML5 + CSS3 实现地球绕太阳公转
使用的是正面视角,主要是用 HTML5 + CSS3 来实现,JS只是用来画图. test.html: <!DOCTYPE html> <html> <head> ...
- WPF Viewport3D 解决透视模式时窗体模糊
最近折腾Viewport3D玩,遇到了一些诡异的问题,研究一下略有心得,特此和大家分享~ 三维图形概述: https://msdn.microsoft.com/zh-cn/library/ms7474 ...
- thinkphp5杂谈--项目架构和模板搭建(view视角)
nginx网站配置 项目架构 项目文件夹 视图模板 一种出幺蛾子的访问办法 访问相关特色模块并渲染视图
- 6款程序员不得不爱的bootstrap模板
Bootstrap是基于jQuery框架开发的,它在jQuery框架的基础上进行了更为个性化和人性化的完善,形成一套自己独有的网站风格,并兼容大 部分jQuery插件.Bootstrap中包含了丰富的 ...
- 50款免费 PSD 名片设计模板源文件下载《下篇》
名片是陌生人之间建立联系的最便捷.最有效的工具.名片它可能是给你的客户留下正面的印象第一步,另一方面,名片是一个企业最重要和最符合成本效益的营销工具之一,尤其是对于刚刚起步的企业.这里收集了50款免费 ...
- 13. 星际争霸之php设计模式--正面模式
题记==============================================================================本php设计模式专辑来源于博客(jymo ...
随机推荐
- selenium滑块操作
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from ...
- HttpRunner学习6--使用parameters参数化
前言 在使用HttpRunner测试过程中,我们可能会遇到这种场景: 账号登录功能,需要输入用户名和密码,设计测试用例后有 N 种组合情况 如果测试组合比较少,比如只有2个,那我们直接在YAML脚本中 ...
- Python基础-day01-9
变量的命名 目标 标识符和关键字 变量的命名规则 0.1 标识符和关键字 1.1 标识符 标示符就是程序员定义的 变量名.函数名 名字 需要有 见名知义 的效果,见下图: 标示符可以由 字母.下划线 ...
- Redis两种持久化策略分析
Redis专题地址:https://www.cnblogs.com/hello-shf/category/1615909.html SpringBoot读源码系列:https://www.cnblog ...
- GIS面试小知识点
1.什么是地理信息系统?简述其基本功能 它是随着地理科学.计算机技术.遥感技术和信息科学的发展而产生的一门科学.就应用而言,是对空间数据进行 组织.管理.分析.显示 的系统.其实本质上它探讨的就是 ...
- IOS弓箭传说的插件开发
1.导出ipa进行解压后,定位到执行程序archero,ida加载后,发现很多都是sub_xxx开头的. 2.搜索资料后,原来Unity编写的程序,可以使用Il2CppDumper进行符号表还原. 下 ...
- 【原】MAC安装Flutter
系统环境要求 Flutter因为是新出的框架,所以对系统还是有一定的要求的. MacOS(64-bit) 磁盘空间:大于700M,如果算上Android Studio等编辑工具,尽量大于3G. 命令号 ...
- 如何判断一个变量是否为数组(isArray)
在我们平时的工作中经常会用到如何判断一个变量是否为数组.常用的方法很多,有用常用框架里面的,isArray.但是关于这个isArray的实现,各有不同. 常用的方法有如下几种 1.instanceof ...
- RocketMq在SparkStreaming中的应用总结
其实Rocketmq的给第三方的插件已经全了,如果大家有兴趣的话请移步https://github.com/apache/rocketmq-externals.本文主要是结合笔者已有的rmq在spar ...
- 在centos上安装mysql
本文依然是用的xftp上传gz文件,然后在xShell上操作的,如果没有安装使用这两个文件的请查阅之前的博客. 1.将下载好的文件用xftp上传到对应的位置. 2.解压文件:tar -zvxf m ...