<> #ifndef _ANIMATION_LIB_H #define _ANIMATION_LIB_H /* animation_lib.h アニメーションサンプルウィジェット集のヘッダ */ /* GDKでアニメーションgifを読み込むサンプルウィジェット */ GtkWidget *my_pixbuf_animation(GtkWidget *window); /* ボールが動くアニメーションサンプルウィジェット */ GtkWidget *my_animation_ball(GtkWidget *window, gboolean trans); /* アニメーションgifが動くアニメーションサンプルウィジェット */ GtkWidget *my_animation_earth(GtkWidget *window, gboolean trans); /* キャラクターが動くアニメーションサンプルウィジェット */ GtkWidget *my_animation_chara(GtkWidget *window,GtkWidget *window2, gboolean trans); #endif <> static struct{ int up; int right; int down; int left; int w; int d; int s; int a; int f; int r; int ctrl; int shift; } sg_keys = {FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}; static struct{ int punch1; int punch2; int kick1; int kickk2; int guard1; int guard2; }hit={FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}; static struct{ /*しょうごステータス*/ int y_hp; int y_at; int y_def; int y_sp; }yama={6000, 500, 200, 3}; static struct{ /*おおともステータス*/ int o_hp; int o_at; int o_def; int o_sp; }otm={6000, 200, 200, 5}; static struct{ /*だいやステータス*/ int d_hp; int d_at; int d_def; int d_sp; }daiya={5000, 100, 100, 7}; static struct{ /*かなめステータス*/ int k_hp; int k_at; int k_def; int k_sp; }kaname={6000, 200, 400, 4}; static struct{ /*たくみステータス*/ int t_hp; int t_at; int t_def; int t_sp; }takumi={6000, 300, 200, 5}; static struct{ /*たさきステータス*/ int ta_hp; int ta_at; int ta_def; int ta_sp; }tasaki={6000, 300, 100, 5}; <> #ifndef _GDK_PIXBUF_LIB_H #define _GDK_PIXBUF_LIB_H /* gdk_pixbuf_lib.h gdk-pixbufであれこれするサンプルウィジェット集のヘッダ */ #include /* 画像を読み込むサンプルウィジェット */ GtkWidget *my_pixbuf_image(char *filename); /* 画像の拡大・縮小のサンプルウィジェット */ GtkWidget *my_pixbuf_scale(void); /* 画像の回転のサンプルウィジェット */ GtkWidget *my_pixbuf_rotate(void); /* 画像を半透明にするサンプルウィジェット */ GtkWidget *my_pixbuf_alpha(void); #endif # include //gtkの機能をまとめて使うためのインターフェイス typedef PangoFontDescription My_Font_Desc; // 初期化 // とにかく実行直後に呼んでおくこと void my_init(int argc, char *argv[]); // ウィンドウの作成 // 600x480, 枠の幅が15pixel GtkWidget * my_window_new(void); // ラベル付きボタンの作成 GtkWidget * my_button_new(char *label, My_Font_Desc *fontdescription); // イメージの作成 GtkWidget * my_image_new(char *path); // フォントの取り扱い My_Font_Desc *my_font_description(const gchar *fontname); // イベント処理 (コールバック) 関数 gint my_close_handler(GtkWidget *widget, gpointer gdata); void my_button_clicked_handler(GtkWidget *widget, gpointer data); <> # include //gtkの機能をまとめて使うためのインターフェイス typedef PangoFontDescription My_Font_Desc; // 初期化 // とにかく実行直後に呼んでおくこと void my_init(int argc, char *argv[]); // ウィンドウの作成 // 600x480, 枠の幅が15pixel GtkWidget * my_window_new(void); // ラベル付きボタンの作成 GtkWidget * my_button_new(char *label, My_Font_Desc *fontdescription); // イメージの作成 GtkWidget * my_image_new(char *path); // フォントの取り扱い My_Font_Desc *my_font_description(const gchar *fontname); // イベント処理 (コールバック) 関数 gint my_close_handler(GtkWidget *widget, gpointer gdata); void my_button_clicked_handler(GtkWidget *widget, gpointer data); <> static gint hp1(gpointer data)/*p2のHPが減少*/ { anime_pack *anime = (anime_pack *)data; gint p1_hp = anime->hp1, p2_hp = anime->hp2; static int i = 1; printf("p1_hp = %d\np2_hp = %d\n初期\n",p1_hp,p2_hp); printf("呼びだされたかテスト前 i = %d\n",i); if(i >0){ printf("呼びだされたかテスト i = %d\n",i); p2_hp -= anime->at1 - anime->def2; printf("p1_hp = %d\np2_hp = %d\n",p1_hp,p2_hp); anime->hp1 = p1_hp; anime->hp2 = p2_hp; } i++; if(p2_hp <= 0){gtk_main_quit();} return TRUE; } static gint hp2(gpointer data)/*p1のHPが減少*/ { anime_pack *anime = (anime_pack *)data; gint p1_hp = anime->hp1, p2_hp = anime->hp2; static int j = 1; printf("p1_hp = %d\np2_hp = %d\n初期\n",p1_hp,p2_hp); printf("呼びだされたかテスト前 j = %d\n",j); if(j >0){ printf("呼びだされたかテスト j = %d\n",j); p1_hp -= anime->at2 - anime->def1; printf("p1_hp = %d\np2_hp = %d\n",p1_hp,p2_hp); anime->hp1 = p1_hp; anime->hp2 = p2_hp; } j++; if(p1_hp <= 0){gtk_main_quit();} return TRUE; } <> #ifndef _STRUCT_H #define _STRUCT_H typedef struct {/*アニメーション用パーツ詰め合わせ*/ GtkWidget *drawing_area; gint timeout; GdkPixbuf *s_pixbuf, *s_pixbuf2; gint s_width, s_width2; gint s_height, s_height2; gint hp1, at1, def1, sp1, kj1; gint hp2, at2, def2, sp2, kj2; int sta,seni; gdouble x, x2, y, y2, dx, dx2, dy, dy2, t,t2; gint s_timeout; GdkPixbufAnimationIter *iter, *iter2; } anime_pack; extern anime_pack *anime; static struct{ int up; int right; int down; int left; int w; int d; int s; int a; int f; int r; int ctrl; int shift; int jump1; } sg_keys = {FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}; static struct{ int punch1; int punch2; int kick1; int kickk2; int guard1; int guard2; }hit={FALSE,FALSE,FALSE,FALSE,FALSE,FALSE}; static struct { /*しょうごステータス no1*/ int y_hp; int y_at; int y_def; int y_sp; }yama={6000, 500, 200, 3}; static struct { /*おおともステータス no2*/ int o_hp; int o_at; int o_def; int o_sp; }otm={6000, 200, 200, 5}; static struct { /*だいやステータス no3*/ int d_hp; int d_at; int d_def; int d_sp; }daiya={5000, 250, 100, 6}; #endif