File: sprite.h

package info (click to toggle)
xsystem35 2.17.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 8,096 kB
  • sloc: ansic: 38,159; java: 4,085; xml: 249; sh: 134; python: 15; makefile: 12
file content (135 lines) | stat: -rw-r--r-- 3,359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

#ifndef __SPRITE_H__
#define __SPRITE_H__

#include "portab.h"
#include <SDL_rect.h>

#define DEFAULT_UPDATE nt_sp_draw


#define SPRITEMAX 20
#define SPNO_WALL    0  // 壁紙
#define SPNO_SCENERY 1  // 背景
#define SPNO_TACHI_L 2  // 立ち絵左
#define SPNO_TACHI_M 3  // 立ち絵中央
#define SPNO_TACHI_R 4  // 立ち絵右
#define SPNO_MSGBG   5  // 文字下地
#define SPNO_MSGFRAME_BG 6 // メッセージウィンド枠
#define SPNO_MSGFRAME_FG 7 // メッセージ文字描画キャンバス
#define SPNO_FACE 11        // 人物顔CG
#define SPNO_MSG_KEYANIM 12 // メッセージキー入力アニメーション
#define SPNO_MSG_ICON_MUTE 13 // メッセージウィンドアイコン

#define CGMAX 65536
// 0-9999: reserve for Link CG
// 2051: メッセージウィンド枠CG
#define CGNO_MSGFRAME_LCG 2051
// 4017: メッセージウィンドで声をmuteにするCG
#define CGNO_MSGFRAME_NOVICE_LCG 4017
// 4018: メッセージウィンドのアイコンにマウスが重なったときのCG
#define CGNO_MSGFRAME_ICONREV_LCG 4018
// 4034: キー入力を促すアニメーションCG
#define CGNO_MSGHAK_LCG 4034

// 10000: メッセージウィンドでのキー待ちアニメ その1
#define CGNO_MSGHAK_1 10000
// 10001: メッセージウィンドでのキー待ちアニメ その2
#define CGNO_MSGHAK_2 10001
// 10002: 文字下地CG
#define CGNO_MSGFR_BG 10002


// CG_XX で作るCGの種類
enum cgtype {
	CG_NOTUSED = 0,
	CG_LINKED  = 1,
	CG_SET     = 2,
	CG_REVERSE = 3,
	CG_STRETCH = 4
};

// cgに関する情報
struct _cginfo {
	enum cgtype type;  // CGの種類, 0: 未使用, 1:リンクされている, ...
	int no;            // CGの番号
	struct SDL_Surface *sf;
	int refcnt;        // 参照カウンタ。0になったら開放してもよい。
};
typedef struct _cginfo cginfo_t;


enum spritetype {
	SPRITE_NORMAL = 0,
	SPRITE_ANIME  = 5,
	SPRITE_MSG    = 100,
	SPRITE_WP,
	SPRITE_NONE   = -1
};

struct _sprite {
	enum spritetype type;
	
	int no;
	
	int width;
	int height;
	
	cginfo_t *curcg;
	cginfo_t *cg1, *cg2, *cg3;
	
	bool show;
	
	int blendrate;
	
	SDL_Point loc;
	
	SDL_Point cur;

	void (* update)(struct _sprite *sp, SDL_Rect *updatearea);
	
	union {
		struct {
			int interval;
			int startttime;
			int npat;
			unsigned int tick;
		} anime;
		
		struct {
			struct SDL_Surface *canvas;
			SDL_Point dspcur;
		} msg;
	} u;
};

typedef struct _sprite sprite_t;


/* in nt_sprite.c */
sprite_t *nt_sp_new(int no, int cg1, int cg2, int cg3, int type);
sprite_t *nt_sp_msg_new(int no, int x, int y, int width, int height);
void nt_sp_free(sprite_t *sp);
void nt_sp_set_show(sprite_t *sp, bool show);
// void nt_sp_set_cg(sprite_t *sp, int no);
void nt_sp_set_loc(sprite_t *sp, int x, int y);

/* in nt_sprite_update.c */
void nt_sp_update_clipped();
void nt_sp_update_all(bool syncscreen);
void nt_sp_updateme(sprite_t *sp);
void nt_sp_updateme_part(sprite_t *sp, int x, int y, int w, int h);
void nt_sp_add_updatelist(sprite_t *sp);
void nt_sp_remove_updatelist(sprite_t *sp);
void nt_sp_draw_wall(sprite_t *sp, SDL_Rect *r);
void nt_sp_clear_updatelist(void);

/* in nt_sprite_draw.c */
void nt_sp_draw(sprite_t *sp, SDL_Rect *r);
void nt_sp_draw_scg(sprite_t *sp, SDL_Rect *r);

/* in nt_sprite_eupdate.c */
void nt_sp_eupdate(int type, int time, int cancel);


#endif /* __SPRITE_H__ */