赞
踩
我的作品:
代码:
- #include <bits/stdc++.h>
- #include <windows.h>
- #include <ctime>
- #include "conio.h"
-
- using namespace std;
-
- #define leftspace 3
- #define upspace 3
-
- #define up 119
- #define down 115
- #define right 100
- #define left 97
-
- #define UP 72
- #define DOWN 80
- #define RIGHT 77
- #define LEFT 75
-
- #define esc 27
- #define enter 13
- #define tab 9
- #define space 32
-
- //主要函数
- void game();
- void gaming(); //"开始游戏"
- void introduce(); //"游戏介绍"
- void setgame(); //"游戏设置"
- //其它函数
- void start(); //开始游戏动画
- void go(int x,int y); //改变光标坐标
- void color(int a); //设置颜色
- void savefile(); //保存数据
- void readfile(); //读取数据
- void full_screen(); //全屏窗口
- void hide_cursor(); //隐藏光标
-
- int Map[45][45];
- int cc=247;
- int dc=15;
- int x,y;
-
- int main(){
- COORD coord;coord.X=100,coord.Y=100;
- SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),coord);
- go(5,5);color(13);printf("本游戏可能加载较慢,请耐心等待......(游戏本身无延迟)");
- go(5,6);printf("(。··)ノ");
- system("mode con cols=150 lines=200");//设置控制台大小90 28
- for(int i=0;i<45;i++)
- for(int j=0;j<45;j++)
- Map[i][j]=dc;//初始化Map(并不是不会用memset,而是我的memset有问题qaq)
- CONSOLE_CURSOR_INFO cursor_info={1,0};
- SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);//隐藏光标
- color(dc);
- start();
- game();//进入游戏
- return 0;
- }
-
- void hide_cursor(){
- CONSOLE_CURSOR_INFO cursor_info={1,0};
- SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);//隐藏光标
- }
-
- void go(int x,int y) //光标移动函数,X表示横坐标,Y表示纵坐标。
- {
- COORD coord; //使用头文件自带的坐标结构
- coord.X=(x+leftspace)*2; //这里将int类型值传给short,不过程序中涉及的坐标值均不会超过short范围
- coord.Y=y+upspace;
- HANDLE a=GetStdHandle(STD_OUTPUT_HANDLE); //获得标准输出句柄
- SetConsoleCursorPosition(a,coord); //以标准输出的句柄为参数设置控制台光标坐标
- }
-
- void full_screen(){
- HWND hwnd = GetForegroundWindow();
- int cx = GetSystemMetrics(SM_CXSCREEN); /* 屏幕宽度 像素 */
- int cy = GetSystemMetrics(SM_CYSCREEN); /* 屏幕高度 像素 */
- LONG l_WinStyle = GetWindowLong(hwnd,GWL_STYLE); /* 获取窗口信息 */
- /* 设置窗口信息 最大化 取消标题栏及边框 */
- SetWindowLong(hwnd,GWL_STYLE,(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
- }
-
- void game()
- {
- system("cls");
- system("color 0F");
- color(15);
- system("cls");
- color(15);
- go(13,1);printf("像素game");
- go(12,16);printf("WS/上下控制选择");
- go(12,9);printf(" 游戏介绍 ");
- go(12,13);printf(" 游戏设置 ");
- color(127);
- go(12,4);printf("■■■■■■");
- go(12,5);printf("■");color(124)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。