Mercurial > hg > old > magoroku_racing
diff gFont.c @ 96:0b65ca27f113
compile on Mac OS X 2
author | Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 02 Jun 2011 14:56:11 +0900 |
parents | 8edae89a3877 |
children |
line wrap: on
line diff
--- a/gFont.c Thu May 26 18:13:40 2011 +0900 +++ b/gFont.c Thu Jun 02 14:56:11 2011 +0900 @@ -8,8 +8,8 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> -//#include "libps2.h" -//#include "ps2util.h" +#include "libps2.h" +#include "ps2util.h" #include "gSprite.h" #define DEFOBJ 120 @@ -20,88 +20,92 @@ #define CHAR_H_SIZE 34 static SpriteTable sptable[DEFOBJ]; -//static ps2utilSprite sp[DEFOBJ*2]; // 表示スプライト用スタック +static ps2utilSprite sp[DEFOBJ*2]; // 表示スプライト用スタック static unsigned int sp_counter; static bool flag_spriteInited = false; // スプライトロードフラグ -//static TEXTURE *font_tex; +static TEXTURE *font_tex; static void gFont_Init_Png(char *texname) { - /* if (!(font_tex = read_png_file(texname))) { - fprintf(stderr, - "cannot creat texture - gFont_Init_Png().\n"); - fflush(stderr); - exit(EXIT_FAILURE); - }*/ + if (!(font_tex = read_png_file(texname))) { + fprintf(stderr, + "cannot creat texture - gFont_Init_Png().\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } - /* if (ps2util_tex_Set(font_tex) == -1) { - fprintf(stderr, - "cannot set texture - gFont_Init_Png().\n"); - fflush(stderr); - exit(EXIT_FAILURE); - }*/ + if (ps2util_tex_Set(font_tex) == -1) { + fprintf(stderr, + "cannot set texture - gFont_Init_Png().\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } } static void gFont_Create() { - int i; + int i; + for (i=0; i<DEFOBJ; i++) { + if (ps2util_sprite_Create(&sp[i], font_tex) == -1) { + fprintf(stderr, + "cannot create sprite - gFont_Create()\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } + ps2util_sprite_Unuse_alpha(&sp[i]); + } - for (i=0; i<DEFOBJ; i++) { - /* if (ps2util_sprite_Create(&sp[i], font_tex) == -1) { - fprintf(stderr, - "cannot create sprite - gFont_Create()\n"); - fflush(stderr); - exit(EXIT_FAILURE); - } - ps2util_sprite_Unuse_alpha(&sp[i]);*/ - } - flag_spriteInited = true; + + flag_spriteInited = true; } static void gFont_DefSprite(int number, int x, int y, int w, int h) { - sptable[number].tx = x; - sptable[number].ty = y; - sptable[number].tw = w; - sptable[number].th = h; + sptable[number].tx = x; + sptable[number].ty = y; + sptable[number].tw = w; + sptable[number].th = h; } void gFont_Init() { - int i, j; - int number = 0; + int i, j; + int number = 0; - gFont_Init_Png("img/font.png"); - gFont_Create(); // スプライト生成 + gFont_Init_Png("img/font.png"); + gFont_Create(); // スプライト生成 - for (i=0; i<7; i++) { - for (j=0; j<15; j++) { - gFont_DefSprite(number, j*17, i*34, 17, 34); - number++; - } + for (i=0; i<7; i++) { + for (j=0; j<15; j++) { + gFont_DefSprite(number, j*17, i*34, 17, 34); + number++; } + } } static void gFont_PutSprite(int number, int x, int y) { - // ps2utilSprite *p = &sp[sp_counter]; + ps2utilSprite *p = &sp[sp_counter]; - /* ps2util_sprite_Set_basicAttribute( + // ushortってなんですか?:miya + /* + ps2util_sprite_Set_basicAttribute( p, (ushort)x, (ushort)y, (ushort)sptable[number].tw*1.5, (ushort)sptable[number].th*1.5, (ushort)sptable[number].tx, (ushort)sptable[number].ty, (ushort)sptable[number].tw, (ushort)sptable[number].th, - SPRITE_PRIO_FOREGROUND);*/ + SPRITE_PRIO_FOREGROUND); + */ - // ps2util_sprite_Request(p); + ps2util_sprite_Request(p); sp_counter++; } @@ -112,7 +116,7 @@ int i; for (i=0; i<DEFOBJ; i++) { - // sprite_disappear(&sp[i].attribute); + sprite_disappear(&sp[i].attribute); } sp_counter = 0; } @@ -137,14 +141,14 @@ void gFont_SetString(char *str, int x, int y) { - int number; + int number; - while (*str != '\0') { - number = get_number_char(*str); - gFont_PutSprite(number, x, y); - str++; - x += (int)CHAR_W_SIZE*1.5; - } + while (*str != '\0') { + number = get_number_char(*str); + gFont_PutSprite(number, x, y); + str++; + x += (int)CHAR_W_SIZE*1.5; + } } /* @@ -153,10 +157,10 @@ void gFont_SetStringInt(int num, int x, int y) { - char bufp[256]; + char bufp[256]; - snprintf(bufp, 256, "%d", num); - gFont_SetString(bufp, x, y); + snprintf(bufp, 256, "%d", num); + gFont_SetString(bufp, x, y); } void