rendered paste body// -----------------------------// iGamer.c// --> Main File for iGamer// -----------------------------// Created by Daniel Shaw// -----------------------------// VERSION: Alpha// -----------------------------// --> Load libraries and podzilla for references#include <stdio.h>#include <string.h>#include <stdlib.h>// --> Podzilla data//static PzEvent *ev;//static PzEvent *rev;//static PzEvent *logo_touch;TWidget *logo_pic();//static PzEvent *title_action;// = ttk_new_window();//static PzEvent *menu_main_b;// --> FilesFILE *game_data;FILE *data_cfg;// --> Widget data (Map, Events)TWidget *game;TWidget *event;//TWidget *logo_widg;TWidget *title;TWidget *menu_data;// Max limits ( MAP )int max_x;int max_y;int max;// --> Logostatic char logo[104];static char logo_path[52];// --> Surfacesstatic ttk_surface image;static ttk_surface character;static ttk_surface user;static ttk_surface srf;static ttk_surface screen_image;static ttk_surface event_image; // Event imagestatic ttk_surface logod; // Logostatic ttk_surface wskind; // Window skinstatic ttk_surface logo_tmp; // Temporary logostatic ttk_surface title_image_data;// --> Data for use and visualsstatic char tileset[80]; // The tileset in usestatic char generation[1]; // 1, 2, 3, 4, mini(m), photo(p), nano(n), video(v)// --> Title Datastatic int title_position, start_game_now = 0;static char title_image[50], title_image_path[50];// --> Game variable (playing).static int in_game = 0;// --> Starting positionsstatic char map_id[3];// --> Current Positions and directionstatic int player_x = 0, player_y = 0, facing = 3; // --> Facing position (1 - UP, 2 - RIGHT, 3 - DOWN, 4 - LEFT)// --> Buttonstatic int event_button = 0;// --> Loaded layer tiles from filestatic int get[7][55][5];// --> Event datastatic char ne_name[18][50], ne_char[18][50];static int ne_flowa[18][50];static int ne_flowb[18][50];static int ne_trigger[18][50];static int ne_x[18][50];static int ne_y[18][50];static int ne_ncmds[18][50];static int ne_cmdids[18][50];char ne_page_0[15][15][15][15]; // Event / Event Number / Type / Parameter// --> Menustatic int menu_position = 120;// --> Charactersstatic char char_path[75];static char char_a[25];// --> Total eventsstatic int total_events = 0;// --> Game namestatic char game_name[20];// --> Window skinstatic char wskin[50];static char wskin_path[75];//void update_screen() // --> Refresh the map and sprites!// { // game->dirty++;// }//--------------////#include "XFunc.c"//#include "Menu.c"//#include "Map.c"//#include "Event.c"//--------------////int load_tileset() // --> Load the tileset (Obviously)!// { // Place tileset in full path // char tileset_path [104]; // sprintf(tileset_path, "game_data/Visuals/Tiles/%s", tileset); // Load image (Tileset) //image = ttk_load_image (tileset_path); // Determine if the tileset is valid! // if (image == NULL) // { // return 2; // } // else // { // return 1; // } //}//void draw_data(TWidget *wid, ttk_surface srf) // --> Draw the map, sprites, etc!// { // if (image == NULL) { // if (load_tileset() == 2) // { // printf("Warning: Unable to load tiles!; This may have been caused by insufficient memory...."); // game->dirty++; // } // } // else // { // draw_map_l1_tiles(srf); // --> Show Layer 1 Tiles // output_event(srf); // --> Draw events // character_draw(facing, srf); // --> Draw the main character // }//draw_map_l2_tiles(srf); // --> Show Layer 2 Tiles//draw_map_l3_tiles(srf); // --> Show Layer 3 Tiles // if (event_button == 1) // { // do_event(srf, wskind); // event_button = 0; // } }int movement(int dir) // --> Movement for the main character! { switch(dir) // Direction to face { case 1: player_y--; facing = 1; break; case 2: player_x++; facing = 2; break; case 3: player_y++; facing = 3; break; case 4: player_x--; facing = 4; break; } update_screen(); return 0; }//int event_data (PzEvent *e) // --> Input data receieved!// {// // int ret = TTK_EV_CLICK; // switch (e->type) {ttk_free_window(mainwindow); // case PZ_EVENT_BUTTON_DOWN: // If the button is pressed down // switch (e->arg) { // case PZ_BUTTON_MENU: // Up // if (can_move(1)) // movement(1); // break; // // case PZ_BUTTON_NEXT: // Right // if (can_move(2)) // movement(2); // break; // // case PZ_BUTTON_PLAY: // Down // if (can_move(3)) // movement(3); /// break;/// // // / case PZ_BUTTON_PREVIOUS: // Left/// / if (can_move(4))/// / movement(4);// / break;///// // case PZ_BUTTON_ACTION: // Action // if (touching(facing) == 0) // { // event_button = 1; // } // update_screen(); // break;//// case PZ_BUTTON_HOLD: // Hold - Exit// menu_data = pz_add_widget (startw, menu_draw_main, menu_event_main);// //pz_close_window(e->wid->win);startw = pz_new_window (game_name, PZ_WINDOW_FULLSCREEN); // || Setup new window ||// logo_widg = ttk_add_widget (startw, show_logo);//, logo_opt); // || Logo ||// return ttk_close_window (startw); // || End when ready ||// break;// }//// default:// ret = TTK_EV_UNUSED;// break;//// }// return ret;// }void load_map(ttk_surface srf) {// load_map_data(map_id); // || Load Map Data Tiles || // load_wind_decoration(srf); // --> Window Skin //load_tileset();// load_map_events(); // output_event(srf); }void start_game(ttk_surface srf) // --> Start game from title screen { //ttk_remove_widget (startw, title); //game = ttk_add_widget (startw, draw_data);//, event_data); // || Add Map and Sprites Widget || // in_game = 1; //load_map(srf); // || Load Map Data || }void title_dat(TWidget *title_data, ttk_surface srf) // --> Title graphics { // if (in_game == 0)//// {// if (start_game_now == 1)// {// start_game(srf);// start_game_now = 0;// }/// // sprintf(title_image_path, "game_data/Visuals/Title/%s", title_image);// title_image_data = ttk_load_image (title_image_path);// ttk_blit_image(title_image_data, srf, 0, 0);// /// sprintf(wskin_path, "game_data/Visuals/Window/%s", wskin);// wskind = ttk_load_image (wskin_path); // Load image // Show decoration// ttk_blit_image_ex (wskind, 0, 103, 128, 25, srf, 0, 94);// ttk_blit_image_ex (wskind, 0, 103, 40, 25, srf, 128, 94); // ttk_text(srf, mainfont, title_position, 109, ttk_makecol(BLACK), "-----"); // ttk_text(srf, mainfont, 10, 100, ttk_makecol(BLACK), "Begin");// ttk_text(srf, mainfontt, 68, 100, ttk_makecol(BLACK), "Load");// ttk_text(srf, mainfont, 128, 100, ttk_makecol(BLACK), "Exit!");//// } }//int title_ev(PzEvent *title_action) // --> Action information for title// {// int ret = TTK_EV_CLICK; //if (in_game == 1) // { // return ret;// }// switch (title_action->type)// {// case PZ_EVENT_BUTTON_DOWN: // If the button is pressed down// switch (title_action->arg)// {// case PZ_BUTTON_NEXT: // Right// switch (title_position)// {// case 10:// title_position = 68;// break;// case 68:// title_position = 128;// break;// case 128:// title_position = 10;// break;// }// title->dirty++;// break; // case PZ_BUTTON_PREVIOUS: // Left// switch (title_position)// {// case 10:// title_position = 128;// break;// case 68:// title_position = 10;// break;// case 128:// title_position = 68;// break;// }// title->dirty++;// break; // case PZ_BUTTON_ACTION: // Action// switch (title_position)// {// case 10: // New// ttk_remove_widget(startw, logo_widg);// start_game_now = 1;// title->dirty++;// break;// // case 68: // Load// pz_message("Error: Sorry load is not yet implemented");// break;// // case 128: // Exit// pz_close_window(startw);// break;// }// break;// }// // default:// ret = TTK_EV_UNUSED;// break;// }// return ret;// }void remove_logo() // --> End logo and start the game { //ttk_remove_widget(startw, logo_widg); //title = ttk_add_widget (startw, title_dat);//, title_ev); // || Title || }//int logo_opt (PzEvent *logo_touch) // --> Input data receieved!// {// int ret = TTK_EV_CLICK;// switch (logo_touch->type)// {// case PZ_EVENT_BUTTON_DOWN: // If the button is pressed down// switch (logo_touch->arg)// {// case PZ_BUTTON_ACTION: // Action// remove_logo();// break;// }// // default:// ret = TTK_EV_UNUSED;// break;// }// return ret;// }//void show_logo(TWidget *logo_pic, ttk_surface logod)//, ttk_surface logo_tmp) // --> Show startup logo// { // Combine path and logo// printf("hi..");// sprintf(logo_path, "game_data/Visuals/Logos/%s", logo); // logo_tmp = ttk_load_image (logo_path);// ttk_create_timer(2400, remove_logo);// ttk_blit_image(logo_tmp, logod, 40, 50);// } void check_files() // --> Check for the neccessary files! { // Configuration file data_cfg = fopen("igamer.cfg", "r"); // Failure to open file if (data_cfg == NULL) { printf("Warning: Unable to load config file, Using nano generation!"); sprintf(generation, "n"); } // Add generation fscanf(data_cfg, "%s", generation); // -- \\ fclose(data_cfg); // -------------------------------------------|||-------------------------------------------- // // Game Configuration file game_data = fopen("game_data/gdata.igame", "r"); // Failure to open file if (game_data == NULL) { printf ("Error: Unable to locate 'gdata.igame'"); } // Add Gamename fscanf(game_data, "%s", game_name); // Add start map id and positions fscanf(game_data, "%s", &map_id); fscanf(game_data, "%d", &player_x); fscanf(game_data, "%d", &player_y); fscanf(game_data, "%d", &facing); fscanf(game_data, "%s", &char_a); fscanf(game_data, "%s", &logo); fscanf(game_data, "%s", &title_image); fscanf(game_data, "%s", &wskin); // -- \\ fclose(game_data); }//void load_fonts() // --> Load default fonts// { // ttk_font *mainfont; // *mainfont = ttk_get_font ("/fonts/Espy Sans", 327263);// }void end_data() // --> Destroy data from cache { //ttk_free_image(img); //ttk_free_window(startw); }int main(int argc, char **argv) // --> Start the engine { // = ttk_init(); TWindow *startw; //load_fonts(); printf("hi.."); check_files(); //sprintf(char_path, "game_data/Visuals/Players/%s", char_a); //character = ttk_load_image (char_path); printf("hi.."); ttk_run(); printf("hi.."); printf("hi.."); // end_data(); //ttk_quit(); return ttk_run(); }//return ttk_close_window (startw);