Esempio n. 1
0
void game_mesh::draw_pivot(void)
{  
  GRAPH3D *p_graph = scene_get()->graph_get();
  VECT     pivot;
  if(p_geom && p_graph) {
    p_geom->pivot_get(&pivot);
    p_graph->draw_cross(&pivot, 1.0f);
  }
}
Esempio n. 2
0
// ********************************
// Whole game mesh
// ********************************
void game_mesh::draw_world_set(void)
{
  SCENE *p_scene = scene_get();
  if(p_scene) {
    GPIPE *p_gpipe = p_scene->gpipe_get();
    assert(p_gpipe);
    p_gpipe->world_set(world_global_get());
  }
}
Esempio n. 3
0
File: block.c Progetto: rvba/minuit
void block_bricks_free(t_block *block)
{
	t_scene *sc = scene_get();

	t_link *l;
	t_brick *b;

	for(l=block->bricks->first;l;l=l->next)
	{
		b=l->data;
		b->cls->disconnect( b);
		scene_delete(sc,b);
	}
}
Esempio n. 4
0
void add_exe_remove_brick(t_brick *brick)
{
	t_scene *sc = scene_get();
	scene_store( sc, 1);
	t_action *action = action_new("action");

	action->act = exe_remove_brick;

	t_dict *dict = dict_make("args");
	action->args = dict;
	action->brick = brick;

	dict_symbol_add(action->args,"brick",dt_null,brick);

	exe_add_action(action);

	scene_store( sc, 0);
}
Esempio n. 5
0
void add_exe_add_brick(t_brick *brick,t_brick *brick_target,void (* f)(t_action *))
{
	t_scene *sc = scene_get();
	scene_store( sc, 1);
	t_action *action = action_new("action");

	action->act = f;

	t_dict *dict = dict_make("args");
	action->args = dict;
	action->brick = brick;

	dict_symbol_add(action->args,"brick",dt_null,brick);
	dict_symbol_add(action->args,"target",dt_null,brick_target);

	exe_add_action(action);

	scene_store( sc, 0);
}
Esempio n. 6
0
File: block.c Progetto: rvba/minuit
void block_free( t_block *block)
{
	t_scene *sc = scene_get();

	if( block->set)
	{
		if( block->clone)
		{
			t_block *block_parent = block->clone;
			block_parent->clones -= 1;
		}

		list_remove_by_ptr(block->set->blocks,block);
	}

	// free bricks
	block_bricks_free( block);

	if( block->rhizome) rhizome_block_remove( block->rhizome, block);

	// free lst
	scene_delete( sc, block->bricks);
}
Esempio n. 7
0
GAME * game_init ()
{
    if (!al_init ()) {
        fprintf (stderr, "Failed to initialize Allegro.\n");
        return NULL;
    }

    if (!al_init_image_addon ()) {
        fprintf (stderr, "Failed to initialize image addon.\n");
        return NULL;
    }

    if (!al_install_keyboard ()) {
        fprintf (stderr, "Failed to install keyboard.\n");
        return NULL;
    }

    al_init_font_addon ();

    if (!al_init_ttf_addon ()) {
        fprintf (stderr, "Failed to initialize ttf addon.\n");
        return NULL;
    }

    if (!al_init_primitives_addon ()) {
        fprintf (stderr, "Failed to initialize primitives addon.\n");
        return NULL;
    }

    GAME *game = al_malloc (sizeof (GAME));
    if (!game)
        return NULL;

    srand (time (NULL));

    game->running = true;
    game->paused = false;

    game->fullscreen = 1;
    game->windowed = 1;
    game->rrate = 60;
    game->suggest_vsync = 1;
    game->force_vsync = 0;

    game->current_npc = NULL;

    game->screen = screen_new ();

    char *filename;
    const char *str;

    filename = get_resource_path_str ("data/game.ini");
    ALLEGRO_CONFIG *game_config = al_load_config_file (filename);
    al_free (filename);

    str = al_get_config_value (game_config, "", "org");
    al_set_org_name (str);
    str = al_get_config_value (game_config, "", "app");
    al_set_app_name (str);

    ALLEGRO_PATH *settpath = al_get_standard_path (ALLEGRO_USER_SETTINGS_PATH);
    ALLEGRO_PATH *gcpath = al_clone_path (settpath);

    al_set_path_filename (gcpath, "general.ini");
    const char * gcpath_str = al_path_cstr (gcpath, ALLEGRO_NATIVE_PATH_SEP);

    ALLEGRO_CONFIG *gconfig = al_load_config_file (gcpath_str);

    if (!gconfig) {
        gconfig = al_create_config ();
        al_make_directory (al_path_cstr (settpath, ALLEGRO_NATIVE_PATH_SEP));

        set_config_i (gconfig, "display", "width", game->screen.width);
        set_config_i (gconfig, "display", "height", game->screen.height);
        set_config_i (gconfig, "display", "fullscreen", game->fullscreen);
        set_config_i (gconfig, "display", "windowed", game->windowed);
        set_config_i (gconfig, "display", "refreshrate", game->rrate);
        set_config_i (gconfig, "display", "suggest_vsync", game->suggest_vsync);
        set_config_i (gconfig, "display", "force_vsync", game->force_vsync);
    } else {
        get_config_i (gconfig, "display", "width", &game->screen.width);
        get_config_i (gconfig, "display", "height", &game->screen.height);
        get_config_i (gconfig, "display", "fullscreen", &game->fullscreen);
        get_config_i (gconfig, "display", "windowed", &game->windowed);
        get_config_i (gconfig, "display", "refreshrate", &game->rrate);
        get_config_i (gconfig, "display", "suggest_vsync", &game->suggest_vsync);
        get_config_i (gconfig, "display", "force_vsync", &game->force_vsync);
    }

    al_save_config_file (gcpath_str, gconfig);

    al_destroy_path (settpath);
    al_destroy_path (gcpath);
    al_destroy_config (gconfig);

    int flags = 0;

    if (game->fullscreen == game->windowed)
        flags |= ALLEGRO_FULLSCREEN_WINDOW;
    else if (game->fullscreen)
        flags |= ALLEGRO_FULLSCREEN;
    else
        flags |= ALLEGRO_WINDOWED;

    al_set_new_display_option (ALLEGRO_VSYNC, game->suggest_vsync, ALLEGRO_SUGGEST);
    al_set_new_display_option (ALLEGRO_DEPTH_SIZE, 8, ALLEGRO_SUGGEST);

    al_set_new_display_flags (flags);
    al_set_new_display_refresh_rate (game->rrate);
    game->display = al_create_display (game->screen.width, game->screen.height);
    if (!game->display) {
        fprintf (stderr, "Failed to create display.\n");
        al_free (game);
        return NULL;
    }

    al_set_new_bitmap_flags (ALLEGRO_VIDEO_BITMAP);

    game->timer = al_create_timer (1.0 / FPS);
    if (!game->timer) {
        fprintf (stderr, "Failed to create timer.\n");
        al_free (game);
        return NULL;
    }

    game->screen.width = al_get_display_width (game->display);
    game->screen.height = al_get_display_height (game->display);
    screen_update_size (&game->screen, game->screen.width, game->screen.height);

    game->rrate = al_get_display_refresh_rate (game->display);

    game->event_queue = al_create_event_queue ();
    if (!game->event_queue) {
        fprintf (stderr, "Failed to create event queue.\n");
        al_free (game);
        return NULL;
    }

    al_register_event_source (game->event_queue, al_get_display_event_source (game->display));
    al_register_event_source (game->event_queue, al_get_timer_event_source (game->timer));

    al_set_render_state (ALLEGRO_ALPHA_FUNCTION, ALLEGRO_RENDER_EQUAL);
    al_set_render_state (ALLEGRO_ALPHA_TEST_VALUE, 1);

    filename = get_resource_path_str ("data/sprites.ini");
    game->sprites = sprite_load_sprites (filename);
    al_free (filename);

    filename = get_resource_path_str ("data/scenes.ini");
    game->scenes = scene_load_file (filename);
    scene_load_scenes (game->scenes, game->sprites);
    al_free (filename);

    str = al_get_config_value (game_config, "", "scene");
    game->current_scene = scene_get (game->scenes, str);

    str = al_get_config_value (game_config, "", "actor");
    game->current_actor = sprite_new_actor (game->sprites, str);
    str = al_get_config_value (game_config, "", "portal");
    SCENE_PORTAL *portal = scene_get_portal (game->scenes, str);

    al_destroy_config (game_config);

    filename = get_resource_path_str ("data/ui.ini");
    game->ui = ui_load_file (filename);
    al_free (filename);

    sprite_center (game->current_actor, &portal->position);
    screen_center (&game->screen, portal->position, game->current_scene->map);

    return game;
}
Esempio n. 8
0
void game_mesh::mesh_remove(void)
{
  SCENE *p_scene = scene_get();
  assert(p_scene != NULL);
  p_scene->mesh_remove(this);
}