Ejemplo n.º 1
0
void scene_load(void)
{
	load_bitmaps();
	scene.realImages = 0;
	scene.camera = camera_create();
	scene.octree = octree_init(input_path_concat("galaxies.txt"), 20000);
	scene.galaxies = galaxylist_create();
}
Ejemplo n.º 2
0
//initialize SDL and game window
void init(Surface& images, Font& fonts)
{
    //initialize SDL, the window, and fonting
    SDL_Init(SDL_INIT_EVERYTHING);   
    SDL_WM_SetCaption("Dungeon Epic", NULL);  
	TTF_Init();
	//initialize the video buffer in the window   
       
    images.buffer = SDL_SetVideoMode (SCRWIDTH,SCRHEIGHT, SCRBPP,SDL_HWSURFACE); 
     
    //load graphics
    
    //images.spritesheet = load_bitmaps("data/images/.jpg"); 
    
    images.background = load_bitmaps("data/images/gothic.jpg"); 
    images.playersheet = load_bitmaps("data/images/player.png");
    
    //load fonts
    fonts.font1 = load_font("data/fonts/NotCourierSans.otf", 18);
    
    return;
}
Ejemplo n.º 3
0
static void instruction_menu_window_load(Window *window) {
  load_bitmaps();

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  s_instruction_menu = menu_layer_create(bounds);

  menu_layer_set_callbacks(s_instruction_menu, NULL, (MenuLayerCallbacks){
    .get_num_sections = menu_get_num_sections_callback,
    .get_num_rows = menu_get_num_rows_callback,
    .get_header_height = menu_get_header_height_callback,
    .get_cell_height = menu_get_cell_height_callback,
    .draw_header = NULL,
    .draw_row = menu_draw_row_callback,
    .select_click = menu_select_callback,
  });
Ejemplo n.º 4
0
int main()
{
    //shell vars
    bool render = false;

    //allegro vars
    ALLEGRO_DISPLAY *display = NULL;
    ALLEGRO_EVENT_QUEUE *event_queue = NULL;
    ALLEGRO_TIMER *timer = NULL;

    //allegro init functions
    printf ("Initializing allegro\n");
    if (!al_init())
    {
        al_show_native_message_box(NULL, NULL, NULL, "failed", NULL, 0);
        return -1;
    }

    printf("Creating display\n");
    display = al_create_display(WIDTH, HEIGHT);
    if (!display)
    {
        al_show_native_message_box(NULL, NULL, NULL, "failed", NULL, 0);
        return -1;
    }

    printf("Installing addons\n");
    al_init_font_addon();
    al_init_ttf_addon();
    al_init_primitives_addon();
    al_init_image_addon();
    al_install_keyboard();
    al_install_mouse();
    al_install_audio();
    al_init_acodec_addon();
    al_reserve_samples(10);

    //project inits
    srand(time(NULL));

    printf("Initializing timer\n");
    event_queue = al_create_event_queue();
    timer = al_create_timer(1.0 / FPS);

    printf("Registering event sources\n");
    al_register_event_source(event_queue, al_get_display_event_source(display));
    al_register_event_source(event_queue, al_get_keyboard_event_source());
    al_register_event_source(event_queue, al_get_timer_event_source(timer));
    al_start_timer(timer);

    printf("Init mouse and keyboard\n");
    init_keyboard();
    init_mouse();

    printf("Loading assets\n");
    load_bitmaps();
    load_fonts();
    load_samples();

    printf ("Creating manager\n");
    push_state(new TitleMenu());
    
    printf("Beginning game\n");
    while (!is_game_over())
    {
        //declare an event
        ALLEGRO_EVENT event;

        //monitor event sources
        al_wait_for_event(event_queue, &event);
        if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
        {
            end_game();
        }
        else if (event.type == ALLEGRO_EVENT_TIMER)
        {
            render = true;

            update_mouse();
            update_keyboard();

            handle_key();
            update_game();
        }

        // Render screen
        if (render && al_event_queue_is_empty(event_queue))
        {
            render = false;
            render_game();
            al_flip_display();
        }
    }

    unload_assets();
    al_destroy_event_queue(event_queue);
    al_destroy_display(display);
    al_destroy_timer(timer);

    return 0;
}
Ejemplo n.º 5
0
void loadmap(Zone& area, Map& level, Player& player1, Surface& images)
{ 
    int mapnum, floornum;
    bool stairs;
    int playx,playy;
    //load world and set initial values the first time through
    if (player1.get_map() == -1) {
        
        srand(time(NULL));
        mapnum = area.get_id();          
        floornum = 0;  
        area.init();
        level = area.zones[mapnum].floors[floornum]; 
        playx = level.get_begin_x() * TILEW;
        playy = level.get_begin_y() * TILEH;      
        player1.put_stairs(1);          
    }    
    //load a new map if the player has changed maps midplay
    if (player1.get_map() >= 0) {
        mapnum = player1.get_destmap();
        floornum = player1.get_destfloor();
        if (floornum < 0) {
            floornum = 0;
            player1.put_stairs(1);   
            mapnum = area.get_id(); 
            playx = area.zones[player1.get_map()].get_x() * TILEW;
            playy = (area.zones[player1.get_map()].get_y() + 1) * TILEH;
        }        
        area.zones[player1.get_map()].floors[player1.get_floor()] = level; 
    }
    
    level = area.zones[mapnum].floors[floornum]; 
    level.set_rendered(0); //area is not yet rendered for graphics
    if (area.zones[mapnum].floors[floornum].get_type() == TOWN){
        playx = MAPW / 2 * TILEW;
        playy = (MAPH - 2) * TILEH;
    }
    if (area.zones[mapnum].floors[floornum].get_type() == DUNGEON){    
        stairs = player1.get_stairs();
        if (stairs == 0) {
            playx = level.get_end_x() * TILEW;
            playy = level.get_end_y() * TILEH;
        }
        if (stairs == 1) {
            playx = level.get_begin_x() * TILEW;
            playy = level.get_begin_y() * TILEH;
        }    
    }
    player1.put_coor(playx, playy);    
    player1.put_map(mapnum);
    player1.put_floor(floornum);
    
    
    //load appropriate spritesheet for this kind of level
    switch(level.get_type())
    {
        case DUNGEON:
            images.tilesheet = load_bitmaps("data/images/dungeon.jpg");
            break;
        case TOWN:
            images.tilesheet = load_bitmaps("data/images/town.jpg");
            break;
        case FOREST:
            images.tilesheet = load_bitmaps("data/images/forest.jpg");
            break;
    }    
};