一个小游戏(可以拿来画像素画)(C++编写)

#include<iostream>
#include<conio.h>
#include<windows.h>
#include<ctime> 
#ifndef FONTCOLOR_H_
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0) 
#endif
using namespace std;typedef unsigned long long ull;
void red_print(std::string out); void green_print(std::string out);
void black_print(std::string out);void yellow_print(std::string out);
void blue_print(std::string out);void purple_print(std::string out);
void cyan_print(std::string out);void dark_blue_print(std::string out);			
void white_print(std::string out);
int randNext(int left, int right){
static unsigned int seed = 0;seed++;
srand((unsigned) time(NULL) + seed * seed);
return rand() % (right - left + 1) + left;}
void COLOR_PRINT(int color){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);cout<<"  "; 
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);}
void SB(int color){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);cout<<"SB"; 
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);}
short map[32][32];unsigned short x=1,y=1;char moves;int color=1;
void does(){for(int i = 1;i<31;i++)for(int j = 1;j<31;j++)map[i][j]=666;
while(moves=getch()){system("cls");
if(moves=='w'&&(x-1)!=0&&map[x-1][y]==666)x--;
if(moves=='s'&&(x+1)!=31&&map[x+1][y]==666)x++;
if(moves=='a'&&(y-1)!=0&&map[x][y-1]==666)y--;
if(moves=='d'&&(y+1)!=31&&map[x][y+1]==666)y++;
if(moves=='i')if(map[x-1][y]!=0) map[x-1][y]=666;
if(moves=='k')if(map[x+1][y]!=0) map[x+1][y]=666;
if(moves=='j')if(map[x][y-1]!=0) map[x][y-1]=666;
if(moves=='l')if(map[x][y+1]!=0) map[x][y+1]=666;
if(moves=='t')if(map[x-1][y]!=0) map[x-1][y]=color;
if(moves=='g')if(map[x+1][y]!=0) map[x+1][y]=color;
if(moves=='f')if(map[x][y-1]!=0) map[x][y-1]=color;
if(moves=='h')if(map[x][y+1]!=0) map[x][y+1]=color;
if(moves=='c') cin>>color;
for(int i = 0;i<32;i++){for(int j = 0;j<32;j++){
if(x==i&&y==j){SB(240);continue;}if(map[i][j]==666)COLOR_PRINT(127);
if(map[i][j]==0) COLOR_PRINT(111);if(map[i][j]==1) COLOR_PRINT(320);
if(map[i][j]==2) COLOR_PRINT(480);if(map[i][j]==3) COLOR_PRINT(943);
if(map[i][j]==4) COLOR_PRINT(944);if(map[i][j]==5) COLOR_PRINT(927);
if(map[i][j]==6) COLOR_PRINT(879);if(map[i][j]==7) COLOR_PRINT(848);
if(map[i][j]==8) COLOR_PRINT(384);if(map[i][j]==9) COLOR_PRINT(512);
}cout<<endl;}cout<<"x:"<<x<<"   "<<"y:"<<y<<endl;
COLOR_PRINT(320);cout<<"1 ";COLOR_PRINT(480);cout<<"2 ";COLOR_PRINT(943);cout<<"3 ";
COLOR_PRINT(944);cout<<"4 ";COLOR_PRINT(927);cout<<"5 ";COLOR_PRINT(879);cout<<"6 ";
COLOR_PRINT(848);cout<<"7 ";COLOR_PRINT(384);cout<<"8 ";COLOR_PRINT(512);cout<<"9 ";
cout<<endl<<color; }}int main(){does();}

WASD:控制上下移动

TFGH:放置方块

IJKL:消除方块

C:输入颜色,列表在下方

原创!!!

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值