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

📄 diamonds.h

📁 一个在linux下用c基于fb语言编写的五子棋游戏
💻 H
字号:
#ifndef		__DIAMONDS_H__#define		__DIAMONDS_H__#include    <linux/fb.h>#include    <sys/ioctl.h>#include    <sys/mman.h>#include	<sys/time.h>#include	<sys/types.h>#include    <unistd.h>#include    <fcntl.h>#include    <stdio.h>#include    <stdlib.h>#include    <string.h>#include	<assert.h>#include	<time.h>typedef		int		BOOL;#define		TRUE	1#define		FALSE	0#define BLOCKSIZE           18					#define ROWS                30			#define COLS                20			#define OriginXPos          20			#define OriginYPos          30		#define	x_offset			200#define	y_offset			200#define	LINE_WIDTH			5typedef struct TAG_GAME_TIMER{	unsigned long	curent_second;	unsigned long	curent_msecond;	unsigned long	old_second;	unsigned long	old_msecond;}GAME_TIMER;typedef struct TAG_BLOCK{	BOOL Flag_Is_Moveable;			    BOOL Flag_Is_Filled;				int  BlockStyle;			}BLOCK;static	GAME_TIMER  GameTimer;static 	BLOCK BlockArray[ROWS][COLS];static	unsigned char BG_COLOR[4]={255, 255, 255, 0};static	unsigned char LINE_COLOR[4]={0, 0, 0, 0};static	unsigned char ITEM_COLOR[4]={0, 0, 255, 0};void	Init_GameTimer();unsigned long	Game_Interval();void 	DrawBackground();void 	DrawBlock(int row,int column,int BlockStyle);void 	EraseBlock(int row,int column);void 	InitializeBlock(BLOCK BlockArray[ROWS][COLS]);BOOL 	GameOver(BLOCK BlockArray[ROWS][COLS]);void 	GenerateNewBlock(BLOCK BlockArray[ROWS][COLS]);BOOL 	NeedGenerateNewBlock(BLOCK Block[ROWS][COLS]);void 	KillFullLine(BLOCK BlockArray[ROWS][COLS]);BOOL 	CanBlockMoveDown(BLOCK Block[ROWS][COLS]);BOOL 	CanBlockMoveRight(BLOCK BlockArray[ROWS][COLS]);BOOL 	CanBlockMoveLeft(BLOCK BlockArray[ROWS][COLS]);void 	MoveBlockFromSrcToDes (BLOCK BlockArray[ROWS][COLS],int SrcRow, int SrcCol, int DesRow, int DesCol);void 	MoveBlockFromPreviewToGameArea(BLOCK BlockArray[ROWS][COLS]);void 	MoveBlockDown(BLOCK Block[ROWS][COLS]);void 	MoveBlockRight(BLOCK BlockArray[ROWS][COLS]);void 	MoveBlockLeft(BLOCK BlockArray[ROWS][COLS]);void 	Moveable2Stable(BLOCK Block[ROWS][COLS]);void 	RefreshWindow(BLOCK BlockArray[ROWS][COLS]);int 	JudgeBlockStyle(BLOCK BlockArray[ROWS][COLS]);void 	ChangeBlockStyleToGray(BLOCK BlockArray[ROWS][COLS]);void 	RotateStyleZero(BLOCK BlockArray[ROWS][COLS]);void 	RotateStyleOne(BLOCK  BlockArray[ROWS][COLS]);void 	RotateStyleTwo(BLOCK BlockArray[ROWS][COLS]);void 	RotateStyleThree(BLOCK BlockArray[ROWS][COLS]);void 	RotateStyleFour(BLOCK BlockArray[ROWS][COLS]);void 	RotateStyleSix(BLOCK BlockArray[ROWS][COLS]);void 	move_down();void	move_left();void	move_right();void	Item_rotate();int				openfb(char *dev_name);void 			get_fb_var_screeninfo(int fhandle, struct fb_var_screeninfo *fb_var);void			set_fb_var_screeninfo(int fhandle, struct fb_var_screeninfo *fb_var);void			get_fb_fix_screeninfo(int fhandle, struct fb_fix_screeninfo *fb_fix);unsigned char 	make8color(unsigned char r, unsigned char g, unsigned char b);unsigned short 	make15color(unsigned char r, unsigned char g, unsigned char b);unsigned short 	make16color(unsigned char r, unsigned char g, unsigned char b);void 			set8map(int fh, struct fb_cmap *map);void 			get8map(int fh, struct fb_cmap *map);void 			make332map(struct fb_cmap *map);void 			set332map(int fh);void			get_fb_var_var_bp(struct fb_var_screeninfo *fb_var);void			*convertRGB_fb(unsigned char *rgb, int bpp);void			*RGB_convert_fbuffer(unsigned char *rgb, int bpp);void			fb_mmap_buffer();void 			fb_draw_point(unsigned char *color, unsigned int pos_x, unsigned pos_y);void 			fb_draw_horizontal_line(unsigned char *color, unsigned int pos_x, unsigned pos_y, unsigned int lenght, unsigned int widht);void 			fb_draw_vertical_line(unsigned char *color, unsigned int pos_x, unsigned pos_y, unsigned int lenght, unsigned int widht);void			fb_draw_rect(unsigned char *color, unsigned int width, unsigned int height, unsigned int x, unsigned int y);void			fb_draw_chess(unsigned char *color, unsigned int x, unsigned int y);#endif

⌨️ 快捷键说明

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