[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 ...
随机推荐
- Linux之CentOS设置别名与屏蔽别名
一.环境 CentOS6.8 二.设置别名 ◆别名功能:让grep符合的关键字高亮 1.临时生效 [root@localhost ~]#alias grep="grep --color=au ...
- Test 1023 T1&T2
T1 popust (贪心 TimeLimit: 1000MS Memory Limit: 32768KB 米尔科饿了如熊,偶然发现当地一家餐馆.餐厅提供\(n\)种餐,有一个有趣的定价政策:每种 ...
- return之为什么能够终止函数,代码演练
''' return 有终止函数的作用,下面通过执行到return x 以后, 就结束了程序的下一步执行,所以就没有往下面走,所以终端上也就只能 看到打印结果100,看不到打印呢 ''' def se ...
- 自定义滚动条(Custom ScrollBar)
时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...
- 去除TextView设置lineSpacingExtra后,最后一行多出的空白
转载请标明出处:https://www.cnblogs.com/tangZH/p/11985745.html 有些手机中,给TextView设置lineSpacingExtra后会出现最后一行的文字也 ...
- [20191206]隐含参数_db_always_check_system_ts.txt
[20191206]隐含参数_db_always_check_system_ts.txt --//今年年头我做tab$删除恢复时,遇到的问题,就是遇到延迟块清除的问题.参考链接:http://blog ...
- 【译】ModSecurity
Preface 本篇译ModSecurity 主页的自身介绍. ModSecurity is an open source, cross-platform web application firewa ...
- WebRTC Android版本编译
本文简单介绍如何在Ubuntu18.04 上,编译WebRTC Android版本. 安装工具 需要用到depot_tools工具来下载webrtc源码. 安装 depot_tools git 命令获 ...
- Maven发布封装到中央仓库时候报错:no default secret key: No secret key
今天因为发布swagger-spring-boot-starter做一个问题的修复,然后碰到了下面这个问题,记录一下解决过程,帮助后续碰到类似问题的童鞋: *gpg: WARNING: "- ...
- 针对windows系统如何解决openssl_pkey_export(): cannot get key from parameter 1这个问题
为了解决这个问题我百度了很多方法,可是很多方法并没有效果. 方法一: 如果你安装的是phpstudy这个集成环境,那么 1.你就要去php拓展里面去打开php_opemssl中打开这个扩展. 2.去p ...