void MapfileLoadAction::act(std::string path, float secondsElapsed) { #ifdef CLIENT std::string basename = assetId; ClientSystem::currMap = basename; load_world( ClientSystem::currMap.c_str() ); #endif }
int debug_load_world(Object * obj, Object * obj2) { load_world(obj->world, "world.bin"); gotoxy(0, 0); set_color(0, 14); printf("world loaded"); Sleep(1000); return 1; }
void map::load_worlds() { worlds_.clear(); // Get the maps directory QDir d(QString("%1/maps/").arg(QCoreApplication::applicationDirPath())); // Get all the files which have the extension which ends by: .dll, .so and .dylib QStringList list = d.entryList(QStringList() << "*.dll" << "*.so" << "*.dylib", QDir::Files, QDir::Name); for (int i = 0; i < list.size(); ++i) load_world(list.at(i)); }
int main (int argc, const char* argv[]) { //Super important note: //MSVS Doesn't allow declarations to follow statements in a block. //It uses an old C90 ruleset. Support for this was added to C in the C99 standard room alpha; room* rooms = alloc_room(); char* t_str = strmalloc(); FILE* world = fopen("WORLD.DAT","r"); //TODO: Add a parameter parser to allow users to specify different worlds. if (world == NULL) { printf("Could not open WORLD.DAT!\n"); return 1; } load_world(rooms, world); //Load our world data into the rooms /// TEST ROUTINES // /*while (rooms != NULL) //NOTE: Using this will break the room looking { printf(rooms->name); printf("\n"); while (rooms->areas != NULL) { printf("\t"); printf(rooms->areas->name); printf("\n"); printf("\t\t"); printf(rooms->areas->desc); printf("\n"); rooms->areas = rooms->areas->next; } rooms = rooms->next; } if (t_str == "") printf("Empty String"); else if (t_str == NULL) printf("NULL String"); else { itoa(strlen(t_str), t_str, 1); printf(t_str); }*/ printf(rooms->doors->name); gameloop(rooms); printf("User Exited. Press any key to quit."); getchar(); /// END TEST ROUTINES // fclose(world); return 0; }
bool Game::load_game(std::string filename) { std::ifstream fin; fin.open(filename.c_str()); if (!fin.is_open()) { debugmsg("Couldn't open %s for reading.", filename.c_str()); return false; } if (!city->load_data(fin)) { debugmsg("Game failed to load city."); return false; } load_world(); return true; }
int main(int argc, char **argv) { // Create an OpenGL context and a GLUT window. glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(reso_x, reso_y); glutCreateWindow("Box2D"); // Bind all GLUT events do callback function. glutDisplayFunc(&draw); glutIdleFunc(&draw); glutReshapeFunc(&resize_window); glutKeyboardFunc(&key_pressed); glutMouseFunc(&mouse_clicked); glutMotionFunc(&mouse_moved); glutPassiveMotionFunc(&mouse_moved); // Initialise the matrices so we have an orthogonal world with the same size // as the levels, and no other transformations. glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, world_x, 0, world_y, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Read the levels into a bunch of structs. num_levels = load_levels(&levels); printf("Loaded %d levels.\n", num_levels); // Load the first level (i.e. create all Box2D stuff). load_world(0); last_time = glutGet(GLUT_ELAPSED_TIME); frame_count = 0; glutMainLoop(); return 0; }
/* * Called when the user presses a key. */ void key_pressed(unsigned char key, int x, int y) { switch (key) { case 27: // Esc case 'q': cleanup(); exit(0); break; // Add any keys you want to use, either for debugging or gameplay. case ' ': play = !play; break; // case '1': // load_world(0); // break; // case '2': // load_world(1); // break; // case '3': // load_world(2); // break; // case '4': // load_world(3); // break; // case '5': // load_world(4); // break; case 'r': /* Reset level. */ load_world(current_level - 1); break; case 'b': /* Reset ball to starting position. */ resetBall(); break; default: break; } }
void changemap(const char *name) { if(!connected) localconnect(); if(editmode) toggleedit(); if(!load_world(name)) emptymap(0, true, name); }
/* * Called when we should redraw the scene (i.e. every frame). * It will show the current framerate in the window title. */ void draw(void) { int time = glutGet(GLUT_ELAPSED_TIME); int frametime = time - last_time; frame_count++; // Clear the buffer glColor3f(0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); // // Do any logic and drawing here. // // suggested vel = 8, suggested pos = 3. float32 timestep = 1.0f / 60.0f; int32 velocity_iterations = 6; int32 position_iterations = 2; b2Body *body_list = world->GetBodyList(); int current_polygon = 0; while(body_list != NULL) { b2Fixture *fixture_list = body_list->GetFixtureList(); if (ground == body_list) { body_list = body_list->GetNext(); current_polygon++; continue; } while(fixture_list != NULL) { if (fixture_list->GetType() == 2) { b2PolygonShape *poly = (b2PolygonShape*) fixture_list->GetShape(); drawPolygon(body_list, poly); } fixture_list = fixture_list->GetNext(); } body_list = body_list->GetNext(); current_polygon++; } if (play) { world->Step(timestep, velocity_iterations, position_iterations); /* If the ball has reached the finish, continue to the next level or finish the game. */ b2Vec2 position = ball->GetPosition(); if (ballHasReachedFinish(position)) { if (current_level > num_levels) { timeval play_time2; gettimeofday(&play_time2, 0); fprintf(stderr, "You have played for %d seconds.\n", play_time2.tv_sec - play_time.tv_sec); fprintf(stderr, "You have won the game! Also, you have lost the game... ;)\n"); exit(0); } else { gettimeofday(&finish_time, 0); fprintf(stderr, "You finished level %d in %d seconds!\n", current_level, finish_time.tv_sec - start_time.tv_sec); if (current_level >= num_levels) { fprintf(stderr, "You have won the game! Also, you have lost the game... ;)\n"); exit(0); } else { load_world(current_level); /* Automatically pause the world... */ play = 0; } } } } // Draw ball drawBall(); // Draw finish drawFinish(); if (num_vertices > -1) { drawVertex(num_vertices); // printf("derp%d\n", num_vertices); if (drawn == 1) { num_vertices = -1; drawn = 0; } } // Show rendered frame glutSwapBuffers(); // Display fps in window title. if (frametime >= 1000) { char window_title[128]; snprintf(window_title, 128, "Box2D: %f fps, level %d/%d", frame_count / (frametime / 1000.f), current_level, num_levels); glutSetWindowTitle(window_title); last_time = time; frame_count = 0; } }
void changemapserv(char *name, int mode) // forced map change from the server { gamemode = mode; load_world(name); };
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags), petri_dish(), histogramDialog(0), changed(true), auto_save(false), update_thread(this, this) { setupUi(this); connect(&timer, SIGNAL(timeout()), &petri_dish, SLOT(step())); connect(&petri_dish, SIGNAL(changed()), worldView, SLOT(queueUpdate())); //connect(&petri_dish, SIGNAL(changed()), worldView, SLOT(repaint())); connect(&petri_dish, SIGNAL(changed()), this, SLOT(set_stats())); connect(runButton, SIGNAL(clicked()), this, SLOT(start_stop())); //connect(checkIntegrity, SIGNAL(clicked()), this, SLOT(check_integrity())); connect(stepBtn, SIGNAL(clicked()), this, SLOT(step())); connect(radViewDefault, SIGNAL(clicked()), &petri_dish, SLOT(set_default_view_mode())); connect(radViewBugs, SIGNAL(clicked()), &petri_dish, SLOT(set_bugs_view_mode())); connect(radViewEnergy, SIGNAL(clicked()), &petri_dish, SLOT(set_energy_view_mode())); connect(radViewAge, SIGNAL(clicked()), &petri_dish, SLOT(set_age_view_mode())); connect(radViewSize, SIGNAL(clicked()), &petri_dish, SLOT(set_dna_size_view_mode())); connect(radViewDNA, SIGNAL(clicked()), &petri_dish, SLOT(set_dna_view_mode())); connect(radViewTerrain, SIGNAL(clicked()), &petri_dish, SLOT(set_terrain_view_mode())); connect(actionNew, SIGNAL(triggered()), this, SLOT(new_world())); connect(actionSave, SIGNAL(triggered()), this, SLOT(save_world())); connect(actionOpen, SIGNAL(triggered()), this, SLOT(load_world())); connect(actionSave_As, SIGNAL(triggered()), this, SLOT(save_as_world())); connect(settings, SIGNAL(settingsChanged()), this, SLOT(change_world())); connect(actionAutoSave, SIGNAL(triggered()), this, SLOT(autosave_world())); connect(actionCheck_Integrity, SIGNAL(triggered()), this, SLOT(check_integrity())); connect(worldView, SIGNAL(clicked(int, int)), this, SLOT(edit_bug(int, int))); connect(idleChk, SIGNAL(clicked(bool)), this, SLOT(enableIdleDetect(bool))); connect(&idleTimer, SIGNAL(timeout()), this, SLOT(checkIdle())); autosave_timer.setInterval(1000 * 60 * 2); // every two mins connect(&autosave_timer, SIGNAL(timeout()), this, SLOT(save_world())); petri_dish.set_widget(worldView); petri_dish.init(settings->getParams()); totalEnergy->setText(QString().setNum(petri_dish.get_total_energy())); spinDNAVal->setMaximum(settings->getParams().max_data); set_stats(); last_time = 0; update_time.start(); updates_per_sec = 0; //update_thread.start(); horizontalSlider->setValue(1000); timer.start(0); setAttribute(Qt::WA_QuitOnClose, true); repaint(); if(!qApp->arguments().size() > 1) { bool running; load_from_file(qApp->arguments().at(1), running); if(running) start(); } }
void changemapserv(const std::string &name, int mode) // forced map change from the server { gamemode = mode; load_world(name); }