Newer
Older
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Uint8 type; //事件类型
SDL_ActiveEvent active; //窗口焦点、输入焦点及鼠标焦点的失去和得到事件
SDL_KeyboardEvent key; //键盘事件,键盘按下和释放
SDL_MouseMotionEvent motion; //鼠标移动事件
SDL_MouseButtonEvent button; //鼠标按键事件
SDL_QuitEvent quit; //退出事件
SDL_SysWMEvent syswm; //平台相关的系统事件
}SDL_Event;*/
//typedef enum
//{
//SDL_NOEVENT = 0, /* 未使用 */
//SDL_ACTIVEEVENT, /* 应用程序失去焦点或得到焦点*/
//SDL_KEYDOWN, /* 按下某键 */
//SDL_KEYUP, /* 松开某键 */
//SDL_MOUSEMOTION, /* 鼠标移动 */
//SDL_MOUSEBUTTONDOWN, /* 鼠标键按下 */
//SDL_MOUSEBUTTONUP, /* 鼠标键松开 */
//SDL_QUIT, /*离开 */
//SDL_SYSWMEVENT, /* 系统事件 */
//SDL_EVENT_RESERVEDA, /* 保留 */
//SDL_EVENT_RESERVEDB, /* 保留 */
//SDL_VIDEORESIZE, /* 用户改变视频模式 */
//SDL_VIDEOEXPOSE, /* 屏幕重画 */
//SDL_EVENT_RESERVED2, /* 保留*/
//SDL_EVENT_RESERVED3, /* 保留 */
//SDL_EVENT_RESERVED4, /* 保留 */
//SDL_EVENT_RESERVED5, /* 保留 */
//SDL_EVENT_RESERVED6, /* 保留*/
//SDL_EVENT_RESERVED7, /* 保留 */
//SDL_USEREVENT = 24, /* 用户自定义事件 */
//SDL_NUMEVENTS = 32
//}SDL_EventType;
//typedef struct SDL_MouseButtonEvent
//{
// Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
// Uint8 which; /* The mouse device index */
// Uint8 button; /* 鼠标按键,左、右、中三个键*/
// Uint8 state; /* SDL_PRESSED按下 or SDL_RELEASED松开 */
// Uint16 x, y; /* 鼠标按下时的坐标 */
//}SDL_MouseButtonEvent;
//typedef struct SDL_MouseMotionEvent
//{
// Uint8 type; /* SDL_MOUSEMOTION */
// Uint8 which; /* The mouse device index */
// Uint8 state; /* 鼠标状态 */
// Uint16 x, y; /* 鼠标当前坐标 */
// Sint16 xrel; /* 鼠标在x方向的位移 */
// Sint16 yrel; /* 鼠标在y方向的位移*/
//} SDL_MouseMotionEvent;
typedef enum {LEFT,RIGHT}BUTTONPOS; //枚举按钮在精灵图中的编号
typedef enum {un,deux,OTHER}BUTTONFLAG; //枚举按钮
#ifndef FONT_H
#define FONT_H
typedef int BOOL;
#define TRUE 1
#define FALSE 0
//表面声明
SDL_Surface *gpBackground; //背景表面
SDL_Surface *gpScreen; //显示表面
SDL_Surface *gpMessage[2]; //文字表面
//事件声明
extern SDL_Event myEvent;
// 字体声明
extern TTF_Font *font;
const SDL_Color RGB_Black;
const SDL_Color RGB_Red;
const SDL_Color RGB_Green;
const SDL_Color RGB_Blue;
const SDL_Color RGB_Cyan;
const SDL_Color RGB_Magenta;
const SDL_Color RGB_Yellow;
const SDL_Color RGB_White;
const SDL_Color RGB_Gray;
const SDL_Color RGB_Grey;
const SDL_Color RGB_Maroon ;
const SDL_Color RGB_Darkgreen;
const SDL_Color RGB_Navy;
const SDL_Color RGB_Teal;
const SDL_Color RGB_Purple;
const SDL_Color RGB_Olive;
const SDL_Color RGB_Noname;
void changeButton(BUTTONPOS aPos,int aNo,SDL_Rect *aDst);
BOOL init(char* aCaption,char * aIcon);
SDL_Surface *loadImage( char * filename );
void applySurface( int x, int y, SDL_Surface *source, SDL_Surface *destination );
SDL_Surface *TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg);