⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.h

📁 本人自己编写的Linux下的象棋程序
💻 H
字号:
#ifndef _FUNCTION_H#define _FUNCTION_H#include <stdio.h>#include <stdlib.h>#include <math.h>#include <SDL/SDL.h>#include "SDL_image.h"#define QIPAN  "//home//chess//qipan//mutou//qipan.bmp" #define END  "//home//chess//pic//end.bmp"#define START1  "//home//chess//pic//start1.bmp"#define START2 "//home//chess//pic//start2.bmp"#define WINDOW "//home//chess//pic//window.bmp"#define B_ZU "//home//chess//qizi//mutou//black_b.bmp" #define B_PAO "//home//chess//qizi//mutou//black_p.bmp" #define B_CAR "//home//chess//qizi//mutou//black_j.bmp" #define B_HOR "//home//chess//qizi//mutou//black_m.bmp" #define B_ELF "//home//chess//qizi//mutou//black_x.bmp" #define B_NURSE "//home//chess//qizi//mutou//black_s.bmp" #define B_MAS "//home//chess//qizi//mutou//black_k.bmp"#define R_BING  "//home//chess//qizi//mutou//red_b.bmp" #define R_PAO  "//home//chess//qizi//mutou//red_p.bmp" #define R_CAR "//home//chess//qizi//mutou//red_j.bmp" #define R_HOR "//home//chess//qizi//mutou//red_m.bmp" #define R_ELF "//home//chess//qizi//mutou//red_x.bmp" #define R_NURSE "//home//chess//qizi//mutou//red_s.bmp" #define R_MAS "//home//chess//qizi//mutou//red_k.bmp" #define RL_CAR 1#define RR_CAR 2#define RL_HOR 3#define RR_HOR 4#define RL_ELF 5#define RR_ELF 6   #define RR_NURSE 7#define RL_NURSE 8#define RC_MAS 9#define RL_PAO 10#define RR_PAO 11#define R_BING1 12#define R_BING2 13#define R_BING3 14#define R_BING4 15#define R_BING5 16#define BL_CAR 17#define BR_CAR 18#define BL_HOR 19#define BR_HOR 20#define BL_ELF 21#define BR_ELF 22  #define BR_NURSE 23#define BL_NURSE 24#define BC_MAS 25#define BL_PAO 26#define BR_PAO 27#define B_ZU1 28#define B_ZU2 29#define B_ZU3 30#define B_ZU4 31#define B_ZU5 32struct QIZI{    SDL_Surface *image;};int qipan[10][9];struct QIZI qizi[33];//加载图片并返回图片指针SDL_Surface* load_image( char *filename ); //将source图片显示在destination图片的(x,y)位置void display_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip );//初始化棋盘,把相应棋子放在相应位置上void init_qipan();//显示棋子int display_qizi(int x, int y, struct QIZI *qizi, SDL_Surface *screen, SDL_Surface *qipan_screen);//显示盘面void display_qipan(SDL_Surface* qipan_screen, SDL_Surface *screen);//显示重新开局的盘面void start_again(SDL_Surface *qipan_screen, SDL_Surface *screen);//显示终局盘面void display_end(SDL_Surface *screen);//显示棋盘右侧面板void display_window(SDL_Surface *screen);//显示开始按钮void display_start(SDL_Surface *screen);//将指定的一颗棋子移动到目标位置int move(int x0,int y0, int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);//检测是否可以移动int try_move(int x0,int y0, int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);//棋子的运动规则int car_rules(int x0, int y0, int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);int bing_zu_rules(int x0, int y0 ,int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen) ;int pao_rules(int x0, int y0, int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);int horse_rules(int x0, int y0 ,int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);int elf_rules(int x0, int y0 ,int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);int nurse_rules(int x0, int y0 ,int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);int master_rules(int x0, int y0 ,int x, int y, SDL_Surface *screen, SDL_Surface *qipan_screen);//棋子的切换void change_to(int x0,int y0, int x, int y, 	SDL_Surface *screen, SDL_Surface *qipan_screen);	//棋子被选中的标志void flash_qizi(int x0, int y0, SDL_Surface *screen);//获取指定图片的指定位置的象素Uint32 getpixel(SDL_Surface *surface, int x, int y);//在指定位置显示一个象素void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -