示例#1
0
文件: pacman.c 项目: neiderm/turaco
void Maped_Info_PacMan(int mode)
{
#if 0
    char text[80];
    int max;
#ifdef SNOOP_ENABLE
    struct ROMDATA * rd = Driver.RomData;
#endif

    sprintf(text, "Size %04x", Maped_TotalMap_PacMan());
    if (Maped_TotalMap_PacMan() > 0x17d)
	textout(screen, font, text, SCREEN_W - 90, 40, PAL_RED);
    else
	textout(screen, font, text, SCREEN_W - 90, 40, PAL_GREEN);

    max = Driver.RomData->MapData[mapno].OverlayCount;
    sprintf(text, "#p %3d/%3d", Maped_TotalOverlay_PacMan(), max);

    if (Maped_TotalOverlay_PacMan() != max)
	textout(screen, font, text, SCREEN_W - 90, 50, PAL_RED);
    else
	textout(screen, font, text, SCREEN_W - 90, 50, PAL_GREEN);

#ifdef SNOOP_ENABLE
    sprintf(text, "O %08lx", snoop_offset);
    textout(screen, font, text, SCREEN_W - 90, 60, PAL_GREY);

    sprintf(text, "T %08lx", snoop_offset + rd->MapData[mapno].StartAddress);
    textout(screen, font, text, SCREEN_W - 90, 70, PAL_GREY);
#endif

    if (mode == MODE_EDIT)
	textout(screen, font, "M: Map Edit", SCREEN_W - 90, 95, PAL_YELLOW);
    else
	textout(screen, font, "M: Tile Sel", SCREEN_W - 90, 95, PAL_GREEN);

    sprintf(text, " 0x%02x ", GetTileUnderCursor());
    textout_centre(screen, font, text, SCREEN_W - 45, 105, PAL_LTGREY);
#endif
}
示例#2
0
void TextList::subanimate()
{
	STACKTRACE;

	if (!optionlist || N == 0)
		return;					 // if it's an empty list

	int ix, iy;
	int i;

	// check if there's need for shifting the list, i.e., if the scroll is off
	// the map:

	// note, a positive "shift" means, a number of items are skipped at the top,
	// when drawing them:

	// else, do nothing ;)					// selected item is somewhere in the middle.

	for ( i = scroll.y; i < N; ++i ) {
		if (i > scroll.y + scroll.Nyshow)
			break;

		ix = 0;
		iy = Htxt * (i - scroll.y);

		int c;

		if ( i != scroll.yselect ) {
			text_mode(-1);
			c = text_color;
		} else {
			text_mode( makecol(0,0,0) );
			//c = makecol(255,255,255);
			c = text_color;
		}

		if (optionlist[i])		 // && strlen(optionlist[i]) < 20)
			textout(drawarea, usefont, optionlist[i], ix, iy, c);
	}

}
void Draw(int cycles, int currtour, int besttour) {

	/////////////////////////////////////////////////////////////////////////////////////////////
	// draw a graph (drawing towns and paths is too hard with the current system of random distances)
	// is graph of tour length at each step as well as the current best tour length
	//
	// One important thing with draw() is that it takes the current and best tour lengths and divides them
	// by the number of towns.. this is so that no matter how many towns there are, it wont draw off the screen
	// unless the MAX_DISTANCE is set over 500
	//
	/////////////////////////////////////////////////////////////////////////////////////////////
	acquire_screen();
	
	//graph axis
	vline(screen, 40, 40, SCREEN_H-40, makecol(255,255,255));
	hline(screen, 40, 440, SCREEN_W-40, makecol(255,255,255));
	
	//graph axis text
	textout_centre(screen,font,"CYCLES",SCREEN_W/2, SCREEN_H-20,makecol(0,200,200));
	textout(screen,font,"DISTANCE",1, SCREEN_H/2,makecol(0,200,200));

	//graph legend
	rectfill(screen, SCREEN_W-200, 20, SCREEN_W-170, 40, makecol(0,200,200));
	textprintf(screen,font,SCREEN_W-160, 30,makecol(255,255,255),"Current Tour");
	rectfill(screen, SCREEN_W-200, 50, SCREEN_W-170, 70, makecol(255,0,0));
	textprintf(screen,font,SCREEN_W-160, 60,makecol(255,255,255),"Best Tour");
	
	//draw current cycles distance
	vline(screen,cycles+41,SCREEN_H-40,(SCREEN_H-40)-(currtour/NUM_TOWNS),makecol(0,200,200));
	vline(screen,cycles+41,SCREEN_H-40,(SCREEN_H-40)-(besttour/NUM_TOWNS),makecol(255,0,0));
	

	release_screen();

	
}
示例#4
0
文件: aphoton.c 项目: Fomka/ufo2000
int d_aphoton_list_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
	int height, listsize, i, len, bar, x, y, w, char_height;
	int fg, bg;
	char *sel = (char *)d->dp2;
	char s[1024];
	int rtm;

	(*(getfuncptr)d->dp)(-1, &listsize);
	char_height = text_height(font);
	height = (d->h-4) / char_height;
	bar = (listsize > height);
	w = (bar ? d->w-14 : d->w-3);

	/* draw box contents */
	for (i=0; i<height; i++) {
	    if (d->d2+i < listsize) {
		if (d->d2+i == d->d1) {
		    fg = list_white;
		    bg = list_green;
		}
		else if ((sel) && (sel[d->d2+i])) {
		    fg = list_white;
		    bg = list_green;
		}
		else {
		    fg = black;
		    bg = list_white;
		}
		
		ustrzcpy(s, sizeof(s), (*(getfuncptr)d->dp)(i+d->d2, NULL));
		
		x = d->x + 2;
		y = d->y + 2 + i*char_height;
		
		rtm = text_mode(bg);
		rectfill(screen, x, y, x+7, y+char_height-1, bg);
		x += 8;
		
		len = ustrlen(s);
		while (text_length(font, s) >= MAX(d->w - 1 - (bar ? 22 : 10), 1)) {
		    len--;
		    usetat(s, len, 0);
		}
		
		textout(screen, font, s, x, y, fg);
		text_mode(rtm);
		
		x += text_length(font, s);
		if (x <= d->x+w)
		    rectfill(screen, x, y, d->x+w, y+char_height-1, bg);
	    }
	    else {
		rectfill(screen, d->x+2,  d->y+2+i*char_height,
			 d->x+w, d->y+1+(i+1)*char_height, list_white);
	    }
	}

	if (d->y+2+i*char_height <= d->y+d->h-3)
	    rectfill(screen, d->x+2, d->y+2+i*char_height,
		     d->x+w, d->y+d->h-3, list_white);

	/* draw frame, maybe with scrollbar */
	photon_draw_scrollable_frame(d, listsize, d->d2, height);

	return D_O_K;
    }

    return d_list_proc(msg, d, c);
}
示例#5
0
文件: aphoton.c 项目: Fomka/ufo2000
int d_aphoton_edit_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
	int l, x, b, f, p, w, rtm;
	int fg = (d->flags & D_DISABLED) ? shadow : black;
	char *s = (char *)d->dp;
	char buf[16];
	int fonth;

        agup_edit_adjust_position (d);
	
	fonth = text_height(font);
	
	l = ustrlen(s);
	/* set cursor pos */
	if (d->d2 >= l) {
	    d->d2 = l;
	    usetc(buf+usetc(buf, ' '), 0);
	    x = text_length(font, buf) + 2;
	}
	else
	    x = 2;
	
	b = 0;	  /* num of chars to be blitted */
	/* get the part of the string to be blitted */
	for (p = d->d2; p >= 0; p--) {
	    usetc(buf+usetc(buf, ugetat(s, p)), 0);
	    x += text_length(font, buf);
	    b++;
	    if (x > d->w-4)
		break;
	}

	/* see if length of text is too wide */
	if (x <= d->w-2) {
	    b = l; 
	    p = 0;
	}
	else {
	    b--;
	    p = d->d2-b+1; 
	    b = d->d2; 
	}

	photon_box(screen, d->x, d->y, d->w, fonth+8, edit_white);
	hline(screen, d->x+2, d->y+2, d->x+d->w-3, edit_gray);
	vline(screen, d->x+2, d->y+2, d->y+fonth+5, edit_gray);

	for (x = 4; p<=b; p++) {
	    f = ugetat(s, p);
	    usetc(buf+usetc(buf, (f) ? f : ' '), 0);
	    w = text_length(font, buf);
	    f = ((p == d->d2) && (d->flags & D_GOTFOCUS));
	    rtm = text_mode(edit_white);
	    textout(screen, font, buf, d->x+x, d->y+4, fg);
	    text_mode(rtm);
	    if (f)
		vline(screen, d->x+x-1, d->y+3, d->y+fonth+5, black);
	    if ((x += w) + w > d->w - 4)
		break;
	}

        if (d->flags & D_GOTFOCUS)
            hline(screen, d->x+4, d->y+fonth+4, d->x+d->w-5, highlight);

        agup_edit_restore_position (d);

	return D_O_K;
    }

    return d_agup_adjusted_edit_proc(msg, d, c);
}
示例#6
0
文件: editor.cpp 项目: Fomka/ufo2000
// See also: Inventory::draw(), Soldier::draw_inventory()
// Called by: Connect::do_planner() via Units::execute and execute_main()
void Editor::show()
{
    reset_video();
    destroy_bitmap(screen2);
    screen2 = create_bitmap(640, 400); 
    clear(screen2);

    // Prepare background picture for editor screen to improve 
    // performance a bit (static image that is never changed)
    BITMAP *editor_bg = create_bitmap(640, 400);
    clear_to_color(editor_bg, COLOR_BLACK1);
    SPK *tac01 = new SPK("$(xcom)/ufograph/tac01.scr");  // Picture with buttons
    tac01->show(editor_bg, 0, 0); // draw buttons: OK, Next-Man, Prev-Man, Unload-clip, Scroll-right
    delete tac01;
    BITMAP *b5 = create_bitmap(32, 15); clear(b5);  // Button for Scroll-left
    blit(editor_bg, b5, 288, 137, 0, 0, 32, 15);
    draw_sprite_vh_flip(editor_bg, b5, 255, 137); // Button: Scroll-left
    destroy_bitmap(b5);
    rectfill(editor_bg, 288, 32, 319, 57, COLOR_GRAY15);    //hide unused "unload" button
    text_mode(-1);
    textout(editor_bg, g_small_font, _("Click-and-drop weapons from the armory to the soldier, right-click to remove"), 0, 364 + 22, COLOR_WHITE); 

    position_mouse(320, 200);
    MouseRange temp_mouse_range(0, 0, 639, 400);

    int DONE = 0;
    int mouse_leftr = 1, mouse_rightr = 1;
    int i;
    int color = COLOR_LT_OLIVE;
    int A1 = 0, A2 = 0;

    while (mouse_b & 3) rest(1);

    g_console->resize(SCREEN_W, SCREEN_H - 400);
    g_console->set_full_redraw();
    g_console->redraw(screen, 0, 400);

    while (!DONE) {

        net->check();

        rest(1); // Don't eat all CPU resources

        if (CHANGE) {
            g_console->redraw(screen, 0, 400);

            blit(editor_bg, screen2, 0, 0, 0, 0, editor_bg->w, editor_bg->h);
            man->showspk(screen2); // Show "bigpicture" of soldier in choosen armor

            color = COLOR_DK_GRAY;
            if (man->x != 0)   // ??? This soldier already selected for the mission ?
                color = COLOR_LT_OLIVE;
            text_mode(-1);
            textout(screen2, large, man->md.Name, 0, 0, color);

            for (i = 0; i < NUMBER_OF_PLACES; i++) //man->drawgrid();
                man->place(i)->drawgrid(screen2, i);
            m_armoury->drawgrid(screen2, P_ARMOURY);

            man->draw_unibord(1, 320, 0);  // Attribute-Barchart
            if (sel_item != NULL) {
                if (sel_item_place == P_ARMOURY)
                    sel_item->od_info(330, 235, COLOR_WHITE);
                else
                    sel_item->od_info(330, 235, COLOR_OLIVE);

                textprintf(screen2, g_small_font, 128, 140, COLOR_GREEN,  "%s", sel_item->name().c_str());

                if (sel_item->haveclip()) {
                    //textprintf(screen2, font, 272, 80, color, "%d", sel_item->roundsremain());
                    textout(screen2, g_small_font, _("AMMO:"),  272, 64, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("ROUNDS"), 272, 72, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("LEFT="),  272, 80, COLOR_LT_OLIVE);
                    textprintf(screen2, g_small_font,           299, 80, COLOR_ORANGE, "%d", sel_item->roundsremain());
                    rect(screen2, 272, 88, 303, 135, COLOR_DK_GRAY);      //clip
                    PCK::showpck(sel_item->clip()->obdata_pInv(), 272, 88 + 8);
                } else if (sel_item->obdata_isAmmo()) {
                    //textprintf(screen2, font, 272, 80, color, "%d", sel_item->rounds);
                    textout(screen2, g_small_font, _("AMMO:"),  272, 64, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("ROUNDS"), 272, 72, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("LEFT="),  272, 80, COLOR_LT_OLIVE);
                    textprintf(screen2, g_small_font,           299, 80, COLOR_ORANGE, "%d", sel_item->m_rounds);
                    rect(screen2, 272, 88, 303, 135, COLOR_DK_GRAY);      //clip
                    PCK::showpck(sel_item->obdata_pInv(), 272, 88 + 8);
                }
                PCK::showpck(sel_item->obdata_pInv(),
                                mouse_x - sel_item->obdata_width()  * 16 / 2,
                                mouse_y - sel_item->obdata_height() * 16 / 2 + 8);
            } else {
                Item *it = m_armoury->item_under_mouse(0, 0);
                if (it != NULL) {
                    if (is_item_allowed(it->m_type))
                        it->od_info(330, 235, COLOR_GRAY05);
                    else
                        it->od_info(330, 235, COLOR_GRAY10);
                } else {
                    //textprintf(screen2, large, 330, 220, COLOR_LT_BLUE, _("Click here to change equipment set"));
                    int ty = 235;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F1: Help")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("    F2/F3: Save/load team")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F4: Edit soldier attributes")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F5: Change weaponset")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F6: Save as weapon set template")); ty += 15;

                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _(" Ctrl+Ins: Copy current soldier")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Ins: Paste on current soldier")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      Del: Delete items of current man")); /*ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Del: Drop items of current man"));*/ ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      F11: Cycle through appearences")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      F12: Cycle through human armours")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+F12: Cycle through alien races")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      Tab: Next soldier")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Tab: Previous soldier")); ty += 10;
                }
            }

            int wht = man->count_weight();
            int max_wht = man->md.Strength;
            color       = max_wht < wht ? COLOR_RED03 : COLOR_GRAY02;
            textprintf(screen2, g_small_font, 0, 20, color, _("Equipment weight: %2d/%2d"), wht, max_wht);
            char str1[64]; // to adjust position of translated string
          //int x1 = 120;
            int x2 = 236;
            sprintf(str1, "%s: %4d", _("Soldier cost"), man->calc_full_ammunition_cost() );
            int w1 = text_length(g_small_font, str1);  // right-justify string
            textprintf(screen2, g_small_font, x2-w1, 20, COLOR_GRAY02, "%s", str1);

            draw_alpha_sprite(screen2, mouser, mouse_x, mouse_y);
            blit(screen2, screen, 0, 0, 0, 0, screen2->w, screen2->h);
            CHANGE = 0;
        }

        if ((mouse_b & 1) && (mouse_leftr)) { //left mouseclick
            mouse_leftr = 0;
            CHANGE = 1;

            if (handle_mouse_leftclick())
                DONE = 1;
        }

        if ((mouse_b & 2) && (mouse_rightr)) { //right mouseclick: get & put items
            mouse_rightr = 0;
            CHANGE = 1;
            if (sel_item != NULL) {
                if (sel_item_place == P_ARMOURY) {
                    // If item was taken from the armoury - just delete it
                    delete sel_item;
                    sel_item = NULL;
                } else {
                    // If item was taken from the the soldier - put it back
                    man->putitem(sel_item, sel_item_place, sel_item->m_x, sel_item->m_y);
                    sel_item = NULL;
                }
            } else {
                // Delete item under mouse cursor
                for (i = 0; i < NUMBER_OF_PLACES; i++) {
                    Item *it = man->place(i)->mselect(0, 0);
                    if (it != NULL) delete(it);
                }
            }
        }

        if (!(mouse_b & 1)) {
            mouse_leftr = 1;
        }

        if (!(mouse_b & 2)) {
            mouse_rightr = 1;
        }

        if (keypressed()) {
            CHANGE = 1;
          //int c = readkey();
          //switch (c >> 8) {
            int scancode; int keycode = ureadkey(&scancode); 
            switch (scancode) { 
                case KEY_F1:
                    help( HELP_INVENTORY );
                    break;
                // Todo: Change from "Save&Load Team" to "Save&Load Soldier" 
                // Todo: move "Save&Load Team" to Mission-planner (connect.cpp)
                case KEY_F2:
                    //if (askmenu("SAVE DATA")) {
                    save();
                    //}
                    break;
                case KEY_F3:
                    //if (askmenu("LOAD DATA")) {
                    load();
                    //}
                    break;
                case KEY_F4:
                    edit_soldier();   // Edit Attributes+Armor
                    break;

                case KEY_F5:
                    change_equipment();
                    break;

                case KEY_F6:
                    export_weaponset();
                    break;

                case KEY_F10:
                    change_screen_mode();
                    break;

                case KEY_F11:  // cycle thru apperances:
                    A1 = man->md.Appearance;
                    A2 = man->md.fFemale;
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-F11: 
                        A2++;
                        if (A2 >= 2) A2 = 0;
                        man->md.fFemale    = A2;
                    } else { // F11: 
                        A1 = A1 + (A2 ? 4 : 0);
                        A1++;
                        if (A1 >= 8) A1 = 0;
                        man->md.fFemale    = A1 >= 4;
                        man->md.Appearance = A1 % 4;
                    }
                    man->process_MANDATA();
                    break;
                case KEY_F12:  // cycle thru armor-types:
                    A1 = man->md.SkinType;
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) // Shift-F12: Aliens
                        man->skin()->next_alien();
                    else // F12: Human Armor
                        man->skin()->next_human();
                    man->process_MANDATA();
                    break;
//
                case KEY_INSERT:  // Todo: Copy items from last DEL to current man
                    if ((key[KEY_LCONTROL]) || (key[KEY_RCONTROL])) {
                        copy_soldier(man);
                        break;
                    }
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT])) {
                        paste_soldier(man);
                        break;
                    }
                    break;
                case KEY_DEL:  // Todo: store the deleted items (where?) for KEY_INSERT
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-DEL:
                      // Drop all carried items:   // Todo: drop to common pool
                        Item * it;
                        for (int i = 0; i < NUMBER_OF_CARRIED_PLACES; i++) {
                            it = man->item(i);
                            if (it != NULL)
                                man->putitem(it, P_MAP);
                        }
                    } else { // DEL:
                        // Destroy items of current man, including those on the ground:
                        man->destroy_all_items();
                    }
                    break;

                case KEY_TAB:   // jump to next/prev. soldier
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-TAB:
                        man = man->prevman();
                    } else { // TAB:
                        man = man->nextman();
                    }
                    break;
                case KEY_LEFT:
                    man = man->prevman();
                    break;
                case KEY_RIGHT:
                    man = man->nextman();
                    break;     

                 case KEY_PGUP:
                    scroll_equipment(-1);
                    break;
                 case KEY_PGDN:
                    scroll_equipment(+1);
                    break;
                case KEY_PRTSCR:
                    if (askmenu(_("SCREEN-SNAPSHOT"))) {
                        savescreen();
                    }
                    break;
                case KEY_ESC:
                    DONE = 1;
                    break;
                default: 
                    if (g_console->process_keyboard_input(keycode, scancode))
                        net->send_message((char *)g_console->get_text());
            }
        }
    }

    m_plt->save_FULLDATA("$(home)/squad.lua");

    destroy_bitmap(editor_bg);
    destroy_bitmap(screen2);
    screen2 = create_bitmap(SCREEN2W, SCREEN2H); clear(screen2);

    g_console->resize(SCREEN_W, SCREEN_H - SCREEN2H);
    g_console->set_full_redraw();

    clear(screen);
}
示例#7
0
int main() {

	init();
	equacao();
	abertura();
	
	clock_t tempo;
   	float FPS = 15.0;//Limitadores de FPS
   	tempo = clock();
	menu();
	buffer = create_bitmap(1280,720);                   			//O Buffer cria um Bitmap de 1280x720
	background[0] = load_bitmap("background.bmp", NULL);   			//O background recebe a imagem
	background[1] = load_bitmap("background1.bmp", NULL);   		//O background recebe a imagem
	background[2] = load_bitmap("background2.bmp", NULL);   		//O background recebe a imagem
	background[3] = load_bitmap("background3.bmp", NULL);   		//O background recebe a imagem
	background[4] = load_bitmap("background4.bmp", NULL);   		//O background recebe a imagem
	background[5] = load_bitmap("background5.bmp", NULL);   		//O background recebe a imagem
	background[6] = load_bitmap("background6.bmp", NULL);   		//O background recebe a imagem
	background[7] = load_bitmap("background7.bmp", NULL);   		//O background recebe a imagem
	
	//Iniciando Background
    draw_sprite(screen, background[back], 0, 0);          			//Coloca a imagem na tela
    draw_sprite(buffer, background[back], 0, 0);          			//Coloca a imagem na tela

    //Iniciando Nave
    nave[0] = load_bitmap("nave1.bmp", NULL);          				//A Nave recebe a imagem
    nave[1] = load_bitmap("nave2.bmp", NULL);          				//A Nave recebe a imagem
    nave[2] = load_bitmap("nave3.bmp", NULL);          				//A Nave recebe a imagem

	//iniciando inimigos

	inimigo[10] = load_bitmap("Inimigos.bmp", NULL);
    inimigo[11] = load_bitmap("Inimigos1.bmp", NULL);
    inimigo[12] = load_bitmap("Inimigos2.bmp", NULL);
    inimigo[13] = load_bitmap("Inimigos3.bmp", NULL);
	escolha();
	while (!key[KEY_ESC]) {
        //vsync();
		//readkey();                                                //Sem essa função, a tela atualiza sozinha.
		if ( (double)(clock() - tempo) >= 1000/FPS ) {
			if (yini >= ynave[e] - 100){
				perdeu();
			}

	        if (key[KEY_RIGHT])
         	{
				if (e == 0){
					if (xnave[e] < 1140){                          	//Limita até aonde o tanque vai
						xnave[e] += 40;								//Muda a nave de posição
					}
				}
				if (e == 1){
                    	if (xnave[e] < 1100){                       //Limita até aonde o tanque vai
						xnave[e] += 40;								//Muda a nave de posição
					}
				}
				if (e == 2){
					if (xnave[e] < 1190){                          	//Limita até aonde o tanque vai
						xnave[e] += 40;								//Muda a nave de posição
					}
				}
			}
	        if (key[KEY_LEFT])
	        {
                if (e == 0){
					if (xnave[e] > -50){                            //Limita até aonde o tanque vai
					xnave[e] -= 40;                            		//Muda a nave de posição
					}
				}
				if (e == 1){
                	if (xnave[e] > -75){                            //Limita até aonde o tanque vai
					xnave[e] -= 40;                            		//Muda a nave de posição
					}
				}
				if (e == 2){
					if (xnave[e] > -50){                            //Limita até aonde o tanque vai
					xnave[e] -= 40;                            		//Muda a nave de posição
					}
				}
			}
			if (key[KEY_SPACE])
			{
				lazer();
				atirar();
			}

			char txt[15]; sprintf(txt,"x + %d = %d", b, a);			//Inicializa o texto
			char txt2[15]; sprintf(txt2,"Pontos = %d", score);		//Inicializa o texto
			blit(buffer, screen, 0,0,0,0,1280,720);					//Limpa a tela
	       	clear_bitmap(buffer);									//Limpa a tela
			xini = 15.0;
			yini += nivel;

			if (p == 10){
				p++;
			}
			else {
				if (p == 11){
					p++;
				}
				else {
					if (p == 12){
						p++;
					}
					else {
						if (p == 13){
							p = 10;
						}
					}
				}
			}
			draw_sprite(buffer, background[back], 0, 0);			//Coloca a imagem na tela
			draw_sprite(screen, nave[e], xnave[e],ynave[e]);     	//Põe a nave na tela
			textout(screen,font,txt,600,450,makecol(255,0,0));  	//Exibe o texto
			textout(screen,font,txt2,5,5,makecol(255,0,0));  		//Exibe o texto
			draw_sprite(screen, inimigo[p], 15,yini); 				//Põe a nave na tela
	        tempo = clock();
		}
	}

	deinit();
	return 0;

}
示例#8
0
/*
 * pg_node_tree_out		- output routine for type PG_NODE_TREE.
 *
 * The internal representation is the same as TEXT, so just pass it off.
 */
Datum
pg_node_tree_out(PG_FUNCTION_ARGS)
{
	return textout(fcinfo);
}
示例#9
0
文件: place.cpp 项目: Fomka/ufo2000
/**
 * Draw inventory-grid for belt, backpack, armory etc.
 */
void Place::drawgrid(BITMAP *dest, int PLACE_NUM)
{
    ASSERT((PLACE_NUM >= 0) && (PLACE_NUM <= NUMBER_OF_PLACES));

    if (PLACE_NUM == P_ARMOURY) {
        const char *eqname = get_current_equipment_name();
        if (!eqname) eqname = _("(none, remote player doesn't have any of your weaposets)");
        textprintf(dest, g_small_font, gx, gy + 1 - text_height(g_small_font), COLOR_WHITE,
            _("Weapon set: %s"), eqname);
    } else {
        textout(dest, g_small_font, place_name[PLACE_NUM], gx, gy + 1 - text_height(g_small_font), COLOR_LT_OLIVE);
    }

    if (!ishand()) {
        int dx = 0, dy = 0;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (!outside_belt(j, i))
                    rect(dest, gx + dx, gy + dy, gx + dx + 16, gy + dy + 15, COLOR_GRAY08);      //square
                dx += 16;
                if (j == 19) break;      // for map cell!!!!!!!!!!!!!!!!!!!
            }
            dx = 0;
            dy += 15;
        }
    } else {
        rect(dest, gx, gy, gx + width * 16, gy + height * 15, COLOR_GRAY08);
    }

    // Draw items in grid:
    Item *t = m_item;
    while (t != NULL) {
        if ((t->m_x >= viscol - 1) && (t->m_x < viscol + 20)) {

            if (!is_item_allowed(t->itemtype())) {
                int x = gx + (t->m_x - viscol) * 16;
                int y = gy + t->m_y * 15;
                int sx = t->obdata_width() * 16;
                int sy = t->obdata_height() * 15;
                if (ishand()) {
                    x = gx;
                    y = gy;
                    sx = width * 16;
                    sy = height * 15;
                }
                rectfill(dest, x + 1, y + 1, x + sx - 1, y + sy - 1, COLOR_RED06);
            }

            int x = gx + (t->m_x - viscol) * 16;
            int y = gy + t->m_y * 15 + 5;

            if (ishand()) {
                int it_width = t->obdata_width();
                int it_height = t->obdata_height();
                x = gx + (width - it_width) * 16 / 2;
                y = gy + (height - it_height) * 15 / 2 + 5;
            }

            PCK::showpck(dest, t->obdata_pInv(), x, y);  // Picture of item

            if (ishand()) { // Inventory-view: display ammo-rounds & grenade-delay
                if (t->clip() != NULL) {   // see also: Soldier::drawinfo()
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_WHITE, t->roundsremain() );
                    textout(dest, g_small_font, t->get_damage_name(), gx + 3, gy + 36, COLOR_GREEN);
                }
                if (t->obdata_isAmmo() ) {   // Test
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_WHITE, t->m_rounds );
                }
                if (t->is_grenade() ) {  // see also: icon.h : DrawPrimed
                    if (t->delay_time() > 0)
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_RED, t->delay_time() - 1);
                    else if (t->is_proximity_grenade() && t->delay_time() < 0)
                    textout(dest, g_small_font, "*", gx + 23, gy + 36, COLOR_RED);
                }
            }

            if (key[KEY_LCONTROL]) {
                t->draw_health(dest, 1, x + 1, y - 4);
            }
            if (key[KEY_ALT]) {
                t->draw_health(dest, 0, x + 1, y - 4);
            }
        }
        t = t->m_next;
    }
}
示例#10
0
文件: gtext.c 项目: cravo/damp
void gtext_render(void)
{
   char tempstr[64];          /* temp variable */
   int n;                     /* loop counter */


   /* clear the buffer */
   clear(damp_gfx_buffer);


   /* display volume */
   textout(damp_gfx_buffer,font,"Volume:",0,30,makecol(255,255,0));
   sprintf(tempstr,"%d",damp_volume);
   textout(damp_gfx_buffer,font,tempstr,text_length(font,"Volume:"),30,makecol(128,128,128));

   /* display track time */
   textout(damp_gfx_buffer,font,"Time:",160,30,makecol(255,255,0));
   sprintf(tempstr,"%s",damp_display_time_remaining ? timeremainstr : timestr);
   textout(damp_gfx_buffer,font,tempstr,160+text_length(font,"Time:"),30,makecol(128,128,128));

   /* display status */
   textout(damp_gfx_buffer,font,"================ STATUS ================", 0, 50, makecol(255,128,64));
   textout(damp_gfx_buffer,font,"Surround",30,60,audio_driver->surround ? makecol(255,255,0) : makecol(64,64,64));
   textout(damp_gfx_buffer,font,"Continuous",30+text_length(font,"Surround   "),60,damp_playlist_continuous ? makecol(255,255,0) : makecol(64,64,64));
   textout(damp_gfx_buffer,font,"Random",30+text_length(font,"Surround   Continuous   "),60,damp_playlist_random ? makecol(255,255,0) : makecol(64,64,64));

   /* display scrolling track name */
   textout(damp_gfx_buffer,font,"============== NOW PLAYING =============", 0, 80, makecol(255,128,64));
   textout(damp_gfx_buffer,font,&damp_gfx_scroll_name[damp_gfx_scroll_name_pos],0,90,makecol(255,255,255));
   if(track_sel_pos > 0)
      textout_centre(damp_gfx_buffer,font,track_sel,160,100,makecol(255,255,255));

   /* display vu */
   if(damp_want_scope)
   {
      textout(damp_gfx_buffer,font,"VU-meter:",0,110,makecol(255,255,0));
      for(n=0;n<32;n++)
         textout(damp_gfx_buffer,font,n==gtext_vu_max/2 ? "I" : (n<damp_vu/2 ? "=" : "-"),n*10,120,(n < damp_vu/2) ? (n<16 ? makecol(0,255,0) : (n<24 ? makecol(255,255,0) : makecol(255,0,0))) : makecol(128,128,128));
   }

   /* display "advert" :-) */
   textout_centre(damp_gfx_buffer,font,"DAMP",160,140,makecol(255,0,0));
   textout_centre(damp_gfx_buffer,font,"Copyright 1999/2000 Hedgehog Software",160,150,makecol(255,0,0));
   textout_centre(damp_gfx_buffer,font,"http://www.damp-mp3.co.uk/",160,160,makecol(255,0,0));

   /* display it all */
   if(!damp_using_gui)
      blit(damp_gfx_buffer,screen,0,0,0,0,DAMP_GFX_SCREEN_WIDTH,DAMP_GFX_SCREEN_HEIGHT);
}
示例#11
0
文件: xkeymap.c 项目: albinoz/raine
static void
test_key_map (void)
{
  int i;
  static int key_was_pressed[KEY_MAX + 1];
  static int key_is_pressed[KEY_MAX + 1];
  static char *welcome[] =
  {
    "Key that is pressed now is marked with red",
    "Key that was pressed is marked with yellow",
    "Press mouse button or Escape to exit test",
    0
  };

  text_mode (-1);

  /* Clear screen and output prompt.  */
  clear_to_color (screen, white);
  for (i = 0; welcome[i] != 0; i++)
    textout (screen, font, welcome[i], 8, i * 8 + 8, black);

  clear_to_color (screen, white);
  for (i = 0; keymap[i].string != 0; i++)
    textout (screen, font, keymap[i].string, 32 + (i % 4) * 160, 40 + (i / 4) * 14, black);

  do
    {
      poll_keyboard ();
      poll_mouse ();
    }
  while ((key[KEY_ESC]) || (mouse_b));

  do
    {
      poll_keyboard ();
      poll_mouse ();

      for (i = 0; i < KEY_MAX; i++)
	{
	  if (key[i])
	    key_was_pressed[i] = key_is_pressed[i] = 1;
	  else
	    key_is_pressed[i] = 0;
	}

      for (i = 0; keymap[i].string != 0; i++)
	{
	  int x = 16 + (i % 4) * 160;
	  int y = 40 + (i / 4) * 14;
	  int k = keymap[i].key;

	  if (key_is_pressed[k])
	    rectfill (screen, x, y, x + 7, y + 7, red);
	  else if (key_was_pressed[k])
	    rectfill (screen, x, y, x + 7, y + 7, yellow);
	  else
	    rectfill (screen, x, y, x + 7, y + 7, white);
	}
    }
  while ((!key[KEY_ESC]) && (!mouse_b));

  do
    {
      poll_keyboard ();
      poll_mouse ();
    }
  while ((key[KEY_ESC]) || (mouse_b));

  clear_keybuf ();
}
示例#12
0
文件: xkeymap.c 项目: albinoz/raine
static void
setup_all_keys (void)
{
  int i, y, ymin, ymax;
  static char *welcome[] =
  {
    "Press a key to map to this scancode",
    "Press mouse button for next scancode",
    0
  };

  text_mode (-1);

  /* Clear screen and output prompt.  */
  clear_to_color (screen, white);
  for (i = 0; welcome[i] != 0; i++)
    textout (screen, font, welcome[i], 8, i * 8 + 8, black);

  ymin = i * 8 + 16;
  ymax = ymin + 8 * 8;
  y = ymin - 8;

  for (i = 0; keymap[i].string != 0; i++)
    {
      y += 8;
      if (y >= ymax)
	{
	  blit (screen, screen, 8, ymin + 8, 8, ymin, 200, ymax - ymin);
	  y -= 8;
	}

      textprintf (screen, font, 8, y, red, "scancode: %s", keymap[i].string);

      /* Wait while any mouse button is pressed.  */
      do
	{
	  poll_mouse ();
	}
      while (mouse_b);

      /* Wait for new key press.  */
      new_keycode = -1;
      waiting_for_key = 1;

      do
	{
	  poll_keyboard ();
	  poll_mouse ();

	  if (mouse_b)
	    waiting_for_key = 0;
	}
      while (waiting_for_key);

      /* Save keycode to scancode mapping.  */
      if ((new_keycode >= 0) && (new_keycode < 256))
	{
	  _xwin.keycode_to_scancode[new_keycode] = keymap[i].scancode;
	  keycode_to_scancode[new_keycode] = keymap[i].scancode;
	}
    }

  do
    {
      poll_keyboard ();
      poll_mouse ();
    }
  while ((key[KEY_MUHENKAN]) || (mouse_b));

  clear_keybuf ();
}
示例#13
0
/* a hack */
void putstr(char *s) {
  static int y = 0;
  text_mode(-1);
  textout(screen, font, s, 0, y, makecol(0, 0, 0));
  y += text_height(font);
}
示例#14
0
void TextEditBox::subanimate()
{
	STACKTRACE;

	//	TextInfoArea::subanimate();

	text_mode(-1);

	int i;
	for ( i = 0; i < textinfo->Nshow; ++i ) {
		int iline;
		iline = scroll.y + i;

								 // is the following correct? -> Nline-1 is not a line; it indicates the last byte + 1
		if ( iline < 0 || iline > textinfo->Nlines-1 )
			continue;

		// first character of the line
		int n, L;
		n = textinfo->linestart[iline];

		// number of characters till the start of the next line
		if ( iline < textinfo->Nlines-1 )
			L = textinfo->linestart[iline+1] - n - 1;
		else
			L = strlen(&(textinfo->textinfo[n]));

		// make a copy of this line (and add a 0 ?)
		char txt[128];

		if (L > 127)
			L = 127;

		strncpy(txt, &(textinfo->textinfo[n]), L);
		txt[L] = 0;

		// filter the text a little...

		int k;
		for ( k = 0; k < L; ++k ) {
			if (txt[k] < 20 || (unsigned char)txt[k] > 128 )
				txt[k] = ' ';
		}

		textout(drawarea, usefont, txt, 0, (iline - scroll.y)*textinfo->Htxt, text_color);
	}

	// draw a line at "charpos" ...

	int xc, yc;
	textinfo->getxy(charpos, &xc, &yc);
	yc /= textinfo->Htxt;
	//yc = scroll.yselect;

	int h;
	h = textinfo->Htxt;
	yc -= scroll.y;

	if ( (int(mainwindow->menu_time * 1000) % 100) < 50)
		line (drawarea, xc, yc*h, xc, (yc+1)*h, makecol(0,0,0));

}
示例#15
0
int savecity()
{
     buffer = create_bitmap(640,480);
     
     samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\savecity.wav");
     samExplosion1 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion1.wav");

     textout(buffer,font,"Save City (ESC to quit)",0,1,WHITE);

     updatescore();

//     rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);

     city = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\city.bmp", NULL);
     for (n = 0; n < 5; n++)
         masked_blit(city, buffer, 0, 0, 20+n*120, SCREEN_H-city->h-2, city->w, city->h);

     crosshair = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\crosshair.bmp", NULL); 
     set_mouse_sprite(crosshair);
     set_mouse_sprite_focus(15,15);
     show_mouse(buffer); 
     
     play_sample(samSong, 128, 128, 1000, 1);
     
     while (!key[KEY_ESC])
     {
           //above the red was border get destroyed
           rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);
           
           mx = mouse_x;
           my = mouse_y;
           mb = (mouse_b & 1);
     
           if (destroyed)
                firenewmissile();
     
           if (mb)
           {
                explosion1(screen,mx,my,GREEN);
                play_sample(samExplosion1, 40, 128, 1000, 0);
           }
           
           movemissile();
           
           blit(buffer,screen,0,0,0,0,640,480);
           
           if(key[KEY_BACKSPACE])
           {    
                 score=-1;        
                 firenewmissile();
                 stop_sample(samSong);

                 openscreen();        
           }
              
           if(key[KEY_ESC])
           {
                           exit(1);
           }
           
                         
           if(score>=0 && score <5)
                 rest(10);
           else if(score>=5 && score<10)
                 rest(9);            
           else if(score>=10 && score<15)
                 rest(8);            
           else if(score>=15 && score<20)
                 rest(7);            
           else if(score>=20 && score<25)
                 rest(6);            
           else if(score>=25 && score<30)
                 rest(5);            
           else if(score>=30 && score<35)
                 rest(4);            
           else if(score>=35 && score<40)
                 rest(3);
           else if(score>=40 && score<45)
                 rest(2);
           else if(score>=45)
                 rest(1);            
                                   
     }
     
     set_mouse_sprite(NULL);
     destroy_bitmap(city);
     destroy_bitmap(crosshair);
    // openscreen();
     return 0;
}
示例#16
0
文件: ocamlras.c 项目: kign/inet-lab
value_t c_win32_dial (
   value_t _mt,
   value_t _entryName,
   value_t phoneNumber,
   value_t userName,
   value_t password,
   value_t domain,
   value_t callback ) 
{
   char			* entryName = String_val ( _entryName );
   int			mt = Bool_val ( _mt );
   DWORD 		dwRet;
   RASDIALPARAMS 	rdParams;
   HRASCONN 		hRasConn;
   CAMLparam5 ( mt, _entryName, phoneNumber, userName, password );
   CAMLxparam2 ( domain, callback );

   printf ( "Callback passed = 0x%08x, deref = 0x%08x\n",
	    (unsigned) callback, (unsigned)(*(void **)callback) );
   fflush ( stdout );
   
   hRasConn = NULL;
   rdParams.dwSize = sizeof(RASDIALPARAMS);
   lstrcpy(rdParams.szEntryName,   entryName );
   lstrcpy(rdParams.szPhoneNumber, String_val ( phoneNumber ) );
   lstrcpy(rdParams.szCallbackNumber, "" );
   lstrcpy(rdParams.szUserName,    String_val ( userName ) );
   lstrcpy(rdParams.szPassword,    String_val ( password ) );
   lstrcpy(rdParams.szDomain,      String_val ( domain ) );
   
   cb_info.g_status = 0;
   cb_info.mt = mt;
   cb_info.p_closure = &callback;
   cb_info.entryName = entryName;
   
   textout ( mtINFO, "Dialing %s", entryName );
   if (debug_print)
      printf ( "I am inside c_win32_dial!\n" );

   if ( mt )
      enter_blocking_section ();
   
   dwRet = RasDial ( NULL, NULL, &rdParams, 1L,
	     (RASDIALFUNC) RasDialFunc1, &hRasConn );

   if ( mt )
      leave_blocking_section ();
   
   if ( dwRet )
   {
      char		szBuf[256];
      
      if ( RasGetErrorString( dwRet, szBuf, 256 ) != 0 )
	 wsprintf( (LPSTR)szBuf, "Undefined RAS Dial Error (%ld).",
		   dwRet );
      textout ( mtERR, "Error attempting to connect: %s", szBuf );
      hangup ( hRasConn );
   }

   CAMLreturn (Val_bool ( 1 ));
   return 0; /* dummy, to shut down warning */
}
示例#17
0
/*
 * pg_node_tree_out		- output routine for type PG_NODE_TREE.
 *
 * The internal representation is the same as TEXT, so just pass it off.
 */
datum_t pg_node_tree_out(PG_FUNC_ARGS)
{
	return textout(fcinfo);
}
示例#18
0
文件: datfli.c 项目: ifilex/SRC
/* displays a FLIC object in the grabber object view window */
static void plot_fli(DATAFILE *dat, int x, int y)
{
   textout(screen, font, "Double-click in the item list to play it", x, y+32, gui_fg_color);
}
示例#19
0
文件: game.c 项目: nnia/tetrisboxes
void game()
{
	static int count = 0;
	static unsigned char first_time = 1;

	/***********/
	char buff[64];
	int i, j;
	/***********/

	if (first_time==1)
	{

		glEnable(GL_LIGHTING);
		glEnable(GL_LIGHT0);		
//		glEnable(GL_LIGHT1);
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_COLOR_MATERIAL);
		LoadPic1();




		for (i=0; i<BOX_MAX; i++)
		{
			box[i].x = BOX_X_INIT;
			box[i].y = BOX_Y_INIT;
			box[i].status = BOX_OFF;
		}
		/*
		for (j=0; j<N_ROW; j++)
		{
			for (i=0; i<N_COL; i++)
			{
				pole[i][j] = 0;
			}
		}
		*/
		srand(time);
		new_box();
		
		man.x = fmod(rand(), N_COL);
		man.y = 0;
		man.flag_up = MAN_FLAG_UP_0;
		man.ay = 0;

		first_time = 0;
	}


	glPushMatrix(); // all
//	glScalef(0.1, 0.1, 1);

	// pole
	glColor3f(0.0, 0.0, 0.5);


	rectangletex(	START_X + 0*SX, START_Y + 0*SY, 
				START_X + (N_COL)*SX, START_Y + (N_ROW)*SY);
	glColor3f(0, 1.0, 0.5);



	// box to pole
	// box_to_pole();

	// draw
/*

	for (j=0; j<N_ROW; j++)
	{
		for (i=0; i<N_COL; i++)
		{
			if (pole[i][j] != BOX_OFF)
			{
		/ *		rectangle(	START_X + i*SX, START_Y + j*SY, 
							START_X + (i+0.9)*SX, START_Y + (j+0.9)*SY);* /
				drawbox()
				/ *textout(	START_X + i*SX, START_Y + j*SY, 1, &num[pole[i][j]] );* /
			}
		}
	}
*/

	if (gamestatus == GAMEMENU)
	{
		draw_menu_new();
	}
	if (gamestatus == GAME)
	{
		for (i=0; i<BOX_MAX; i++)
		{
			if (box[i].status != BOX_OFF)
			{
				drawbox(box[i]);
			}
		}
		draw_man(man);
	}
	
	// lines
	if (lines > 0)
	{
		sprintf(buff, "Линий: %d", lines);
		textout(RES_LINES_X, RES_LINES_Y, strlen(buff), buff);
	}
	if (pobashke > 0)
	{
		sprintf(buff, "По башке: %d", pobashke);
		textout(RES_POBASHKE_X, RES_POBASHKE_Y, strlen(buff), buff);
	}

	if (gamestatus == GAMEOVER)
	{
		glColor3f(1.0, 1.0, 1.0);
		textout(	START_X + N_COL*HSX, START_Y + N_ROW*HSY, 9, "GAME OVER" );
	}

	if (gamestatus == GAMEPAUSE)
	{
		glColor3f(1.0, 1.0, 1.0);
		textout(	START_X + N_COL*HSX, START_Y + N_ROW*HSY, 5, "PAUSE" );
	}


	glPopMatrix(); // all
}
示例#20
0
文件: aase.c 项目: Fomka/ufo2000
int d_aase_edit_proc(int msg, DIALOG *d, int c)
{
  int ret;

  if (msg == MSG_START) {
    /* this is mainly for `file_select', because the size that
       it put to the `gui_edit_proc' is very small */
    d->h = MAX(d->h, 3 + text_height(font) + 3);
  }
  else if (msg == MSG_DRAW) {
    int f, l, p, w, x, fg, b, scroll;
    char buf[16];
    char *s;
    int rtm;

    agup_edit_adjust_position (d);

    if (!(d->flags & D_INTERNAL))
      d->w -= 6;

    s = (char *)d->dp;
    l = ustrlen(s);
    if (d->d2 > l) 
       d->d2 = l;

    /* calculate maximal number of displayable characters */
    if (d->d2 == l)  {
       usetc(buf+usetc(buf, ' '), 0);
       x = text_length(font, buf);
    }
    else
       x = 0;

    b = 0;

    for (p=d->d2; p>=0; p--) {
       usetc(buf+usetc(buf, ugetat(s, p)), 0);
       x += text_length(font, buf);
       b++;
       if (x > d->w) 
         break;
    }

    if (x <= d->w) {
       b = l; 
       scroll = FALSE;
    }
    else {
       b--; 
       scroll = TRUE;
    }

    d->w += 6;

    ase_rectedge(screen, d->x,   d->y,   d->x+d->w-1, d->y+d->h-1,
      makecol(0, 0, 0),
      makecol(255, 255, 255));

    ase_rectedge(screen, d->x+1, d->y+1, d->x+d->w-2, d->y+d->h-2,
      makecol(128, 128, 128),
      makecol(192, 192, 192));

    ase_rectgouraud(screen, d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,
      (d->flags & D_DISABLED)? 128: 224, 255);

    fg = (d->flags & D_DISABLED) ? aase_mg_color : d->fg;
    x = 3;

    if (scroll) {
       p = d->d2-b+1; 
       b = d->d2; 
    }
    else 
       p = 0; 

    for (; p<=b; p++) {
       f = ugetat(s, p);
       usetc(buf+usetc(buf, (f) ? f : ' '), 0);
       w = text_length(font, buf);
       if (x+w > d->w-2)
          break;
       f = ((p == d->d2) && (d->flags & D_GOTFOCUS));
       rtm = text_mode((f) ? fg : -1);
       textout(screen, font, buf, d->x+x, d->y+d->h/2-text_height(font)/2, (f) ? d->bg : fg);
       text_mode(rtm);
       x += w;
    }

    if (d->flags & D_INTERNAL)
      d->w -= 6;

    agup_edit_restore_position (d);

    return D_O_K;
  }

  d->w -= 6;
  d->flags |= D_INTERNAL;

  ret = d_agup_adjusted_edit_proc(msg, d, c);

  d->flags &= ~D_INTERNAL;
  d->w += 6;

  return ret;
}
示例#21
0
文件: acc.cpp 项目: baffles/sh05
// from a.cc by spelly
void textoutWordWrap_(BITMAP* dst, FONT* font, int x, int y, int w, int h, int col, char* text) {
int height = text_height(font);

char *start = NULL;
char *end = NULL;

static char delim[] = " ";
char *token = NULL;
int curX = x;
int curY = y;
int space = text_length(font, " ");
int len = 0;
int maxX = x + w;
int maxY = y + h;
int getToken = TRUE;
char oneChar[] = "X";

start= text;
end = strchr(start, '\n');
while (end != NULL) {
*end='\0';

token = strtok(start, delim);
while (token != NULL) {
len = text_length(font , token);

getToken = TRUE;
if (curX + len > maxX) {
if (len > w) {
// the token does not fit into a single line
getToken = FALSE;

while (curX < maxX && *token) {
// there's no char_out function, so we'll use a two char string
*oneChar = *token;
len = text_length(font, oneChar);
if (curX + len < maxX) {
token++;
textout(dst, font, oneChar, curX, curY, col);
}
curX += len;
}
curY += height;
curX = x;
} else {
curX = x;
curY += height;

textout(dst, font, token, curX, curY, col);

curX += len + space;
}
} else {
textout(dst, font, token, curX, curY, col);
curX += len + space;
}

if (getToken) {
token = strtok(NULL, delim);
}
}

start = end+1;
end = strchr(start, '\n');
curY += height;
curX = x;
}
}
示例#22
0
/* cflags - flag to regcomp indicates case sensitivity */
static int
RE_compile_and_execute(struct varlena *text_re, char *text, int cflags)
{
	int	oldest;
	int	n;
	int	i;
	char    *re;
	int regcomp_result;

  	re = textout(text_re);
  	/* find a previously compiled regular expression */
  	for (i = 0 ; i < rec ; i++) {
	    if (rev[i].cre_s) {
		if (strcmp(rev[i].cre_s, re) == 0) {
		    if (rev[i].cre_type == cflags) {
			rev[i].cre_lru = ++lru;
			pfree(re);
			return(pg95_regexec(&rev[i].cre_re,
					    text, 0,
					    (regmatch_t *) NULL, 0) == 0);
		    }
		}
	    }
  	}
 


	/* we didn't find it - make room in the cache for it */
	if (rec == MAX_CACHED_RES) {
		/* cache is full - find the oldest entry */
		for (oldest = 0, i = 1 ; i < rec ; i++) {
			if (rev[i].cre_lru < rev[oldest].cre_lru) {
				oldest = i;
			}
		}
	} else {
		oldest = rec++;
	}

	/* if there was an old re, then de-allocate the space it used */
	if (rev[oldest].cre_s != (char *) NULL) {
		for (lru = i = 0 ; i < rec ; i++) {
			rev[i].cre_lru =
				(rev[i].cre_lru - rev[oldest].cre_lru) / 2;
			if (rev[i].cre_lru > lru) {
				lru = rev[i].cre_lru;
			}
 		}
		pg95_regfree(&rev[oldest].cre_re);
		/* use malloc/free for the cre_s field because the storage
		   has to persist across transactions */
		free(rev[oldest].cre_s); 
	}

	/* compile the re */
	regcomp_result = pg95_regcomp(&rev[oldest].cre_re, re, cflags);
	if ( regcomp_result == 0) {
		n = strlen(re);
		/* use malloc/free for the cre_s field because the storage
		   has to persist across transactions */
		rev[oldest].cre_s = (char *) malloc(n + 1);
		(void) memmove(rev[oldest].cre_s, re, n);
		rev[oldest].cre_s[n] = 0;
	        rev[oldest].cre_text = text_re;
		rev[oldest].cre_lru = ++lru;
 		rev[oldest].cre_type = cflags;
		pfree(re);
 		/* agc - fixed an old typo here */
 		return(pg95_regexec(&rev[oldest].cre_re, text, 0,
  						(regmatch_t *) NULL, 0) == 0);
	} else {
	    char errMsg[1000];
	    /* re didn't compile */
	    rev[oldest].cre_s = (char *) NULL;
	    pg95_regerror(regcomp_result, &rev[oldest].cre_re, errMsg,
			  sizeof(errMsg));
	    elog(WARN,"regcomp failed with error %s",errMsg);
	}

	/* not reached */
	return(0);
}
示例#23
0
void colisao(){
	int i = 0;
	int x = -50.0;
	int y = yini - 50.0;
	int k = 0;
	float l = 15.0;
	int m = 0;
	score += 100;

	explosao2();
	winner();
    blit(buffer, screen, 0,0,0,0,1280,720);     					//Limpa a tela
	clear_bitmap(buffer);                       					//Limpa a tela
	draw_sprite(buffer, background[back], 0, 0);      				//Coloca a imagem na tela
	draw_sprite(screen, nave[e], xnave[e],ynave[e]);     			//Põe a nave na tela
	
	while (!key[KEY_ENTER]){
		readkey();
    	textout(screen, font, "Acertou a nave desprotegida! Tecle 'Enter' para continuar", 400,350, makecol(255,0,0 ) );
    	char txt[15]; sprintf(txt,"x + %d = %d", b, a);				//Inicializa o texto
		char txt2[15]; sprintf(txt2,"Pontos = %d", score);			//Inicializa o texto
		textout(screen,font,txt,600,450,makecol(255,0,0));  		//Exibe o texto
		textout(screen,font,txt2,5,5,makecol(255,0,0));  			//Exibe o texto
    	if (score == 300){
			nivel = 2.0;
			textout(screen, font, "Nivel 2", 600,365, makecol(255,0,0 ) );
			back = 1;
		}
		if (score == 500){
			nivel = 4.0;
			textout(screen, font, "Nivel 3", 600,365, makecol(255,0,0 ) );
			back = 2;
		}
		if (score == 600){
			nivel = 5.0;
			textout(screen, font, "Nivel 4", 600,365, makecol(255,0,0 ) );
			back = 3;
		}
		if (score == 700){
			nivel = 6.0;
			textout(screen, font, "Nivel 5", 600,365, makecol(255,0,0 ) );
			back = 4;
		}
		if (score == 800){
			nivel = 10.0;
			textout(screen, font, "Nivel 6", 600,365, makecol(255,0,0 ) );
			back = 5;
		}
		if (score == 900){
			nivel = 16.0;
			textout(screen, font, "Nivel 7", 600,365, makecol(255,0,0 ) );
			back = 6;
		}
		if (score == 1000){
			nivel = 20.0;
			textout(screen, font, "Nivel MAX", 600,365, makecol(255,0,0 ) );
			back = 7;
		}
	}
	equacao();
	yini = 40.0;
	c = 0;
}
示例#24
0
文件: MOUSE.C 项目: kashopi/KMid
int main()
{
   int mickeyx = 0;
   int mickeyy = 0;
   BITMAP *custom_cursor;
   char msg[80];
   int c = 0;

   allegro_init();
   install_keyboard(); 
   install_mouse();
   install_timer();
   set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
   set_pallete(desktop_pallete);

   do {
      /* the mouse position is stored in the variables mouse_x and mouse_y */
      sprintf(msg, "mouse_x = %-5d", mouse_x);
      textout(screen, font, msg, 16, 16, 255);

      sprintf(msg, "mouse_y = %-5d", mouse_y);
      textout(screen, font, msg, 16, 32, 255);

      /* or you can use this function to measure the speed of movement.
       * Note that we only call it every fourth time round the loop: 
       * there's no need for that other than to slow the numbers down 
       * a bit so that you will have time to read them...
       */
      c++;
      if ((c & 3) == 0)
	 get_mouse_mickeys(&mickeyx, &mickeyy);

      sprintf(msg, "mickey_x = %-7d", mickeyx);
      textout(screen, font, msg, 16, 64, 255);

      sprintf(msg, "mickey_y = %-7d", mickeyy);
      textout(screen, font, msg, 16, 80, 255);

      /* the mouse button state is stored in the variable mouse_b */
      if (mouse_b & 1)
	 textout(screen, font, "left button is pressed ", 16, 112, 255);
      else
	 textout(screen, font, "left button not pressed", 16, 112, 255);

      if (mouse_b & 2)
	 textout(screen, font, "right button is pressed ", 16, 128, 255);
      else
	 textout(screen, font, "right button not pressed", 16, 128, 255);

      if (mouse_b & 4)
	 textout(screen, font, "middle button is pressed ", 16, 144, 255);
      else
	 textout(screen, font, "middle button not pressed", 16, 144, 255);

      vsync();

   } while (!keypressed());

   clear_keybuf();

   /*  To display a mouse pointer, call show_mouse(). There are several 
    *  things you should be aware of before you do this, though. For one,
    *  it won't work unless you call install_timer() first. For another,
    *  you must never draw anything onto the screen while the mouse
    *  pointer is visible. So before you draw anything, be sure to turn 
    *  the mouse off with show_mouse(NULL), and turn it back on again when
    *  you are done.
    */
   clear(screen);
   textout_centre(screen, font, "Press a key to change cursor", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   /* create a custom mouse cursor bitmap... */
   custom_cursor = create_bitmap(32, 32);
   clear(custom_cursor); 
   for (c=0; c<8; c++)
      circle(custom_cursor, 16, 16, c*2, c);

   /* select the custom cursor and set the focus point to the middle of it */
   set_mouse_sprite(custom_cursor);
   set_mouse_sprite_focus(16, 16);

   clear(screen);
   textout_centre(screen, font, "Press a key to quit", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   destroy_bitmap(custom_cursor);

   return 0;
}
示例#25
0
// application entry point
void main(int argc,char *argv[])
{
  int system_time=0;
  int frame_counter=0;
  int time0;
  char s[20]="";

  if (argc<2) {
    printusage();
    return;
  }

  // parses command line parameters
  parsecmdline(argc-2,argv+2);

  // initializes the video mode and geometry module
  int mode=-1;
  if (vbe_init()) {
    mode=vbe_findmode(scrwidth,scrheight,8);
    if (!mode) mode=-1;
  }
  if (mode==-1) vbe_done();
  if (!vbe_setmode(mode,backbuffl)) goto err;
  setscreensize(vbe_width,vbe_height);
  scr_cols=vbe_width;
  scr_bpp=vbe_bpp;

  // initializes the keyboard
  kbd_init();

  // initializes the timer
  timer_init();

  // initializes the mouse
  mouse_init();

  // reads the map
  if (!map_init(argv[1])) goto err;
  vbe_setpal((Tcolor *)palette,0,256);

  // main loop
  time0=timer_clocks;
  while(player_idle(timer_clocks)) {
    // draws the current frame
    draw_init(vbe_backbuffer,vbe_width,vbe_height);
    map_draw();

    // calculates the frame rate
    frame_counter++;
    int dt=timer_clocks-time0;
    if (dt>500) {
      float fps = (frame_counter*1000.)/dt;
      sprintf(s,"%.1f FPS",fps);
      time0 = timer_clocks;
      frame_counter = 0;
    }
    textout(vbe_backbuffer,0,0,s,255);

    // flips the video pages
    vbe_flip(waitfl);

    // applies the mouse movement
    if (player_keys & kRUN) player_rotate(-mousedy*0.01,0,-mousedx*0.01);
    else player_rotate(-mousedy*0.005,0,-mousedx*0.005);
    mousedx=0;mousedy=0;

    // clears the keyboard queue
    while (kbhit()) getch();
  }
 err:
  vbe_done();
  vbe_settext();
}
示例#26
0
文件: editmode.c 项目: neiderm/turaco
void create_cursors(BITMAP * curs, BITMAP * busy, BITMAP * flood, BITMAP * eye)
{
    if (curs != NULL)
    {
	// this is actually the default cursor for AmigaDos 2.x
	// it's a cool cursor, so i'm stealing it. ;}
	clear(curs);

	line(curs, 0, 0, 4,  9, MOUSE_COLOR_DARK);
	line(curs, 6, 7, 9, 10, MOUSE_COLOR_DARK);

	line(curs, 0, 0, 9,  4, MOUSE_COLOR_LIGHT);
	line(curs, 7, 6, 10, 9, MOUSE_COLOR_LIGHT);

	rect(curs, 2, 2, 3, 3, MOUSE_COLOR_MID);
	rect(curs, 3, 3, 5, 5, MOUSE_COLOR_MID);
	rect(curs, 6, 4, 7, 5, MOUSE_COLOR_MID);
	rect(curs, 4, 6, 5, 7, MOUSE_COLOR_MID);
	line(curs, 8, 5, 9, 5, MOUSE_COLOR_MID);
	line(curs, 5, 8, 5, 9, MOUSE_COLOR_MID);
	line(curs, 0, 0, 9, 9, MOUSE_COLOR_MID);

	// now install the new cursor, and set the hot-spot
	set_mouse_sprite(curs);
    }

    if (busy != NULL)
    {
	// make a simple busy pointer, as i can't muster the
	// thought to come up with anything better.
	clear(busy);
	text_mode (-1);
	rectfill(busy, 0, 0, 34, 11, MOUSE_COLOR_LIGHT);
	rect(busy, 0, 0, 34, 11, 1);
	textout(busy, font, "Wait", 3,3, MOUSE_COLOR_DARK);
	textout(busy, font, "Wait", 2,2, MOUSE_COLOR_MID);
    }

    if (flood != NULL)
    {
	clear(flood);

	// the spilling paint... 
	// perhaps change MOUSE_COLOR_DARK to be the color to fill with?
	line (flood, 0,5,  0,14, MOUSE_COLOR_DARK);
	line (flood, 1,4,  1,15, MOUSE_COLOR_DARK);
	line (flood, 1,4,  3,4,  MOUSE_COLOR_DARK);

	// paint can outline
	line (flood, 3,3,  6,0,  MOUSE_COLOR_MID);
	line (flood, 7,0,  13,6, MOUSE_COLOR_MID);
	line (flood, 13,7, 9,11, MOUSE_COLOR_MID);
	line (flood, 8,11, 2,5,  MOUSE_COLOR_MID);

	// paint can body
	floodfill(flood, 8,6, MOUSE_COLOR_LIGHT);

	// paint can top
	line (flood, 3,5,  7,1,  MOUSE_COLOR_MID);

	/*
	// the paint can handle
	line (flood, 7,5,  11,1, MOUSE_COLOR_DARK);
	line (flood, 7,6,  12,1, MOUSE_COLOR_DARK);
	line (flood, 8,6,  12,2, MOUSE_COLOR_DARK);
	*/

	// the hot spot -- make it brighter
	putpixel(flood, 1, 15, MOUSE_COLOR_MID);
    }

    if (eye != NULL)
    {
	clear(eye);
	// the dropper
	line(eye, 1,0,  3,0,  MOUSE_COLOR_DARK);
	line(eye, 0,1,  0,6,  MOUSE_COLOR_DARK);
	line(eye, 4,1,  4,6,  MOUSE_COLOR_DARK);
	line(eye, 0,6,  4,6,  MOUSE_COLOR_DARK);
	floodfill(eye, 2,2,   MOUSE_COLOR_DARK);
	// the vial
	line(eye, 1,7,  1,12, MOUSE_COLOR_MID);
	line(eye, 3,7,  3,12, MOUSE_COLOR_MID);
	line(eye, 2,13, 2,14, MOUSE_COLOR_MID);
	floodfill(eye, 2,8,   MOUSE_COLOR_LIGHT);
    }

    set_mouse_sprite_focus(0,0);
}