// the hildon-game-wrapper context
HgwContext *hgw_context = NULL;
+// void rmz_debug (char *msg){
+// FILE *pFile;
+//
+// pFile = fopen ("/home/rzingg/mancala.debug", "a");
+// if (pFile) {
+// fprintf (pFile, "rmz_debug: %s \n", msg);
+// fclose (pFile);
+// }
+// }
+
void sdl_clean_up(){
int i = 0;
}
int play() {
-
+// rmz_debug("play step 1");
SDL_Rect board_rect, title_rect, exit_rect;
SDL_Color font_color;
SDL_Event event;
SDL_Color font_color_exit;
+// rmz_debug("play step 2");
char tile_path[STRING_MAX], stone_path[STRING_MAX];
char icon_path[STRING_MAX], title_path[STRING_MAX];
char home_path[STRING_MAX], board_path[STRING_MAX];
int i, redraw_board, highlight, old_highlight, active;
int current_move, ai_last_move, human_last_move, state;
+// rmz_debug("play step 3");
/* Set up the game board and game variables. */
gameInit(aiBoard, humanBoard);
current_move = 0;
ai_last_move = human_last_move = -99;
+// rmz_debug("play step 4");
/* initialize our libraries */
//if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO) < 0) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
return 1;
}
+// rmz_debug("play step 5");
if (TTF_Init() < 0) {
fprintf(stderr, "Unable to initialize SDL_ttf: %s\n",
SDL_GetError());
return 1;
}
+// rmz_debug("play step 6");
//Initialize SDL_mixer
-
if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
+ // if( Mix_OpenAudio(22050, (Uint16)AUDIO_U8, 2, 256 ) == -1 )
{
+// rmz_debug(g_strdup_printf("Unable to initialize Mix_OpenAudio: %s\n",SDL_GetError()));
fprintf(stderr, "Unable to initialize Mix_OpenAudio: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
}
-
+// rmz_debug("play step 7");
/* Load our images... PNGs now, maybe XPMs later */
sprintf(tile_path, "%s/tile.png", RES_PATH);
if ((tile = LoadRes(tile_path)) == NULL) {
return 1;
}
+// rmz_debug("play step 8");
for (i=0; i<=STONE_MAX; i++) {
if (sprintf(stone_path, "%s/stone%02d.png", RES_PATH, i) == 0)
fprintf(stderr, "Problems assembling path.\n");
}
}
+// rmz_debug("play step 9");
/* Load our font(s) */
if (sprintf(title_path, "%s/luxisr.ttf", FONT_PATH) == 0)
fprintf(stderr, "Problems assembling path.\n");
return 1;
}
+// rmz_debug("play step 10");
if (sprintf(board_path, "%s/luxisr.ttf", FONT_PATH) == 0)
fprintf(stderr, "Problems assembling path.\n");
if (!(board_font = TTF_OpenFont(board_path, BOARD_SIZE))) {
return 1;
}
+// rmz_debug("play step 11");
if (sprintf(home_path, "%s/luxisr.ttf", FONT_PATH) == 0)
fprintf(stderr, "Problems assembling path.\n");
if (!(home_font = TTF_OpenFont(home_path, HOME_SIZE))) {
return 1;
}
+// rmz_debug("play step 12");
/* Load sound effects */
sprintf(pick_path, "%s/pick.wav", RES_PATH);
if ((pick = Mix_LoadWAV(pick_path)) == NULL) {
return 1;
}
+// rmz_debug("play step 13");
/* store the font's color */
font_color.r = 255;
font_color.b = 255;
board_rect.w = 0;
board_rect.h = 0;
+// rmz_debug("play step 14");
/* set window properties and create it */
SDL_WM_SetCaption("Mancala", "Mancala");
if (sprintf(icon_path, "%s/icon.png", RES_PATH) == 0)
sdl_clean_up();
return 1;
}
+ SDL_ShowCursor(SDL_DISABLE);
-
+// rmz_debug("play step 15");
/* define the font color fot the exit text */
font_color_exit.r = 255;
font_color_exit.r = 255;
font_color_exit.r = 255;
-
+// rmz_debug("play step 16");
if (!(exit_text = TTF_RenderText_Blended(home_font, "EXIT",
font_color_exit))) {
fprintf(stderr, "SDL_ttf: %s\n", TTF_GetError());
highlight = 0;
active = 0;
+// rmz_debug("play step 17");
/* GAME LOOP */
while (state != GAME_WON) {
redraw_board = 0;
}
+ hgw_msg_compat_receive(hgw_context, 0);
+
}
SDL_Delay(DELAY_AI);
+
sdl_clean_up();
return 0;
int main(int argc, char **argv) {
-
- fprintf(stderr, "mancala main loop\n");
+
// #if HGW_FUNC
hgw_context = hgw_context_compat_init(argc, argv);
if (!hgw_context) {
fprintf(stderr, "Cannot init hildon-games-startup!\n");
return 0;
}
+
hgw_compat_set_cb_exit(hgw_context, exit_callback);
hgw_compat_set_cb_quit(hgw_context, quit_callback);
- hgw_compat_set_cb_flush(hgw_context, flush_callback);
+ hgw_compat_set_cb_flush(hgw_context, flush_callback);
if(!hgw_context_compat_check(hgw_context)) return 0;
-
+
/* hildon-games-wrapper part */
hgw_msg_compat_receive(hgw_context, 0);
usleep(100);
// #endif
+
// Main game
- play();
+
+ if ( play() > 0 ){
+// rmz_debug("play > 1");
+ }
// #if HGW_FUNC
hgw_context_compat_destroy_deinit(hgw_context);