int main() { //struct timeval lastTime; WINDOW *win = initscr(); keypad(win, true); curs_set(0); raw(); noecho(); timeout(gSpeed); start_color(); // gGame.width = getmaxx(win); gGame.height = getmaxy(win); level_load(0); //gettimeofday(&gGame.lastTime, NULL); while ((gGame.input = getch()) != 'q') { level_draw(); /*gettimeofday(&lastTime, NULL); gGame.elapsedTime = 1000 * (gGame.lastTime.tv_sec - lastTime.tv_sec) + (gGame.lastTime.tv_usec - lastTime.tv_usec); gGame.lastTime = lastTime;*/ } level_unload(true); keypad(win, false); curs_set(1); echo(); noraw(); delwin(win); endwin(); return 0; }
bool level_start() { if (!level_load()) { return false; } scene.unload = &level_unload; scene.update = &level_update; scene.draw = &level_draw; scene.showLetterbox = true; functionDir = 1; functionGap = 1.0/64.0; //menor o valor, maior a precisão functionPlot = false; cacheCount = 0; plotTempo = 0; weightTempo = 0; zeroHeight = zeroHeightPrev = 0; zeroHeightTempo = 0; setBase(3,8); //temp textboxPos = 1; showTextbox(); input.text[0] = '\0'; input.captureFinish = false; input.caretPos = 0; input.selectionStart = -1; return true; }
void PlayerHealth(int delta) { gPlayer.health += delta; if (gPlayer.health <= 0) { // reset_game(); level_load(0); } }
void main() { video_mode = 9; max_entities = 30000; terrain_chunk = 0; level_load(NULL); random_seed(0); mouse_mode = 4; vec_set(camera.x, vector(-1101, -97, 800)); vec_set(camera.pan, vector(4,-29,0)); // Terrain BMAP* bmapHeightMap = generate_random_heightmap_noise(256, 256, 64); BMAP* bmapColorMap = heightmap_to_colormap(bmapHeightMap); ENTITY* entTerrain = terrain_from_heightmap(vector(0,0,-300), bmapHeightMap, 65, 65, 30, 0.4); ent_setskin(entTerrain, bmapColorMap, 2); entTerrain.material = mat_terrain_multi_texture; // Roads proc_city_create_skins(); List *points = roadnetwork_from_rectlangle(entTerrain.min_x + 100, entTerrain.min_y + 100, entTerrain.max_x - 50, entTerrain.max_y - 50, 200, 6); //List *points = roadnetwork_from_voronoi(30, entTerrain.min_x + 100, entTerrain.min_y + 100, entTerrain.max_x - 50, entTerrain.max_y - 50); List *intersections = roadnetwork_calculate(points); roadnetwork_join_near_intersections(intersections, 100); // Delete intersections which are too near to each other List *roadNetwork = roadnetwork_build(intersections, 300, true); // Parcels create_parcels(roadNetwork); }
int main(int argc, char **argl) { while( !ready() ) wait(1.0); draw_pos.x = 25.0; draw_pos.y = 150.0; window_size_set(1280, 720); level_load( "td1\\arena.wmb" ); vec_set( &camera->x, vector(876, 516, -79) ); vec_set( &camera->pan, vector(112, 5, 0) ); object_sky_create( "td1\\envy+6.tga", 1 ); render_rain_new(); on_1 = create_crt; on_2 = create_grain; on_3 = create_sepia; on_4 = create_vignette; on_5 = create_grayscale; on_6 = rain_on; on_7 = rain_off; while(!key_esc) { draw_text(sstr, 10, 10, COLOR_PEACH); draw_text(sstr_mode, draw_pos.x, draw_pos.y, COLOR_BLEU_DE_FRANCE); camera->pan += 0.25 * time_step; wait(1.0); } sys_exit(0); }
void creditsReset () { sky_active = 0; g_bCrFirstLotti = false; gui_hide(); creditsFinished = 0; currentRow = 0; resetPpSwirl(); camera->clip_far = 30000; vec_set(&g_vecCreditsCamShake, nullvector); snd_stopall(4); g_fhCreditsSong = 0; resetPpSwirl (); reset(g_txtCreditsSpace, SHOW); reset(creditsHead1, SHOW); reset(creditsHead2, SHOW); reset(creditsBody1, SHOW); reset(creditsBody2, SHOW); g_bCreditsAllExplode = false; on_space = NULL; level_load(NULL); }
void level_load_ext(STRING* _lvl) { if (_lvl != NULL) { if (panLoad == NULL) { on_level = on_level_event; on_level_load = on_level_loaded_event; panLoad = pan_create("", 100); vec_set(panLoad.blue, vector(8,8,8)); pan_setdigits(panLoad, 0, 10, 10, "Loading...", font_create("Arial#30b"), 1, vDummy2); pan_setcolor(panLoad, 1, 1, vector(255,255,255)); panLoadBar = pan_create("", 101); vec_set(panLoadBar.blue, vector(0,0,255)); } panLoad.size_x = screen_size.x; panLoad.size_y = screen_size.y; panLoadBar.size_x = 0; panLoadBar.size_y = 40; panLoadBar.pos_x = 0; panLoadBar.pos_y = screen_size.y - 100; set(panLoad, LIGHT | SHOW); set(panLoadBar, LIGHT | SHOW); wait(1); level_load(_lvl); } }
static void set_load_levels(void) { static const char *roman[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", "XXIII", "XXIV", "XXV" }; struct set *s = SET_GET(sets, curr); int regular = 1, bonus = 1; int i; for (i = 0; i < s->count; i++) { struct level *l = &level_v[i]; level_load(s->level_name_v[i], l); l->number = i; if (l->is_bonus) SAFECPY(l->name, roman[bonus++]); else sprintf(l->name, "%02d", regular++); l->is_locked = (i > 0); l->is_completed = 0; if (i > 0) level_v[i - 1].next = l; } }
int main(void) { window_open(); glutils_init(); Settings settings; settings.first_run = true; Level level; bool leave = false; while(!leave) { if(!menu_run(&settings)) { leave = true; break; } theme_load(settings.theme); level_load(settings.level_set, settings.level, &level); level_run(&level, &settings); } /* * unload the last used theme * if we loaded several themes one after another, * they have been automatically freed by theme_load */ theme_unload(); return EXIT_SUCCESS; }
static gboolean load_cb(Gui *gui){ fprintf(stdout, "Load called\n"); fflush(stdout); //open up the file entry dialog GtkWidget *dialog; char *filename; dialog = gtk_file_chooser_dialog_new("Level Chooser", GTK_WINDOW(gui->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); //if the user selects a file, get the filename if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT){ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); fprintf(stdout, "%s\n", filename); fflush(stdout); } //call level load using the filename level_load(gui->space, filename); //destroy the file chooser gtk_widget_destroy(dialog); return TRUE; }
void main () { video_mode = 8; fps_max = 60; wait(2); bmap_zbuffer ( bmap_createblack(2048,2048,32) ); mouse_mode = 4; mouse_map = bmap_create ( "arrow_yellow.pcx" ); vec_fill ( &screen_color, 128 ); level_load ( "" ); camera->pan = -40; camera->tilt = -30; evnCameraLocate (); vec_set ( &colCameraBG, vector(150,150,150) ); camera->bg = pixel_for_vec ( &colCameraBG, 100, 8888 ); ENTITY *ent = ent_create ( CUBE_MDL, nullvector, NULL ); // Create style for the menues // CMMEMBER *myMenuStyle = cmstyle_create ( FONT *font, COLOR *colText, COLOR *colBack, COLOR *colOver ) FONT *fntTTF = font_create("Arial#16"); CMStyle *myMenuStyle01 = cmstyle_create ( fntTTF, vector(40,40,40), vector(250,250,250), vector(210,210,210) ); FONT *fntBitmap = font_create("ackfont.pcx"); CMStyle *myMenuStyle02 = cmstyle_create ( fntBitmap, vector(170,170,255), vector(30,20,0), vector(0,0,185) ); // Create a compact menu panel // PANEL *cmenu_create ( char *chrMember, var pos_x, var pos_y, var size_x, var layer, var flags, CMStyle *style ) PANEL *myMenu01 = cmenu_create ( "menu name.submenu=txtMain", 110, 20, 200, 1, SHOW, myMenuStyle01 ); PANEL *myMenu02 = cmenu_create ( "debug & statics.submenu=txtCMDebug", 500, 20, 200, 1, SHOW, myMenuStyle01 ); cmenu_modify ( myMenu02, 120, myMenuStyle02 ); bmpSky = bmap_create ( "sky_fu_256+6.tga" ); while ( !key_esc && !nExit ) { str_setchr ( strString, 1, random(32)+32 ); wait(1); } bmap_remove ( bmpSky ); bmpSky = NULL; bmap_remove ( mouse_map ); mouse_map = NULL; cmenu_remove ( myMenu01 ); sys_free ( myMenuStyle01 ); font_remove ( fntTTF ); cmenu_remove ( myMenu02 ); sys_free ( myMenuStyle02 ); font_remove ( fntBitmap ); sys_exit ( NULL ); }
void main() { level_load(""); // Load an empty level camera.x = -100 ; // Back the Camera up a bit so we can see the Model // Create the Earth Model, at Position 0,0,0 , and run the Action update_Position ent_create("../earth.mdl", NULL, update_Position) ; }
void main() { level_load("") ; // Load empty level // Position the camera at x = -100, y = 0, z = 22 ( Back and Up a bit ) camera.x = -100 ; camera.z = 22 ; // Create the Earth Model , Position XYZ, Action update_Earth ent_create( "earth.mdl", vector( 0, 10, 40 ), update_Earth ) ; }
world_t world_open(const char *dir) { struct _world *w; char *path; w = calloc(1, sizeof(*w)); if ( NULL == w ) goto out; w->path = strdup(dir); if ( NULL == w->path ) goto out_free; if ( asprintf(&path, "%s/level.dat", dir) < 0 ) goto out_free; w->level_dat = level_load(path); free(path); if ( NULL == w->level_dat ) { fprintf(stderr, "world: open: level load failed\n"); goto out_free; } /* Open regular world */ if ( asprintf(&path, "%s/region", dir) < 0 ) goto out_free_level; w->overworld = dim_open(path); free(path); if ( NULL == w->overworld ) { fprintf(stderr, "world: open: overworld open failed\n"); goto out_free_level; } /* Open nether */ if ( asprintf(&path, "%s/DIM-1/region", dir) < 0 ) goto out_free; w->nether = dim_open(path); free(path); if ( NULL == w->nether ) goto out_free_level; goto out; out_free_level: level_put(w->level_dat); out_free: dim_close(w->overworld); dim_close(w->nether); free(w->path); free(w); w = NULL; out: return w; }
void backToMenu() { on_space = NULL; on_mouse_left = NULL; endIngameGUI(); stopSnow(); wait(1); //error("loading menu"); pssm_run(0); wait(1); level_load("menuLevel2.wmb"); startMenu(); }
void main() { level_load("") ; // Load empty level // Position the camera at x = -100 ( Back a bit ) camera.x = -100 ; // Create the Earth Model , Position XYZ, Action update_Earth ent_create( "earth.mdl", vector( 0, 45, 30 ), update_Earth ) ; // Create Cube Model and wrap Collision Zone to Model ent_create( "cube.mdl", vector(0,0,0), c_setminmax ) ; }
void PortalCollision(unsigned int x, unsigned int y) { for (portal = 0; portal < gLevel.portalsCount; ++portal) { if (gLevel.portals[portal].x == x && gLevel.portals[portal].y == y) { unsigned int destination = gLevel.portals[portal].destination; level_load(gLevel.portals[portal].level); gPlayer.x = gLevel.portals[destination].x; gPlayer.y = gLevel.portals[destination].y; // TODO: Without setting (input = 0), input gets processed twice. // I kind of like that, but it may need to be changed later. level_draw(); return; } } }
/* ==================================================================== Load all levels from file and add them to the list. ==================================================================== */ int levels_load( char *fname, List *levels, int *version, int *update ) { /* load all levels from levelset 'fname' and put them to list 'levels' */ FILE *file; Level *level; /* get file handle */ if ( ( file = levelset_open( fname, "rb" ) ) == 0 ) return 0; /* check version */ levelset_get_version( file, version, update ); /* read levels */ while( ( level = level_load( file ) ) != 0 ) list_add( levels, level ); fclose( file ); return 1; }
function game_init() { level_load("") ; // Load an empty level wait(1); //camera.x = -40 ; //camera.z = 160 ; level_state = 1 ; warn_level = 0 ; //tex_share = 1 ; // map entities share their textures sky_color.red = 10 ; //remove these 3 lines if you use a sky or skycube sky_color.green = 10 ; sky_color.blue = 10 ; // return; } // end game_init()
levelset *levelset_load(char *filename) { FILE *fp; char buf[FILENAME_MAX+10]; char fname[FILENAME_MAX]; levelset *set; fname[sizeof(fname)-1] = '\0'; strncpy(fname, LEVELDIR, sizeof(fname)); strncpy(fname + strlen(fname), filename, sizeof(fname)-strlen(fname)); strncpy(fname + strlen(fname), ".set", sizeof(fname)-strlen(fname)); if (fname[sizeof(fname)-1] != '\0') { fatal("File name length overflow"); } fp = fopen(fname, "r"); if (!fp) { fatal("Unable to read level set file"); } set = levelset_new(); set->title = NULL; set->name = filename; while (fgets(buf, sizeof(buf), fp)) { if (buf[strlen(buf)-1] != '\n') { fatal("Line length overflow in level set file"); } buf[strcspn(buf, "\r\n")] = '\0'; if (ishdr(buf, "Title: ")) { if (set->title) { fatal("Multiple titles in level set file"); } set->title = dupstr(buf + 7); } else if (ishdr(buf, "Level: ")) { levelset_nlevels(set, set->nlevels+1); set->levels[set->nlevels-1] = level_load(buf + 7); } else { fatal("Unrecognised keyword in level set file"); } } fclose(fp); return set; }
void main() { level_load("") ; // Load empty level // Position the camera at x = -100 ( Back a bit ) camera.x = -100 ; // Create the Earth Model , Position XYZ, Action update_Earth ent_create( "earth.mdl", vector( 0, 50, 35 ), update_Earth ) ; int i = 0 ; for ( i = 45; i >= -45; i = i - 15 ) { wait ( 100 ) ; ent_create( "cube.mdl", vector(0,i,0), c_setminmax ) ; } }
function main() { video_mode = 7; sound_vol = 100; level_load("models\\position.mdl"); vec_set(screen_color, vector(10, 10, 10)); camera.arc = 50; camera.x = -450; fps_max = 60; wait(3); reset(curtain, SHOW); }
void creditsStart () { redness = 100; wait(1); //reset(camera, SHOW); //wait(1); skychange(0.1); setHdr(LVL_CREDITS_HDR_STRENGTH, LVL_CREDITS_HDR_THRESHOLD, LVL_CREDITS_HDR_EXPOSURE); detail_size = 64; level_load("credits.wmb"); creditsFog(); creditsText(); camera.arc = 65; //wait(1); set(camera, SHOW); credits_populate(); while (key_a && key_c && key_k) wait(1); while (!creditsFinished) { resetPpSwirl (); redness = clamp(redness - g_rednessInc * time_step, 0, 100); if (key_a && key_c && key_k) break; wait(1); } g_bCreditsAllExplode = true; }
void main() { la_assetInit(); level_load(NULL); wait(1); // Wait until the video device is ready // A stone stone = la_ent_create("stones.mdl", vector(1024, 0, -120), NULL); // A marine marine = la_ent_create("marine.mdl", vector(1024, 0, 40), rotate); // Ten boxes full of evil madness int i; for(i=0; i<10; i++) { la_ent_create("box.mdl", vector(2048, -820 + (i * 180), -35), NULL); } }
function main() { video_mode = 7; sound_vol = 100; level_load("models\\position.mdl"); vec_set(screen_color, vector(10, 10, 10)); playInit(); playSetup(); playRun(); camera.arc = 60; camera.x = -700; fps_max = 60; wait(3); }
void main() { // initialize game video_set(1024, 768, 32, 2); warn_level = 2; tex_share = 1; mouse_mode = 4; mouse_range = 100000; shadow_stencil = 2; random_seed(0); level_load("eggz.wmb"); // load the level wait(2); // wait two ticks for the level to finish loading // position the camera camera.x = 800; camera.y = 0; camera.z = 500; camera.pan = 180; camera.tilt = -20 ; // MAIN GAME LOOP // while(1) // start the loop. { wait(1); } }
void main() { level_load("") ; // Load empty level // place the camera at x = -100, y = 0, z = 22 ( Back and Up a bit ) vec_set( camera.x,vector(-100, 0, 22) ) ; // Create the "earth.mdl", Position XYZ, Action update_Earth ent_create("earth.mdl", vector(pos_X, pos_Y, pos_Z), update_Earth); while (1) // While the game is running... { if ( key_space ) { create_Projectile(); // Call the Fuction to create new bullet entity wait(60); // Fire repeat rate } wait(1); } }
int main_deathmatch() { SDL_Event e; SDL_ShowCursor(SDL_DISABLE); entity_initialize_list(1024); tank_initialize_list(15); g_current_level = level_load("leveloneconfig"); render_set_background(g_current_level->background->image); g_music = audio_load_music("sounds/music/backgroundmusic.wav"); g_sound = audio_load_sound("sounds/digital/digital.wav"); if(g_music->file.music != NULL) { slog("Playing Music"); //audio_play_music(g_music->file.music); } else slog("Could not load music file"); player = player_spawn("Player", PLAYER); v2d_set(player->tank->tracks->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2); v2d_set(player->tank->turret->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2); g_now = SDL_GetTicks(); ui_initialize_deathmatch(rtn_renderer()); do { //calculate deltatime g_last = g_now; g_now = SDL_GetTicks(); g_deltatime = g_now - g_last; render_update(1); render_clear(); entity_all_think(); entity_all_update(); player_move(player); while(SDL_PollEvent(&e)) { if(e.type == SDL_KEYDOWN) { if(e.type == SDL_QUIT) SDL_Quit(); if(e.key.keysym.sym == SDLK_w) player->keysHeld.W = 1; if(e.key.keysym.sym == SDLK_s) player->keysHeld.S = 1; if(e.key.keysym.sym == SDLK_a) player->keysHeld.A = 1; if(e.key.keysym.sym == SDLK_d) player->keysHeld.D = 1; if(e.key.keysym.sym == SDLK_e) { tank_weapon_change(player->tank); slog("Current weapon: %s", player->tank->currentweapon->name); } if(e.key.keysym.sym == SDLK_p) { audio_play_sound(g_sound->file.sound); } if(e.key.keysym.sym == SDLK_f) { Entity *sonar; sonar = sonar_new(sonar = entity_new(SONAR, NULL), 3.0, player->tank); } if(e.key.keysym.sym == SDLK_g) { tank_weapon_fire(player->tank); } if(e.key.keysym.sym == SDLK_h) player->tank->health -= 5; if(e.key.keysym.sym == SDLK_j) player->tank->armour -= 5; if(e.key.keysym.sym == SDLK_SPACE) { if(player->tank->is_hidden) player->tank->is_hidden = 0; else player->tank->is_hidden = 1; tank_sprite_change(player->tank); } if(e.key.keysym.sym == SDLK_ESCAPE) { playclicked = 0; entity_close_list(); tank_close_list(); player_close_list(); currentstate = MAINMENU; } } if(e.type == SDL_KEYUP) { if(e.key.keysym.sym == SDLK_w) player->keysHeld.W = 0; if(e.key.keysym.sym == SDLK_s) player->keysHeld.S = 0; if(e.key.keysym.sym == SDLK_a) player->keysHeld.A = 0; if(e.key.keysym.sym == SDLK_d) player->keysHeld.D = 0; } } if(g_deltatime < 32) SDL_Delay(32-g_deltatime); } while(currentstate == DEATHMATCH); return 0; }
int main_mainmenu() { SDL_Event e; SDL_ShowCursor(SDL_ENABLE); g_current_level = level_load("mainmenuconfig"); render_set_background(g_current_level->background->image); player_initialize_list(); ui_initialize_mainmenu(rtn_renderer()); do { render_update(0); render_clear(); while(SDL_PollEvent(&e)) { if(e.type == SDL_KEYDOWN) { if(e.type == SDL_QUIT) exit(0); if(e.key.keysym.sym == SDLK_ESCAPE) { currentstate = EXIT; exit(0); } } if(e.type == SDL_MOUSEBUTTONDOWN) { if(e.button.button == SDL_BUTTON_LEFT) { click = 1; } } if(e.type == SDL_MOUSEBUTTONUP) { if(e.button.button == SDL_BUTTON_LEFT) { click = 0; } } if(playclicked == 1) { slog("Changed to Deathmatch"); currentstate = DEATHMATCH; } else if(editorclicked == 1) { slog("Changed to LevelEditor"); currentstate = LEVELEDITOR; } else if(quitclicked == 1) { exit(0); } } } while(currentstate == MAINMENU); }
int main(int argc, char* argv[]) { printf("hello combine\n"); SDL_Surface* window; SDL_Event event; bool running = true; // create window int width = 480, height = 360; SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); window = SDL_SetVideoMode(width, height, 24, SDL_OPENGL | SDL_GL_DOUBLEBUFFER); // init render render_init(); // load all textures void* textures = textures_load("img"); // scene scene_t scene; scene_init(&scene); sprite_t draft; sprite_init(&draft, map_get(textures, "draft")); draft.layer = 60; sprite_t hud; sprite_init(&hud, map_get(textures, "draft")); hud.x = (hud.texture->width - width) / 2.0f; hud.y = (height - hud.texture->height) / 2.0f; // player player_t player; player_init(&player, &scene, textures, -50, -40); scene.space = array_add(scene.space, &draft); scene.hud = array_add(scene.hud, &hud); level_load(&scene, textures, "cave.lvl"); float counter = 0; int speed = 0; // main while (running) { while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: running = false; break; case SDL_KEYUP: case SDL_KEYDOWN: { switch(event.key.keysym.sym) { case SDLK_a: { if (speed == -1) { speed = 0; } else { speed = -1; } break; } case SDLK_d: { if (speed == 1) { speed = 0; } else { speed = 1; } break; } default: break; } } } } player_move(&player, speed * 2); if (running) { render(&scene, &player.camera); SDL_GL_SwapBuffers(); } draft.rotation += 0.5f; draft.transparency = sin(counter) / 2.0f + 0.5f; counter += 0.05f; } // clean up scene_release(&scene); textures_release(textures); SDL_Quit(); return 0; }