int main(int argc,char* argv[]) { SDL_Surface* screen=SDL_SetVideoMode(SIZE,SIZE,32,SDL_DOUBLEBUF); if(screen==NULL)return 1; init_terrain(); while(!SDL_GetKeyState(NULL)[SDLK_SPACE]) { SDL_PumpEvents(); draw_terrain(screen); do_step(); SDL_Flip(screen); int x,y; for(y=0;y<SIZE;y++) for(x=0;x<SIZE;x++) { float val=terrain[x][y].height; write(STDOUT_FILENO,&val,sizeof(float)); val=terrain[x][y].water.depth; write(STDOUT_FILENO,&val,sizeof(float)); } } return 0; }
void redraw_screen() { RECT pat_rect; pat_rect = windRect; InflateRect(&pat_rect,500,500); OffsetRect(&pat_rect,-ulx, -uly); //to counteract the shifting done in paint_pattern for ALL patterns. We're dealing with the background pattern here. paint_pattern(NULL,1,pat_rect,3); draw_main_screen(); if (overall_mode < 60); draw_terrain(); }
int main () { double prev_time = 0.0; double accum_sim_time = 0.0; if (!start_gl (800, 800)) { fprintf (stderr, "ERROR: could not start opengl\n"); return 1; } init_cam (); init_terrain (); init_dash (); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); glClearColor (0.0, 0.5, 0.5, 1.0); prev_time = glfwGetTime (); while (!glfwWindowShouldClose (gl_window)) { // work out how much time has passed double curr_time = glfwGetTime (); double elapsed = curr_time - prev_time; prev_time = curr_time; accum_sim_time += elapsed; // work out simulation time steps while (accum_sim_time > TIME_STEP_SIZE) { accum_sim_time -= TIME_STEP_SIZE; update_player (TIME_STEP_SIZE); } glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport (0, 0, gl_width, gl_height); draw_terrain (); // i dont want the dashboard to ever intersect with background so // i do a clear of the depth buffer glClear (GL_DEPTH_BUFFER_BIT); draw_dash (); // can expect everything has updated camera matrices by now cam_P_dirty = false; cam_V_dirty = false; glfwPollEvents (); glfwSwapBuffers (gl_window); } return 0; }
int main(int argc, char** argv) { #ifndef TARGET_ESC64 //disable line-buffering on stdin struct termios old_tio, new_tio; assert(!tcgetattr(STDIN_FILENO, &old_tio)); new_tio = old_tio; new_tio.c_lflag &= (~ICANON & ~ECHO); assert(!tcsetattr(STDIN_FILENO, TCSANOW, &new_tio)); #endif for(;;) { fputs("\x1B[2J\x1B[H\x1B[?25l", stdout); //clear screen, cursor to home, cursor invis player1.pos.x = 16; player2.pos.x = 60; //initialize / generate gen_terrain(); init_player(&player1); init_player(&player2); curPlayer = &player1; //draw draw_static(); draw_terrain(); draw_player(&player1); draw_player(&player2); draw_stats(&player1); draw_stats(&player2); while(player1.hull > 0 && player2.hull > 0) { if(player_input()) { break; } TERM_DRAWSTR(MSG_X, MSG_Y + 1, "shot fired"); shoot(); curPlayer = curPlayer == &player1 ? &player2 : &player1; } } #ifndef TARGET_ESC64 //restore old settings line-buffering settings //tcsetattr(STDIN_FILENO, TCSANOW, &old_tio); #endif //return 0; }
//��������������������������������������������������������������������������� // LanderGame - activate //��������������������������������������������������������������������������� void LanderGame::activate() { //��� Load palette and set color if (!Screen->load_palette(szIFF, 0)) panic("LanderGame::activate failed to load palette"); gberg_color(Screen->find(VngoColor24bit(255,255,0)), VNGO_TRANSPARENT); //��� Create event system evt = new MaxEventUser (*Devs); if (!evt || evt->load (szIFF,0) != 0) panic("LanderGame::activate fail for event"); evt->install(); //��� Create network if needed { XFParseINI ini; char buff[256]; ini.open(szINI, XF_OPEN_READ | XF_OPEN_DENYWRITE); //��� Screen parameters if (!ini.section("Lander")) { if (!ini.read("Multiplayer",buff)) { strlwr(buff); if (strstr(buff,"yes") || strstr(buff,"on")) { Net = new LanderNetwork (NUM_LANDERS); if (!Net) panic("LanderGame::activiate network create failed"); // Connect to the network, where appropriate TurnerNetworkUI net_ui (theSim.hWndClient, Net); if (net_ui.connect ()) { // We're on line! if (Net->is_host()) { // OutputDebugString ("We are the creator\n"); } else { // OutputDebugString ("We are joining an existing game\n"); // Get the terrain from another session } // Lander #0 is your lander! aLanders[0]->player_id = Net->create_player (Net->is_host() ? "Veteran": "Newbie", "Lunar Lander Pilot"); } else { delete Net; Net = 0; } } } } } //��� Create viewport assert(vport == 0); if (Screen->bit_depth == 8) { vport = new VngoVVport8(VngoRect(0,0,Screen->width,Screen->height), Screen->pal, 0); } else { vport = new VngoVVport16(VngoRect(0,0,Screen->width,Screen->height), Screen->pal, 0); } if (!vport) panic("LanderGame::activiate failed viewport create"); //��� Create the first lander (the player's lander) aLanders[0] = new Lander (evt, FALSE); if (!aLanders[0] || !aLanders[0]->load_images ()) panic("LanderGame::activiate failed to create lander"); //��� Initialize the terrain image draw_terrain (); //��� Reset the landers for (int i = 0; i < NUM_LANDERS; i++) if (aLanders[i]) aLanders[i]->reset(); //��� Initialize the time and frame count timer.clear(); frame = 0; }
void handle_menu_choice(eMenu item_hit) { std::string dialogToShow; sf::Event dummyEvent = {sf::Event::KeyPressed}; short i, choice; switch(item_hit) { case eMenu::NONE: break; case eMenu::FILE_OPEN: do_load(); break; case eMenu::FILE_SAVE: do_save(0); break; case eMenu::FILE_SAVE_AS: do_save(1); break; case eMenu::FILE_NEW: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show(); if(choice == "cancel") return; for(i = 0; i < 6; i++) univ.party[i].main_status = eMainStatus::ABSENT; party_in_memory = false; reload_startup(); overall_mode = MODE_STARTUP; draw_startup(0); } start_new_game(); draw_startup(0); menu_activate(); break; case eMenu::FILE_ABORT: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); if (choice=="cancel") return; reload_startup(); overall_mode = MODE_STARTUP; } party_in_memory = false; draw_startup(0); menu_activate(); break; case eMenu::PREFS: pick_preferences(); break; case eMenu::QUIT: if(overall_mode == MODE_STARTUP) { if(party_in_memory) { std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { fs::path file = nav_put_party(); if(!file.empty()) break; save_party(file, univ); } } All_Done = true; break; } if(overall_mode > MODE_TOWN) { std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show(); if(choice == "cancel") return; } else { std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { if(univ.file.empty()) { univ.file = nav_put_party(); if(univ.file.empty()) break; } save_party(univ.file, univ); } } All_Done = true; break; case eMenu::OPTIONS_PC_GRAPHIC: choice = char_select_pc(1,"New graphic for who?"); if(choice < 6) pick_pc_graphic(choice,1,nullptr); draw_terrain(); break; case eMenu::OPTIONS_DELETE_PC: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(1,"Delete who?"); if(choice < 6) { std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show(); if(confirm == "yes") kill_pc(univ.party[choice],eMainStatus::ABSENT); } draw_terrain(); } break; case eMenu::OPTIONS_RENAME_PC: choice = char_select_pc(1,"Rename who?"); if(choice < 6) pick_pc_name(choice,nullptr); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_NEW_PC: if(!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ABSENT) i = 20; if(i == 6) { ASB("Add PC: You already have 6 PCs."); print_buf(); break; } if(univ.town->has_tavern) { give_help(56,0); create_pc(6,nullptr); } else { add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2); } print_buf(); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_JOURNAL: journal(); break; case eMenu::OPTIONS_TALK_NOTES: if(overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return; } talk_notes(); break; case eMenu::OPTIONS_ENCOUNTER_NOTES: adventure_notes(); break; case eMenu::OPTIONS_STATS: if(overall_mode != MODE_STARTUP) print_party_stats(); break; case eMenu::HELP_OUT: dialogToShow = "help-outdoor"; break; case eMenu::HELP_TOWN: dialogToShow = "help-town"; break; case eMenu::HELP_COMBAT: dialogToShow = "help-combat"; break; case eMenu::HELP_BARRIER: dialogToShow = "help-fields"; break; case eMenu::HELP_HINTS: dialogToShow = "help-hints"; break; case eMenu::HELP_SPELLS: dialogToShow = "help-magic"; break; case eMenu::ABOUT: dialogToShow = "about-boe"; break; case eMenu::LIBRARY_MAGE: display_spells(eSkill::MAGE_SPELLS,100,0); break; case eMenu::LIBRARY_PRIEST: display_spells(eSkill::PRIEST_SPELLS,100,0); break; case eMenu::LIBRARY_SKILLS: display_skills(eSkill::INVALID,0); break; case eMenu::LIBRARY_ALCHEMY: // TODO: Create a dedicated dialog for alchemy info display_alchemy(); break; case eMenu::LIBRARY_TIPS: tip_of_day(); break; case eMenu::LIBRARY_INTRO: dialogToShow = "welcome"; break; case eMenu::ACTIONS_ALCHEMY: dummyEvent.key.code = sf::Keyboard::A; dummyEvent.key.shift = true; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_WAIT: dummyEvent.key.code = sf::Keyboard::W; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_AUTOMAP: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0); display_map(); } make_cursor_sword(); break; case eMenu::HELP_TOC: if(fs::is_directory(progDir/"doc")) launchURL("file://" + (progDir/"doc/game/Contents.html").string()); else launchURL("https://blades.calref.net/doc/game/Contents.html"); break; case eMenu::ABOUT_MAGE: case eMenu::ABOUT_PRIEST: give_help(209,0); break; case eMenu::ABOUT_MONSTERS: give_help(212,0); break; } if(!dialogToShow.empty()) { cChoiceDlog dlog(dialogToShow); dlog.show(); } }
void Handle_One_Event() { static const long twentyTicks = time_in_ticks(20).asMilliseconds(); static const long fortyTicks = time_in_ticks(40).asMilliseconds(); through_sending(); Handle_Update(); //(cur_time - last_anim_time > 42) if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true) && (!gInBackground)) { animTimer.restart(); draw_terrain(); } if((animTimer.getElapsedTime().asMilliseconds() > twentyTicks) && (overall_mode == MODE_STARTUP)) { animTimer.restart(); draw_startup_anim(true); } clear_sound_memory(); if(map_visible && mini_map.pollEvent(event)){ if(event.type == sf::Event::Closed) { mini_map.setVisible(false); map_visible = false; } else if(event.type == sf::Event::GainedFocus) makeFrontWindow(mainPtr); } if(!mainPtr.pollEvent(event)) { if(changed_display_mode) { changed_display_mode = false; adjust_window_mode(); } flushingInput = false; redraw_screen(REFRESH_NONE); return; } switch(event.type) { case sf::Event::KeyPressed: if(flushingInput) return; if(!(event.key.*systemKey)) handle_keystroke(event); break; case sf::Event::MouseButtonPressed: if(flushingInput) return; Mouse_Pressed(); break; case sf::Event::MouseLeft: // Make sure we don't have an arrow cursor when it's outside the window make_cursor_sword(); break; case sf::Event::GainedFocus: Handle_Update(); makeFrontWindow(mainPtr); case sf::Event::MouseMoved: if(!gInBackground) { location where(event.mouseMove.x, event.mouseMove.y); change_cursor(where); } break; case sf::Event::MouseWheelMoved: if(flushingInput) return; handle_scroll(event); break; case sf::Event::Closed: if(overall_mode == MODE_STARTUP) { if(party_in_memory) { std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { fs::path file = nav_put_party(); if(!file.empty()) break; save_party(file, univ); } } All_Done = true; break; } if(overall_mode > MODE_TOWN){ std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show(); if(choice == "cancel") break; } else { std::string choice = cChoiceDlog("quit-confirm-save", {"save", "quit", "cancel"}).show(); if(choice == "cancel") break; if(choice == "save") save_party(univ.file, univ); } All_Done = true; default: break; // There's several events we don't need to handle at all } flushingInput = false; // TODO: Could there be a case when the key and mouse input that needs to be flushed has other events interspersed? }
Boolean handle_menu (short item, HMENU menu) { short i; Boolean to_return = FALSE; short item_hit; Boolean need_redraw = FALSE; item_hit = item; switch (item) { case -1: break; case 1: // open load_scenario(); if (overall_mode == 60) { update_item_menu(); set_up_main_screen(); } break; case 2: // save modify_lists(); save_scenario(); break; case 3: // new scen build_scenario(); if (overall_mode == 60) set_up_main_screen(); break; case 5: // quit if (save_check(869) == FALSE) break; discard_graphics(); PostQuitMessage(0); break; // Scenario Menu case 101: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can add a new town.", "",0); return to_return; } if (scenario.num_towns >= 200) { give_error("You have reached the limit of 200 towns you can have in one scenario.", "",0); return to_return; } if (new_town(scenario.num_towns) == TRUE) set_up_main_screen(); break; case 103: edit_scen_details(); break; case 104: edit_scen_intro(); break; case 105: set_starting_loc(); break; case 106: overall_mode = 47; set_string("Select party starting location.",""); break; case 109: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(0,0); break; case 110: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(0,0); break; case 111: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can add a new town.", "",0); return to_return; } i = pick_import_town(841,0); if (i >= 0) { import_town(i); change_made = TRUE; redraw_screen(); } break; case 112: edit_save_rects(); break; case 113: edit_horses(); break; case 114: edit_boats(); break; case 115: edit_add_town(); break; case 116: edit_scenario_events(); break; case 117: edit_item_placement(); break; case 118: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can delete a town.", "",0); return to_return; } if (scenario.num_towns == 1) { give_error("You can't delete the last town in a scenario. All scenarios must have at least 1 town.", "",0); return to_return; } if (scenario.num_towns - 1 == cur_town) { give_error("You can't delete the last town in a scenario while you're working on it. Load a different town, and try this again.", "",0); return to_return; } if (scenario.num_towns - 1 == scenario.which_town_start) { give_error("You can't delete the last town in a scenario while it's the town the party starts the scenario in. Change the parties starting point and try this again.", "",0); return to_return; } if (fancy_choice_dialog(865,0) == 1) delete_last_town(); break; case 119: if (fancy_choice_dialog(866,0) == 1) { last_file_printed = 0; start_data_dump(); } break; case 120: if (change_made == TRUE) { give_error("You need to save the changes made to your scenario before you can print the file Scenario Text.", "",0); return to_return; } if (fancy_choice_dialog(871,0) == 1) { last_file_printed = 1; scen_text_dump(); redraw_screen(); } break; case 121: if (fancy_choice_dialog(867,0) == 1) { last_file_printed = 2; start_shopping_data_dump(); } break; case 122: if (fancy_choice_dialog(868,0) == 1) { last_file_printed = 3; start_monst_data_dump(); } break; case 123: if (fancy_choice_dialog(890,0) == 1) { last_file_printed = 4; start_spec_data_dump(); } break; case 124: if (fancy_choice_dialog(878,0) == 1) { last_file_printed = 7; object_scenario_data_dump(); } break; // Town Menu case 201: edit_town_details(); break; case 202: edit_town_wand(); break; case 203: overall_mode = 9; mode_count = 2; set_cursor(5); set_string("Set town boundary","Select upper left corner"); break; case 204: frill_up_terrain(); break; case 205: unfrill_terrain(); break; case 206: edit_town_strs(); break; case 208: if (fancy_choice_dialog(863,0) == 2) // add random break; place_items_in_town(); break; case 209: for (i = 0; i < 64; i++) // set not prop town.preset_items[i].property = 0; fancy_choice_dialog(861,0); draw_terrain(); break; case 210: if (fancy_choice_dialog(862,0) == 2) // clear all items break; for (i = 0; i < 64; i++) town.preset_items[i].item_code = -1; draw_terrain(); break; case 213: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(2,0); break; case 214: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(2,0); break; case 215: edit_advanced_town(); break; case 216: edit_town_events(); break; case 217: if (fancy_choice_dialog(872,0) == 2) // clear all monsters break; for (i = 0; i < 60; i++) { t_d.creatures[i].number = 0; t_d.creatures[i].start_loc.x = 0; t_d.creatures[i].start_loc.y = 0; t_d.creatures[i].spec_enc_code = 0; t_d.creatures[i].time_flag = 0; t_d.creatures[i].spec1 = -1; t_d.creatures[i].spec2 = -1; } break; case 218: if (fancy_choice_dialog(873,0) == 2) // clear all special encounters break; for (i = 0; i < 50; i++) { town.special_locs[i].x = 100; town.special_locs[i].y = 0; town.spec_id[i] = 255; } break; case 219: if (fancy_choice_dialog(874,0) == 2) // clear all fields break; for (i = 0; i < 50; i++) if ((town.preset_fields[i].field_type >= 0) && (town.preset_fields[i].field_type < 9)) { town.preset_fields[i].field_type = 0; town.preset_fields[i].field_loc.x = 0; town.preset_fields[i].field_loc.y = 0; } break; case 220: if (fancy_choice_dialog(876,0) == 2) // clear all stains break; for (i = 0; i < 50; i++) if ((town.preset_fields[i].field_type > 13) && (town.preset_fields[i].field_type < 22)) { town.preset_fields[i].field_type = 0; town.preset_fields[i].field_loc.x = 0; town.preset_fields[i].field_loc.y = 0; } break; case 221: if (fancy_choice_dialog(877,0) == 1) { // make concise town report last_file_printed = 5; start_town_data_dump(); } break; case 222: start_dialogue_editing(0); break; // Outdoor Menu case 301: outdoor_details(); break; case 302: edit_out_wand(0); break; case 303: edit_out_wand(1); break; case 304: frill_up_terrain(); break; case 305: unfrill_terrain(); break; case 306: edit_out_strs(); break; case 307: if (fancy_choice_dialog(875,0) == 2) // clear all special encounters break; for (i = 0; i < 18; i++) { current_terrain.special_locs[i].x = 100; current_terrain.special_locs[i].y = 0; current_terrain.special_id[i] = 255; } case 311: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_special_editing(1,0); break; case 312: lpsi.fMask = SIF_POS; lpsi.nPos = 0; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); //SetScrollPos(right_sbar,SB_CTL,0,TRUE); start_string_editing(1,0); break; break; case 313: if (fancy_choice_dialog(879,0) == 1) { last_file_printed = 6; start_outdoor_data_dump(); } break; case 401: start_town_edit(); break; case 402: start_out_edit(); break; case 403: short x, y; location spot_hit; if (editing_town == false) { if (change_made == TRUE) { if (save_check(859) == FALSE) break; } x = pick_out(cur_out); if (x >= 0) { spot_hit.x = x / 100; spot_hit.y = x % 100; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } } else { if (change_made == TRUE) { if (save_check(859) == FALSE) break; } x = pick_town_num(855,cur_town); if (x >= 0) { load_town(x); start_town_edit(); } } break; case 404: set_up_main_screen(); start_terrain_editing(); break; case 405: set_up_main_screen(); start_monster_editing(0); break; case 406: start_item_editing(0); break; case 407: set_up_main_screen(); break; case 408: // switch view cur_viewing_mode = 1 - cur_viewing_mode; need_redraw = TRUE; draw_main_screen(); draw_terrain(); break; case 409: // load previous town/outdoor zone if (editing_town == true) { if (cur_town == 0) load_town(scenario.num_towns - 1); else load_town(cur_town - 1); start_town_edit(); } else { if (cur_out.x > 0) { x = cur_out.x - 1; y = cur_out.y; } if ((cur_out.x == 0) && (cur_out.y > 0)) { x = scenario.out_width - 1; y = cur_out.y - 1; } if ((cur_out.x == 0) && (cur_out.y == 0)) { x = scenario.out_width - 1; y = scenario.out_height - 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } break; case 410: // load next town/outdoor zone if (editing_town == true) { if (cur_town + 1 == scenario.num_towns) load_town(0); else load_town(cur_town + 1); start_town_edit(); } else { if ((cur_out.x < (scenario.out_width - 1)) && (cur_out.y <= (scenario.out_height - 1))) { x = cur_out.x + 1; y = cur_out.y; } if ((cur_out.x == (scenario.out_width - 1)) && (cur_out.y < (scenario.out_height - 1))) { x = 0; y = cur_out.y + 1; } if ((cur_out.x == (scenario.out_width - 1)) && (cur_out.y == (scenario.out_height - 1))) { x = 0; y = 0; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); } break; case 411: // MENUITEM "Terrain Animations Play", 411 HMENU menu,big_menu; big_menu = GetMenu(mainPtr); menu = GetSubMenu(big_menu,4); if(play_anim == FALSE){ play_anim = TRUE; CheckMenuItem(menu,411,MF_BYCOMMAND | MF_CHECKED); } else{ play_anim = FALSE; CheckMenuItem(menu,411,MF_BYCOMMAND | MF_UNCHECKED); } break; case 412: // load outdoor zone above if (editing_town) break; if (cur_out.y > 0) { x = cur_out.x; y = cur_out.y - 1; } else { x = cur_out.x; y = scenario.out_height - 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); break; case 413: // load outdoor zone below if (editing_town) break; if (cur_out.y == scenario.out_height - 1) { x = cur_out.x; y = 0; } else { x = cur_out.x; y = cur_out.y + 1; } spot_hit.x = x; spot_hit.y = y; load_outdoors(spot_hit,0); augment_terrain(spot_hit); start_out_edit(); break; case 414: // Repeat print of last file printed switch (last_file_printed){ case 0: start_data_dump(); break; case 1: scen_text_dump(); break; case 2: start_shopping_data_dump(); break; case 3: start_monst_data_dump(); break; case 4: start_spec_data_dump(); break; case 5: start_town_data_dump(); break; case 6: start_outdoor_data_dump(); break; case 7: object_scenario_data_dump(); break; } break; // Extra Help case 801: // help file WinHelp(mainPtr,"Scenario Editor.hlp",HELP_CONTENTS,0L); break; case 802: fancy_choice_dialog(986,0); break; // started case 803: fancy_choice_dialog(1000,0); break; // testing case 804: fancy_choice_dialog(1001,0); break; // distributing case 805: fancy_choice_dialog(1062,0); break; default: if ((overall_mode >= 60) || (editing_town == FALSE)) { give_error("You can only place items and individual monsters in town sections, not outdoors.","",0); break; } if ((item_hit >= 600) && (item_hit < 1000)) { item_hit -= 600; if (scen_item_list.scen_items[item_hit].variety == 0) { give_error("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type.","",0); return to_return; } overall_mode = 4; set_string("Place the item.","Select item location"); mode_count = item_hit; } // skip the type 0 monster, it is non-existent if ((item_hit >= 1001) && (item_hit <= 1255)) { // 1,255? overall_mode = 28; item_hit -= 1000; set_string("Place the monster.","Select monster location"); mode_count = item_hit; } /* if ((item_hit >= 1256) && (item_hit <= 1455)) { item_hit -= 1256; mode_count = item_hit; load_town(item_hit); start_town_edit(); // set_string("Loading the indicated town."," "); } */ break; } if ((item >= 100) && (item < 200) && (item != 118) && (item != 119)) change_made = TRUE; return to_return; }
long CALLBACK WndProc (HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; //RECT s_rect = {0,0,30,30},d_rect = {0,0,30,30},d2 = {0,0,420,216},s2 = {0,0,420,216}; POINT press; short handled = 0,sbar_pos = 0,old_setting; long which_sbar; int min = 0, max = 0; HMENU menu; POINT p; RECT r; switch (message) { case WM_KEYDOWN: if (hwnd != mainPtr) { check_cd_event(hwnd,message,wParam,lParam); } else { All_Done = handle_syskeystroke(wParam,lParam,&handled); } return 0; break; case WM_CHAR: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { All_Done = handle_keystroke(wParam,lParam); } return 0; break; case WM_LBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,lParam); check_game_done(); } return 0; break; case WM_LBUTTONUP: mouse_button_held = FALSE; break; case WM_RBUTTONDOWN: mouse_button_held = FALSE; cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,-2); check_game_done(); } return 0; break; case WM_TIMER: // first, mouse held? if ((wParam == 1) && (mouse_button_held == TRUE)) { GetCursorPos(&p); ScreenToClient(mainPtr,&p); All_Done = handle_action(p, 0,0); } // second, refresh cursor? if ((wParam == 1) && (overall_mode < 60) && (GetFocus() == mainPtr)) { GetCursorPos(&p); ScreenToClient(mainPtr,&p); GetClientRect(mainPtr,&r); if (PtInRect(&r,p)) restore_cursor(); } if(play_anim == TRUE){ anim_ticks++; if(overall_mode < 60){ draw_terrain(); } if(overall_mode == 62){ if(store_ter.picture >= 2000) csp(813,14,store_ter.picture - 2000, 5); else if (store_ter.picture >= 400 && store_ter.picture < 1000) csp(813,14,store_ter.picture - 100, 0); if(do_choose_anim == TRUE){ put_choice_pics(); } } } break; case WM_PALETTECHANGED: palette_suspect = TRUE; return 0; case WM_ACTIVATE: if (hwnd == mainPtr) { if (((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) && (palette_suspect == TRUE)) { palette_suspect = FALSE; } if ((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) { window_in_front = TRUE; } if (wParam == WA_INACTIVE) { window_in_front = FALSE; } } return 0; case WM_MOUSEMOVE: if ((mouse_button_held == TRUE) && (hwnd == mainPtr)) { press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,lParam); } restore_cursor(); return 0; case WM_PAINT: hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else redraw_screen(); return 0; case WM_VSCROLL: which_sbar = GetWindowLong((HWND) lParam, GWL_ID); switch (which_sbar) { case 1: sbar_pos = GetScrollPos(right_sbar,SB_CTL); old_setting = sbar_pos; GetScrollRange(right_sbar,SB_CTL,&min,&max); switch (LOWORD(wParam)) { case SB_PAGEDOWN: sbar_pos += NRSONPAGE - 1; break; case SB_LINEDOWN: sbar_pos++; break; case SB_PAGEUP: sbar_pos -= NRSONPAGE - 1; break; case SB_LINEUP: sbar_pos--; break; case SB_TOP: sbar_pos = 0; break; case SB_BOTTOM: sbar_pos = max; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: sbar_pos = HIWORD(wParam); break; } if (sbar_pos < 0) sbar_pos = 0; if (sbar_pos > max) sbar_pos = max; lpsi.fMask = SIF_POS; lpsi.nPos = sbar_pos; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); // SetScrollPos(right_sbar,SB_CTL,sbar_pos,TRUE); if (sbar_pos != old_setting) draw_rb(); break; } SetFocus(mainPtr); return 0; case WM_COMMAND: if (hwnd == mainPtr) { menu = GetMenu(mainPtr); handle_menu((short) wParam, menu); check_game_done(); } else { check_cd_event(hwnd,message,wParam,lParam); } return 0; case WM_DESTROY: case WM_CLOSE: if (hwnd == mainPtr) { discard_graphics(); PostQuitMessage(0); } return 0; case WM_QUIT: if (hwnd == mainPtr) discard_graphics(); break; } return DefWindowProc(hwnd,message,wParam,lParam); }
void do_explosion_anim(short sound_num,short special_draw) // sound_num currently ignored // special_draw - 0 normal 1 - first half 2 - second half { Rect temp_rect,active_area_rect,to_rect,from_rect; Rect base_rect = {0,0,36,28},text_rect; char str[60]; short i,temp_val,temp_val2; location screen_ul; short t,cur_boom_type = 0; Point current_terrain_ul; GWorldPtr temp_gworld; GrafPtr old_port; short boom_type_sound[3] = {5,10,53}; if ((have_boom == false) || (boom_anim_active == false)) { boom_anim_active = false; return; } for (i = 0; i < 30; i++) if (store_booms[i].boom_type >= 0) i = 50; if (i == 30) return; // initialize general data if (in_startup_mode) { current_terrain_ul.h = 306; current_terrain_ul.v = 5; } else current_terrain_ul.h = current_terrain_ul.v = 5; // make terrain_template contain current terrain all nicely draw_terrain(1); if (special_draw != 2) { GetPortBounds(terrain_screen_gworld,&to_rect); Rect oldRect = to_rect; OffsetRect(&to_rect,current_terrain_ul.h, current_terrain_ul.v); rect_draw_some_item(terrain_screen_gworld,oldRect,to_rect,ul); } GetPort(&old_port); // create and clip temporary anim template GetPortBounds(terrain_screen_gworld,&temp_rect); NewGWorld(&temp_gworld, 0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap); SetPort(temp_gworld); TextFont(geneva_font_num); TextFace(bold); TextSize(10); active_area_rect = temp_rect; InsetRect(&active_area_rect,13,13); ClipRect(&active_area_rect); SetPort(GetWindowPort(mainPtr)); // init missile paths screen_ul.x = center.x - 4; screen_ul.y = center.y - 4; for (i = 0; i < 30; i++) if ((store_booms[i].boom_type >= 0) && (special_draw < 2)) { cur_boom_type = store_booms[i].boom_type; explode_place_rect[i] = base_rect; OffsetRect(&explode_place_rect[i],13 + 28 * (store_booms[i].dest.x - screen_ul.x) + store_booms[i].x_adj, 13 + 36 * (store_booms[i].dest.y - screen_ul.y) + store_booms[i].y_adj); if ((store_booms[i].place_type == 1) && (special_draw < 2)) { temp_val = get_ran(1,0,50) - 25; temp_val2 = get_ran(1,0,50) - 25; OffsetRect(&explode_place_rect[i],temp_val,temp_val2); } // eliminate stuff that's too gone. Rect tempRect2; GetPortBounds(terrain_screen_gworld,&tempRect2); SectRect(&explode_place_rect[i],&tempRect2,&temp_rect); if (EqualRect(&temp_rect,&explode_place_rect[i]) == false) { store_booms[i].boom_type = -1; } } else if (special_draw < 2) explode_place_rect[i].top =explode_place_rect[i].left =explode_place_rect[i].bottom =explode_place_rect[i].right = 0; //play_sound(-1 * sound_num); if (special_draw < 2) play_sound(-1 * boom_type_sound[cur_boom_type]); // Now, at last, do explosion for (t = (special_draw == 2) ? 6 : 0; t < ((special_draw == 1) ? 6 : 11); t++) { // t goes up to 10 to make sure screen gets cleaned up // First, lay terrain in temporary graphic area; for (i = 0; i < 30; i++) if (store_booms[i].boom_type >= 0) rect_draw_some_item(terrain_screen_gworld,explode_place_rect[i], temp_gworld,explode_place_rect[i]); // Now put in explosions for (i = 0; i < 30; i++) if (store_booms[i].boom_type >= 0) { if ((t + store_booms[i].offset >= 0) && (t + store_booms[i].offset <= 7)) { from_rect = base_rect; OffsetRect(&from_rect,28 * (t + store_booms[i].offset),36 * (1 + store_booms[i].boom_type)); rect_draw_some_item(boom_gworld,from_rect, temp_gworld,explode_place_rect[i],transparent); if (store_booms[i].val_to_place > 0) { text_rect = explode_place_rect[i]; text_rect.top += 4; text_rect.left -= 10; if (store_booms[i].val_to_place < 10) text_rect.left += 8; sprintf(str,"%d",store_booms[i].val_to_place); SetPort(temp_gworld); ForeColor(whiteColor); char_port_draw_string(temp_gworld,text_rect,str,1,12); ForeColor(blackColor); SetPort(GetWindowPort(mainPtr)); } } } // Now draw all missiles to screen for (i = 0; i < 30; i++) if (store_booms[i].boom_type >= 0) { to_rect = explode_place_rect[i]; OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v); rect_draw_some_item(temp_gworld,explode_place_rect[i],to_rect,ul); } //if (((PSD[SDF_GAME_SPEED] == 1) && (t % 3 == 0)) || ((PSD[SDF_GAME_SPEED] == 2) && (t % 2 == 0))) FlushAndPause(2 * (1 + PSD[SDF_GAME_SPEED])); } // Exit gracefully, and clean up screen for (i = 0; i < 30; i++) if (special_draw != 1) store_booms[i].boom_type = -1; DisposeGWorld(temp_gworld); SetPort(old_port); //to_rect = terrain_screen_gworld->portRect; //OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v); //rect_draw_some_item(terrain_screen_gworld,terrain_screen_gworld->portRect, // terrain_screen_gworld,to_rect,0,1); }
void do_missile_anim(short num_steps,location missile_origin,short sound_num) { Rect temp_rect,missile_origin_base = {1,1,17,17},active_area_rect,to_rect,from_rect; short i,store_missile_dir; Point start_point,finish_point[30]; location screen_ul; short x1[30],x2[30],y1[30],y2[30],t; // for path paramaterization Rect missile_place_rect[30],missile_origin_rect[30],store_erase_rect[30]; Point current_terrain_ul; GWorldPtr temp_gworld; GrafPtr old_port; if ((have_missile == false) || (boom_anim_active == false)) { boom_anim_active = false; return; } for (i = 0; i < 30; i++) if (store_missiles[i].missile_type >= 0) i = 50; if (i == 30) return; // initialize general data if (in_startup_mode) { current_terrain_ul.h = 306; current_terrain_ul.v = 5; } else current_terrain_ul.h = current_terrain_ul.v = 5; // make terrain_template contain current terrain all nicely draw_terrain(1); GetPortBounds(terrain_screen_gworld,&to_rect); Rect oldBounds = to_rect; OffsetRect(&to_rect,current_terrain_ul.h, current_terrain_ul.v); rect_draw_some_item(terrain_screen_gworld,oldBounds,to_rect,ul); GetPort(&old_port); // create and clip temporary anim template GetPortBounds(terrain_screen_gworld,&temp_rect); NewGWorld(&temp_gworld, 0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap); SetPort(temp_gworld); active_area_rect = temp_rect; InsetRect(&active_area_rect,13,13); ClipRect(&active_area_rect); SetPort(GetWindowPort(mainPtr)); // init missile paths for (i = 0; i < 30; i++) { SetRect(&store_erase_rect[i],0,0,0,0); if ((store_missiles[i].missile_type >= 0) && (missile_origin == store_missiles[i].dest)) store_missiles[i].missile_type = -1; } screen_ul.x = center.x - 4; screen_ul.y = center.y - 4; start_point.h = 13 + 14 + 28 * (short) (missile_origin.x - screen_ul.x); start_point.v = 13 + 18 + 36 * (short) (missile_origin.y - screen_ul.y); for (i = 0; i < 30; i++) if (store_missiles[i].missile_type >= 0) { finish_point[i].h = 1 + 13 + 14 + store_missiles[i].x_adj + 28 * (short) (store_missiles[i].dest.x - screen_ul.x); finish_point[i].v = 1 + 13 + 18 + store_missiles[i].y_adj + 36 * (short) (store_missiles[i].dest.y - screen_ul.y); // note ... +1 at beginning is put in to prevent infinite slope if (store_missiles[i].missile_type < 7) { store_missile_dir = get_missile_direction(start_point,finish_point[i]); missile_origin_rect[i] = missile_origin_base; OffsetRect(&missile_origin_rect[i],18 * store_missile_dir,18 * store_missiles[i].missile_type); } else { missile_origin_rect[i] = missile_origin_base; OffsetRect(&missile_origin_rect[i],0,18 * store_missiles[i].missile_type); } // x1 slope x2 start pt x1[i] = finish_point[i].h - start_point.h; x2[i] = start_point.h; y1[i] = finish_point[i].v - start_point.v; y2[i] = start_point.v; } else missile_place_rect[i].top =missile_place_rect[i].left =missile_place_rect[i].bottom =missile_place_rect[i].right = 0; play_sound(-1 * sound_num); // Now, at last, launch missile for (t = 0; t < num_steps; t++) { for (i = 0; i < 30; i++) if (store_missiles[i].missile_type >= 0) { // Where place? temp_rect = missile_origin_base; OffsetRect(&temp_rect,-8 + x2[i] + (x1[i] * t) / num_steps, -8 + y2[i] + (y1[i] * t) / num_steps); // now adjust for different paths if (store_missiles[i].path_type == 1) OffsetRect(&temp_rect,0, -1 * (t * (num_steps - t)) / 100); SectRect(&temp_rect,&active_area_rect,&missile_place_rect[i]); // Now put terrain in temporary; rect_draw_some_item(terrain_screen_gworld,missile_place_rect[i], temp_gworld,missile_place_rect[i]); // Now put in missile from_rect = missile_origin_rect[i]; if (store_missiles[i].missile_type >= 7) OffsetRect(&from_rect,18 * (t % 8),0); rect_draw_some_item(missiles_gworld,from_rect, temp_gworld,temp_rect,transparent); } // Now draw all missiles to screen for (i = 0; i < 30; i++) if (store_missiles[i].missile_type >= 0) { to_rect = store_erase_rect[i]; OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v); rect_draw_some_item(terrain_screen_gworld,store_erase_rect[i],to_rect,ul); to_rect = missile_place_rect[i]; store_erase_rect[i] = to_rect; OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v); rect_draw_some_item(temp_gworld,missile_place_rect[i],to_rect,ul); } if ((PSD[SDF_GAME_SPEED] == 3) || ((PSD[SDF_GAME_SPEED] == 1) && (t % 4 == 0)) || ((PSD[SDF_GAME_SPEED] == 2) && (t % 3 == 0))) FlushAndPause(1); } // Exit gracefully, and clean up screen for (i = 0; i < 30; i++) store_missiles[i].missile_type = -1; DisposeGWorld(temp_gworld); SetPort(old_port); GetPortBounds(terrain_screen_gworld,&to_rect); Rect oldRect = to_rect; OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v); rect_draw_some_item(terrain_screen_gworld,oldRect,to_rect,ul); }
void render_scene(void) { glClearColor(0, 0, 0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_LIGHT0); // camera position glLoadIdentity(); glTranslatef(-(lander_x_pos * 0.7), 0, -12); glRotatef(0.0, 0.0, 0.0, 0.0); glTranslatef(0, 0, 12); /* models can be placed in the scene using opengl by saving the modelview matrix before drawing the model and restoring it right afterwards. */ // earth light_position[0] = 500.0; // x light_position[1] = 0.0; // y light_position[2] = 100.0; // z light_position[3] = 0.0; glLightfv(GL_LIGHT0, GL_POSITION, light_position); light_diffuse[0] = 2; light_diffuse[1] = 2; light_diffuse[2] = 2; light_diffuse[3] = 1; glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); light_ambient[0] = 0; light_ambient[1] = 0; light_ambient[2] = 0; light_ambient[3] = 0; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glPushMatrix(); // save camera glTranslatef(-1000, 1000, -3000); glRotatef(-90, 1.0, 0, 0); glRotatef(earth_angle, 0, 0, 1); glScalef(100.0, 100.0, 100.0); draw_earth(); glPopMatrix(); // restore camera // terrain light_position[0] = 100.0; light_position[1] = 30.0; light_position[2] = 30.0; light_position[3] = 0.0; glLightfv(GL_LIGHT0, GL_POSITION, light_position); light_diffuse[0] = 1.5; light_diffuse[1] = 1.5; light_diffuse[2] = 1.5; light_diffuse[3] = 1; glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glPushMatrix(); // save camera glTranslatef(0, -20, -90); glRotatef(-90, 1.0, 0.0, 0.0); glScalef(150.0, 150.0, 20.0); draw_terrain(); glPopMatrix(); // restore camera // lander light_position[0] = 100.0; light_position[1] = 50.0; light_position[2] = 30.0; light_position[3] = 0.0; glLightfv(GL_LIGHT0, GL_POSITION, light_position); light_diffuse[0] = 1; light_diffuse[1] = 1; light_diffuse[2] = 1; light_diffuse[3] = 1; glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); light_ambient[0] = 0.5; light_ambient[1] = 0.5; light_ambient[2] = 0.5; light_ambient[3] = 0.5; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glPushMatrix(); // save camera glTranslatef(lander_x_pos, lander_y_pos, lander_z_pos); glRotatef(-90, 1.0, 0.0, 0.0); glRotatef(lander_x_pos_rate * 90, 0.0, 1.0, 0.0); glRotatef(lander_z_pos_rate * 90, 1.0, 0.0, 0.0); glRotatef(-45 + lander_y_angle, 0.0, 0.0, 1.0); glScalef(0.2, 0.2, 0.16); draw_lander(); glPopMatrix(); // restore camera glFlush(); SDL_GL_SwapWindow(main_window); }
void display(int d) { int i; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(lock) { if(eye[0] < -23.0 - 28.0*tan(M_PI/6)) eye[0] = -23.0 - 28.0*tan(M_PI/6); if(eye[0] > 33.0) eye[0] = 33.0; if(eye[1] < -28.0 - 26.5*tan(M_PI/6)) eye[1] = -28.0 - 26.5*tan(M_PI/6); if(eye[1] > 25.0) eye[1] = 25.0; if(eye[2] < -25.0) eye[2] = -25.0; if(eye[2] > 51.0 + 65.0*tan(M_PI/6)) eye[2] = 51.0 + 65.0*tan(M_PI/6); } if(!helmet) { for(i=0; i < 3; i++) view[i] = (2 * negview * eye[i]); up[0] = 0; up[1] = negup * 1.0; up[2] = 0; } if(d==D_LEFT) { glTranslatef(-2.5, 0.0, 0.0); } else if(d==D_RIGHT) { glTranslatef(2.5, 0.0, 0.0); } gluLookAt(eye[0], eye[1], eye[2], view[0], view[1], view[2], up[0], up[1], up[2]); glTranslatef(global_translate[0], global_translate[1], global_translate[2]); glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); /* glRotatef(theta, 0.0, 1.0, 0.0); glRotatef(phi, 1.0, 0.0, 0.0);*/ glColor3f(1.0, 1.0, 1.0); if(wireframe) { glPolygonMode(GL_FRONT, GL_LINE); glDisable(GL_CULL_FACE); } else { glPolygonMode(GL_FRONT, GL_FILL); glEnable(GL_CULL_FACE); } /* Draw coordinate axes */ glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); if(axes) { glPushMatrix(); glTranslatef(-global_translate[0], -global_translate[1], -global_translate[2]); glBegin(GL_LINES); glVertex3f(-100.0, 0.0, 0.0); glVertex3f(100.0, 0.0, 0.0); glVertex3f(0.0, -100.0, 0.0); glVertex3f(0.0, 100.0, 0.0); glVertex3f(0.0, 0.0, -100.0); glVertex3f(0.0, 0.0, 100.0); glEnd(); glPopMatrix(); } if(texture) glEnable(GL_TEXTURE_2D); if(lighting) glEnable(GL_LIGHTING); if(!smooth) {glDisable(GL_SMOOTH); glShadeModel(GL_FLAT); glEnable(GL_FLAT);} else {glDisable(GL_FLAT); glShadeModel(GL_SMOOTH); glEnable(GL_SMOOTH);} if(filtering) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } draw_scene(); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); if(terrain) draw_terrain(); /* Draw w/o lighting */ if(stars) draw_stars(); glPopMatrix(); glPopAttrib(); /* And swap buffers to display the image */ glutSwapBuffers(); /* if(helmet) child(1);*/ }