/* init: init's the element lists and allegro, returns 0 upon success * and non-zero otherwise */ int init(void) { /* init allegro */ if (allegro_init() != 0) { printf("failed to initialize..."); return 1; } set_color_depth(GFX_DEPTH); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, EDITOR_WIN_W, EDITOR_WIN_H, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Failed to init a gfxmode."); return 1; } set_window_title("GUNPOWDER MapEditor"); install_keyboard(); install_mouse(); show_mouse(screen); vscreen = create_bitmap(EDITOR_WIN_W, EDITOR_WIN_H); if (!vscreen) { close_program = 1; } /* init our lists */ load_tiles(); load_sprites(); return 0; }
int onImport_Tiles() { int ret=getnumber("Import Start Page",0); if(cancelgetnum) { return D_O_K; } bound(ret,0,TILE_PAGES-1); if(!getname("Import Tiles (.til)","til",NULL,datapath,false)) return D_O_K; saved=false; // usetiles=true; if(!load_tiles(temppath, ret*TILES_PER_PAGE)) { char buf[80],name[13]; extract_name(temppath,name,FILENAME8_3); sprintf(buf,"Unable to load %s",name); jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,lfont); } refresh(rALL); return D_O_K; }
int main (int argc, char* argv []) { load_pal (argv [1]); load_tiles (argv [2]); FILE* f = fopen (argv [3], "rb"); int k = 0; while (!feof (f)) { load_level (f, k++); } fclose (f); std::cout << k << " levels loaded" << std::endl; return 0; }
void main() { char buf[100]; aplib_depack(testtxt_apk, buf); set_vdp_reg(VDP_REG_FLAGS1, VDP_REG_FLAGS1_SCREEN); load_tiles(standard_font, 0, 255, 1); load_palette(pal1, 0, 16); load_palette(pal2, 16, 16); printf(buf); for (;;) { wait_vblank_noint(); } }
void main() { int y = 0; clear_vram(); load_tiles(standard_font, 0, 255, 1); load_palette(pal1, 0, 16); load_palette(pal2, 16, 16); set_vdp_reg(VDP_REG_FLAGS1, VDP_REG_FLAGS1_BIT7 | VDP_REG_FLAGS1_SCREEN); printf("Hello, stdio!\nIs it working?\nI hope so."); gotoxy(5, 5); printf("Hello, gotoxy(%d, %d)!", 5, 5); for (;;) { wait_vblank_noint(); } }
QcFileTileCache::QcFileTileCache(const QString & directory) : QObject(), m_offline_cache(nullptr), m_directory(directory), m_min_texture_usage(0), m_extra_texture_usage(0) { const QString base_path = base_cache_directory(); if (m_directory.isEmpty()) { m_directory = base_path; } QDir::root().mkpath(m_directory); // default values set_max_disk_usage(MAX_DISK_USAGE); set_max_memory_usage(MAX_MEMORY_USAGE); set_extra_texture_usage(EXTRA_TEXTURE_USAGE); load_tiles(); QString offline_cache_directory = m_directory + QDir::separator() + QLatin1Literal("offline"); m_offline_cache = new QcOfflineTileCache(offline_cache_directory); }
/* initialize, screen, windows */ void initgraf(void) { int i; #ifdef USE_OPCURSES load_tiles(); #endif initscr(); #if !defined(MSDOS_SUPPORTED_ANTIQUE) start_color(); # ifndef AMIGA clrgen_init(); # endif #endif if (LINES < 24 || COLS < 80) { printf("Minimum Screen Size: 24 Lines by 80 Columns."); exit(0); } #ifdef AMIGA init_color(1, 800, 800, 800); /* white */ init_color(2, 644, 164, 164); /* brown */ init_color(3, 800, 800, 0); /* yellow */ init_color(4, 200, 200, 200); /* grey */ init_color(5, 0, 1000, 0); /* green */ init_color(6, 0, 0, 1000); /* blue */ init_color(7, 1000, 0, 0); /* red */ LINES -= 2; /* ugly, but neccessary with this curses package... */ #endif ScreenLength = LINES - 6; ScreenWidth = 64; /* PGM */ Msg1w = newwin(1,80,0,0); scrollok(Msg1w, 0); /* DJGPP curses defaults to scrollable new windows */ Msg2w = newwin(1,80,1,0); scrollok(Msg2w, 0); Msg3w = newwin(1,80,2,0); scrollok(Msg3w, 0); Msgw = Msg1w; Morew = newwin(1,15,3,65); scrollok(Morew, 0); #ifdef NEW_BANK Bankw = newwin( 20, 50, ( ScreenLength - 20 ) / 2 + 3, 7 ); scrollok( Bankw, 0 ); #endif Locw = newwin(1,80,ScreenLength+3,0); scrollok(Locw, 0); Levelw = newwin(ScreenLength,ScreenWidth,3,0); scrollok(Levelw, 0); for(i=0;i<MAXITEMS;i++) { Showline[i] = newwin(1,ScreenWidth,i+3,0); scrollok(Showline[i], 0); wclear(Showline[i]); } Menuw = newwin(ScreenLength,ScreenWidth,3,0); scrollok(Menuw, 0); Dataw = newwin(2,80,ScreenLength+4,0); scrollok(Dataw, 0); Timew = newwin(2,15,4,65); scrollok(Timew, 0); Phasew = newwin(2,15,6,65); scrollok(Phasew, 0); Flagw = newwin(4,15,9,65); scrollok(Flagw, 0); Comwin = newwin(8,15,14,65); scrollok(Comwin, 0); Cinema = newwin(3,80,0,0); /* the same position and size as the three * message windows. */ scrollok(Cinema,0); noecho(); crmode(); clear(); touchwin(stdscr); /* omega_title();*/ /* clear();*/ /* touchwin(stdscr);*/ /* refresh();*/ /* DG */ }
Engine* engine_init_level (Context* context) { Engine* engine = (Engine*) malloc(sizeof(Engine)); engine->context = context; engine->tiles = load_tiles(context); int h, w, i; h = context->video[0]->head->v->bitmap->h; w = context->video[0]->head->v->bitmap->w; engine->partition_len = ceil((((double) w) / BOX_SIZE)) * ceil((((double) h) / BOX_SIZE)); engine->partitions = (Node**) malloc(engine->partition_len * sizeof(Node*)); memset(engine->partitions, 0, engine->partition_len * sizeof(Node*)); engine->flash_anims = linked_list_init(); for (i = 0; i < engine->partition_len; i++) { engine->partitions[i] = linked_list_init(); } engine->max_h = h; engine->max_w = w; // Clear any and all vertexes left on the screen (including the background) clear_buffers(context); engine->loading_bufs = engine_create_loading(context, h, w); engine_init_bg(engine, h, w); engine_inc_loading(engine); engine->explosion = engine_load_explosion(context, engine); engine->explosions = linked_list_init(); engine->explo_field = 0; engine->tbl_count = 0; engine->player_tbl = (Player**) malloc(TBL_MAX * sizeof(Player*)); engine->player = engine_load_player( context , engine , "ship" , w / 2 , h - SCREEN_TOP ); engine_inc_loading(engine); engine->shot_bufs = engine_init_shots(context, engine, h); engine->shot_field = 0ULL; engine->enemy_sprites = engine_load_enemies(context, engine); engine->shield_bufs = engine_init_shield(context, engine); engine->score_bufs = engine_init_score(context, h); engine->enemies = (Player**) malloc(MAX_ENEMIES * sizeof(Player*)); memset(engine->enemies, 0, MAX_ENEMIES * sizeof(Player*)); engine->enemy_field = 0; context->game_state = TYRIAN_GAME_LEVEL; engine_clear_loading(context, engine); #if DEBUG vertex* v; fps = (vertex_buffer**) malloc(6 * sizeof(vertex_buffer*)); char str[7] = "FPS 00"; for (i = 0; i < 6; i++) { v = vertex_create( w - GLYPH_SIZE * (6 - i) , SCREEN_TOP , context->glyphs->map[char2index(str[i])] ); context->video[1] = vertex_buffer_push(context->video[1], v); fps[i] = context->video[1]->prev; } #endif return engine; }
void main() { int x = 0; int y = 0; int i, j; int ply_x = 120; int ply_y = 92; int ply_tile = 'H'; int ply2_x = 120; int ply2_y = 100; int ply2_tile = 'H'; int raster[10], speeds[10], *p, *p2; char *c; for (y = 2; y < 22; y += 2) { for (x = 0; x != 32; x += 2) { set_bkg_map(road_pattern, x, y, 2, 2); } for (x = 0; x != 32; x += 4) { if (y < 12) { set_bkg_map(car1_map_r, x, y+1, 2, 1); } else { set_bkg_map(car1_map_l, x, y+1, 2, 1); } } } for (x = 0; x != 32; x ++) { set_bkg_map(top_sidewalk_pattern, x, 0, 1, 3); set_bkg_map(bottom_sidewalk_pattern, x, 22, 1, 3); set_bkg_map(central_strip_pattern, x, 12, 1, 1); } for (i = 0, p2 = speeds; i != 5; i++, p2++) { (*p2) = rand_speed(); } for (i = 0; i != 5; i++, p2++) { (*p2) = -rand_speed(); } set_vdp_reg(VDP_REG_FLAGS1, VDP_REG_FLAGS1_SCREEN); load_tiles(chicken_graphics, 0, 255, 4); load_palette(pal1, 0, 16); load_palette(pal2, 16, 16); // add_pause_int(pause_handler); for (;;) { p = raster; p2 = speeds; j = 0; x = 1; y = 16; while (get_vcount() != 0) { } x = (*p) >> 4; while (y < 176) { while (get_vcount() < y) { } if (j & 0x01) { load_palette(pal1, 0, 16); } else { load_palette(pal2, 0, 16); } scroll_bkg(x, y); (*p) += (*p2); p++; p2++; x = (*p) >> 4; y += 14; j++; while (get_vcount() < y) { } scroll_bkg(0, 0); y += 2; } load_palette(pal1, 0, 16); scroll_bkg(0, 0); wait_vblank_noint(); } }
Font::Font(const char *filename, int width, int height, rgb_color_t color, int useWhite) { rgb_color_t yellow; rgb_color_t white; rgb_color_t magenta; rgb_color_t black; yellow.r = 255; yellow.g = 255; yellow.b = 0; yellow.a = 0; white.r = 255; white.g = 255; white.b = 255; white.a = 0; magenta.r = 255; magenta.g = 0; magenta.b = 255; magenta.a = 0; black.r = 0; black.g = 0; black.b = 0; black.a = 0; memset(charwidth, 0, CHARCOUNT * sizeof(*charwidth)); font = load_tiles(filename, CHARCOUNT, width, height, 0, 0); if (font != NULL) { int i; for (i = 0; i < CHARCOUNT; i++) { int x; int y; if (font[i].b != NULL) { for(x = 0; x < font[i].w; x++) { color_type_t *c; c = (color_type_t *) &font[i].b[getGraphicOffset(x, 0, font[i].w)]; if (colorCmp(*c, yellow) || (useWhite && (colorCmp(*c, white)))) { charwidth[i] = x; //printf("Char %d width %d.\n", i, x); break; } } for(y = 0; y < font[i].h; y++) { for(x = 0; x < font[i].w; x++) { color_type_t *c; c = (color_type_t *) &font[i].b[getGraphicOffset(x, y, font[i].w)]; if (colorCmp(*c, yellow) || colorCmp(*c, magenta) || (x >= charwidth[i])) { *c = getNativeColor(black); } else { if (colorCmp(*c, white)) { *c = getNativeColor(color); } } } } } else printf("Char: %d is NULL\n", i); charwidth[i] = charwidth[i] * FONT_ZOOM_FACTOR; } } else printf("Failed to load font.\n"); }