Beispiel #1
0
bool game_launcher::goto_editor()
{
	if(jump_to_editor_){
		jump_to_editor_ = false;
		std::unique_ptr<savegame::load_game_metadata> load_data = std::move(load_data_);
		if (start_editor(filesystem::normalize_path(load_data ? load_data->filename : "")) ==
		    editor::EXIT_QUIT_TO_DESKTOP)
		{
			return false;
		}
	}
	return true;
}
Beispiel #2
0
bool game_launcher::goto_editor()
{
	if(jump_to_editor_){
		jump_to_editor_ = false;
		if (start_editor(filesystem::normalize_path(game::load_game_exception::game)) ==
		    editor::EXIT_QUIT_TO_DESKTOP)
		{
			return false;
		}
		clear_loaded_game();
	}
	return true;
}
Beispiel #3
0
int main(int argc, char* argv[]) {
  board b;

  if(argc < 2) {
    print_help();
    exit(1);
  }

  initscr();
  cbreak();
  curs_set(0);
  keypad(stdscr, TRUE);
  noecho();

  if(streq(argv[1], "-d")) {
    int x = getch();
    clear();
    mvprintw(0,0,"%i", x);
    getch();
    echo();
    curs_set(1);
    endwin();
    exit(0);
  }
  if(streq(argv[1], "-e") || streq(argv[1], "--editor")) {
    b = start_editor();
  } else {
    b = create_board_from_name(argv[1]);
  }
  int generation = 0;

  while(true) {
    mvprintw(0,0,"Generation: %d", generation);
    generation++;
    print_board(1, 0, b);
    refresh();
    board b1 = tick_board(b);
    free(b);
    b = b1;
    long one_second = 1000000;
    usleep(one_second/6);
  }

  free_board(b);
  echo();
  curs_set(1);
  endwin();
  return 0;
}
Beispiel #4
0
static int initialize_and_run(bool launch_editor) {
    shared_editor_state_t *editor_state = new shared_editor_state_t;

    std::shared_ptr<warp::transition_i> start_level(new level_transition_t);
    std::shared_ptr<warp::transition_i> start_editor
            (new enter_editor_transition_t(editor_state));
    std::shared_ptr<warp::transition_i> edit_region
            (new edit_region_transition_t(editor_state));
    //std::shared_ptr<warp::transition_i> end_level(new gameover_transition_t);

    warp::statemanager_t states = {
        "level", "editor-region-sel", "editor-region", "editor-level"
    };
    states.insert_transition(START_STATE, "level", start_level, false);
    states.insert_transition("level", "level", start_level, false);
    states.insert_transition(START_STATE, "editor-region-sel", start_editor, false);
    states.insert_transition("editor-region-sel", "editor-region", edit_region, false);
    //states.insert_transition("level", END_STATE, end_level, false);

    warp::game_config_t config;
    fill_default_config(&config);

    config.max_entites_count = 512;
    config.window_name = APP_NAME;
    config.first_state = launch_editor ? "editor-region-sel" : "level";

    warp::game_t *game = new warp::game_t;
    warp_result_t init_result = game->initialize(config, states);
    if (WARP_FAILED(init_result)) {
        warp_result_log("Faile to initialize game", &init_result);
        warp_result_destory(&init_result);
        return 1;
    }

    int exit_code = game->run();
    /* on iOS the game continues to operate after main has finished */
    if (game->is_alive_after_main() == false) {
        delete game;
    }
    return exit_code;
}
Beispiel #5
0
	editor::EXIT_STATUS start_editor() { return start_editor(""); }
Beispiel #6
0
Datei: main.c Projekt: mengpq/os
void process_command(char* cmd){
	char* CMD[10];
	memset(CMD,0,10);
	int i,pid,total,status;
	total=0;
	split_by_space(CMD,cmd,&total);
	if (total==0) return;
	if (strcmp(CMD[0],"clear")==0){
		clear_screen();
	} else if (strcmp(CMD[0],"run")==0){
		if (total<2 || (pid=run(CMD[1]))==-1){
			display_string("this program is not exists or already running!\n");
		} else{
			display_string("run successful ");
			display_string("pid = "); display_int(pid); 
			display_string(" name = "); display_string(CMD[1]);
			display_string("\n");
		}
	} else if (strcmp(CMD[0],"sleep")==0){
		if (total<2 || sleep(CMD[1])==-1){
		} else{
			display_string("Process "); 
			display_string(CMD[1]);
			display_string(" is sleeping now!\n");
		}
	} else if (strcmp(CMD[0],"kill")==0){
		if (total<2 || !is_number(CMD[1])){
			display_string("Usage: kill <pid>\n");
		} else 
		if (kill(CMD[1])==-1){
			display_string("No such process\n");
		} else{
			display_string("The process with pid=");
			display_string(CMD[1]);
			display_string(" was stopped\n");
		}
	} else if (strcmp(CMD[0],"killall")==0){
		if (total<2){
			display_string("Usage: killall <name>");
		} else{
			if (killall(CMD[1])==-1){
				display_string("No such process\n");
			} else{
				display_string("the process with name=");
				display_string(CMD[1]);
				display_string(" was stopped\n");
			}
		}
	} else if (strcmp(CMD[0],"setp")==0){
		if (total<3 || !is_number(CMD[2])){
			display_string("Usage: setp <name> <num>\n");
		} else if (setp(CMD[1],atoi(CMD[2]))==-1){
			display_string("i can't set the priority of ");
			display_string(CMD[1]);
			display_string("\n");
		} else {
			display_string("set priority successful\n");
		}
	} else if (strcmp(CMD[0],"ps")==0){
		if (show_tasks(CMD[1])==-1){
			display_string("I can't recognize the parameter\n");
		}
	} else if (strcmp(CMD[0],"ls")==0){
		ls();
	} else if (strcmp(CMD[0],"rm")==0){
		if (total<2){
			display_string("Usage: rm <filename>\n");
		} else{
			if (rm(CMD[1])==-1){
				display_string(CMD[1]); 
				display_string(" no exist!\n");
			}
		}
	} else if (strcmp(CMD[0],"help")==0){
		show_help();
	} else if (strcmp(CMD[0],"edit")==0){
		if (total==1){
			display_string("Usage: edit <filename>\n");
		} else start_editor(CMD[1]);
	} else if (strcmp(CMD[0],"dump")==0){
		if (dump_mem(CMD[1],CMD[2])==-1){
			display_string("I can't recognize the parameter\n");
		}
	} else{
		display_string(cmd); display_string(": ");
		display_string("no such command\n");
	}
}
Beispiel #7
0
int main(int argc, char **argv) {
	int ret;
	char strbuf[256];
	
	allegro_init();
	
	set_color_depth(24);
	if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Allegro says: %s\n", allegro_error);
		return 1;
	}

	install_timer();
	install_keyboard();
	install_mouse();
	if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL)==-1) printf("No sounds avaible.\n");
	graph_init();

	srand(time(0));

	set_keyboard_rate(100, 150);
	gui_bg_color = colors[gray];
	gui_fg_color = colors[black];

	LOCK_VARIABLE(counter);
	LOCK_FUNCTION(game_timer);
	install_int_ex(game_timer, BPS_TO_TIMER(6));
	
	if (argv[0][0]!='\0') {
		char *path;

		for (path=argv[0]; *path; path++) /* nothing */;
		if (path!=argv[0]) {
			for (;*path!='/' && path>=argv[0]; path--);
			path++;
			*path = '\0';
			chdir(argv[0]);
		}
	}
	
	if ((datafile = load_datafile("data.dat"))==NULL) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Datafile data.dat not found\n");
		return 1;
	}
	
	font = datafile[DATA_FONT].dat;
	gui_font_baseline = 1;

	main_dialog[0].bg = colors[darkgray];
	main_dialog[1].dp = datafile[DATA_SCREEN].dat;
	main_dialog[2].dp = datafile[DATA_LOGO].dat;

	for (ret=1; main_dialog[ret].proc; ret++) {
		main_dialog[ret].fg = colors[black];
		main_dialog[ret].bg = colors[gray];
	}
	
	while(1) {
		text_mode(-1);

		switch (do_dialog(main_dialog, -1)) {
		case DMAIN_START:
			ret = start_game();
		
			if (ret==GAME_ABORT) break;

			if (ret==GAME_END) {
				int i;
				ret=0;
				for (i=1; i<8; i++) if (players[i].points > players[ret].points) ret = i;
			}
			scare_mouse();
			clear_to_color(screen, colors[darkgray]);
			unscare_mouse();

			sprintf(strbuf, "The winner is %s!!!", players[ret].name);
			alert("GAME OVER", strbuf, NULL, "OK", NULL, 0, 0);

			report();
			break;
		case DMAIN_EDIT:
			start_editor();
			break;
		case DMAIN_EXIT:
			remove_sound();
			return 0;
		}
	}
	return 0;
}