Exemple #1
0
void display_menu(MENU *menu)
{
  int i;

  cls();
  title(menu->title);
  mvcur(0, 0, STARTROW, STARTCOL);
  refresh();
  for (i = 0; i <= menu->num_items - 1; i++)
    {
      move(STARTROW + i, STARTCOL);
      standend();
      addstr(menu->items[i]);
      refresh();
    }
  center_text(STARTROW + menu->num_items + 2,
	      "Enter a number, <up arrow>, or <down arrow>.");
  if (!level)
    {
      center_text(STARTROW + menu->num_items + 3,
		  "Press 'q' to exit, <return> to confirm choice.");
    }
  else
    {
      center_text(STARTROW + menu->num_items + 3,
		  "Press 'q' to exit, 'r' for main menu, "
		  "<return> to confirm choice.");
    }

  if (!level)
    highlight(main_menu);
}
Exemple #2
0
void button_init_ui(button *b, const char *text, int size)
{
    b->touch_id = -1;

    if(text != NULL)
    {
        b->c[CLR_NORMAL][0] = C_HIGHLIGHT_BG;
        b->c[CLR_NORMAL][1] = C_HIGHLIGHT_TEXT;
        b->c[CLR_HOVER][0] = C_HIGHLIGHT_HOVER;
        b->c[CLR_HOVER][1] = C_HIGHLIGHT_TEXT;
        b->c[CLR_DIS][0] = GRAY;
        b->c[CLR_DIS][1] = WHITE;
        b->c[CLR_CHECK][0] = C_HIGHLIGHT_BG;
        b->c[CLR_CHECK][1] = C_HIGHLIGHT_TEXT;

        b->rect = fb_add_rect_lvl(b->level_off + LEVEL_RECT, b->x, b->y, b->w, b->h, b->c[CLR_NORMAL][0]);

        fb_text_proto *p = fb_text_create(0, 0, b->c[CLR_NORMAL][1], size, text);
        p->level = b->level_off + LEVEL_TEXT;
        b->text = fb_text_finalize(p);
        center_text(b->text, b->x, b->y, b->w, b->h);
    }
    else
    {
        b->text = NULL;
        b->rect = NULL;
    }

    add_touch_handler(&button_touch_handler, b);
}
static void init_header(multirom_theme_data *t)
{
    button **tab_btns = t->tab_btns;
    fb_text **tab_texts = t->tab_texts;
    const int TAB_BTN_WIDTH = fb_width*0.21;
    int i;
    int x = fb_width - (TAB_BTN_WIDTH*TAB_COUNT);
    static const char *str[] = { "Internal", "External", "Misc", "MultiROM" };
    char buff[64];

    fb_add_rect_lvl(100, 0, 0, fb_width, HEADER_HEIGHT, C_HIGHLIGHT_BG);
    ncard_set_top_offset(HEADER_HEIGHT);

    int maxW = 0;
    for(i = 0; i < TAB_COUNT; ++i)
    {
        fb_text_proto *p = fb_text_create(0, 0, C_HIGHLIGHT_TEXT, SIZE_BIG, str[i]);
        p->level = 110;
        tab_texts[i] = fb_text_finalize(p);
        maxW = imax(maxW, tab_texts[i]->w);
    }

    maxW += (30*DPI_MUL);
    x = fb_width/2 - (maxW*TAB_COUNT)/2;

    snprintf(buff, sizeof(buff), ":/miri_%dx%d.png", (int)MIRI_W, (int)MIRI_W);
    fb_img *logo = fb_add_png_img_lvl(110, 10*DPI_MUL, HEADER_HEIGHT/2 - MIRI_W/2, MIRI_W, MIRI_W, buff);
    if(logo)
    {
        pong_btn = mzalloc(sizeof(button));
        pong_btn->x = logo->x;
        pong_btn->y = logo->y;
        pong_btn->w = logo->w;
        pong_btn->h = logo->h;
        pong_btn->clicked = &multirom_ui_start_pong;
        button_init_ui(pong_btn, NULL, 0);
    }

    for(i = 0; i < TAB_COUNT; ++i)
    {
        center_text(tab_texts[i], x, 0, maxW, HEADER_HEIGHT);

        tab_btns[i] = mzalloc(sizeof(button));
        tab_btns[i]->x = x;
        tab_btns[i]->y = 0;
        tab_btns[i]->w = maxW;
        tab_btns[i]->h = HEADER_HEIGHT;
        tab_btns[i]->action = i;
        tab_btns[i]->clicked = &multirom_ui_switch;
        tab_btns[i]->level_off = 100;
        button_init_ui(tab_btns[i], "", 0);

        keyaction_add(tab_btns[i], button_keyaction_call, tab_btns[i]);

        x += maxW;
    }

    t->selected_tab_rect = fb_add_rect_lvl(110, tab_btns[0]->x, HEADER_HEIGHT-SELECTED_RECT_H, maxW, SELECTED_RECT_H, C_HIGHLIGHT_TEXT);
    t->tabs = tabview_create(0, HEADER_HEIGHT, fb_width, fb_height-HEADER_HEIGHT);
}
SubdRepresentation::SubdRepresentation(Rectangle rect, Crop& crop, QDate date) :
    rect(rect), crop(crop)
{
    this->setRect(get_rect().get_x(), - get_rect().get_y() - get_rect().get_height(),
                  get_rect().get_width(), get_rect().get_height());
    if (crop)
    {
        Plant& plant = crop.get_plant();
        QString text = toQString(plant.get_name());
        //text = re.sub("\s+", "\n", text)
        QGraphicsSimpleTextItem *textw =  new QGraphicsSimpleTextItem(text);
        QFont font = textw->font();
        font.setPointSize(6);
        font.setWeight(25);
        textw->setFont(font);
        center_text(textw, this->boundingRect());
        textw->setParentItem(this);
        QString color_str = toQString(plant.get_color_str());
        if (color_str == "") { color_str = "#FF00FF"; }
        QColor color = QColor(color_str);
        if (crop.is_planned_at_date(fromQDate(date)) && !crop.is_active_at_date(fromQDate(date)))
        {
            this->setBrush(QBrush(color, Qt::BDiagPattern));
        }
        else
        {
            this->setBrush(QBrush(color));
        }
    }
}
static void init_header(multirom_theme_data *t)
{
    button **tab_btns = t->tab_btns;
    fb_text **tab_texts = t->tab_texts;
    const int TAB_BTN_WIDTH = fb_width*0.21;
    int i, x;
    static const char *str[] = { "INTERNAL", "EXTERNAL", "MISC" };
    char buff[64];

    fb_add_rect_lvl(100, 0, 0, fb_width, HEADER_HEIGHT, C_HIGHLIGHT_BG);
    fb_add_rect(0, HEADER_HEIGHT, fb_width, (3*DPI_MUL), C_BTN_FAKE_SHADOW);
    ncard_set_top_offset(HEADER_HEIGHT);

    int maxW = 0;
    for(i = 0; i < TAB_COUNT; ++i)
    {
        fb_text_proto *p = fb_text_create(0, 0, C_HIGHLIGHT_TEXT, SIZE_NORMAL, str[i]);
        p->level = 110;
        p->style = STYLE_MEDIUM;
        tab_texts[i] = fb_text_finalize(p);
        maxW = imax(maxW, tab_texts[i]->w);
    }

    maxW += (30*DPI_MUL);
    x = fb_width/2 - (maxW*TAB_COUNT)/2;

    snprintf(buff, sizeof(buff), ":/miri_%dx%d.png", (int)MIRI_W, (int)MIRI_W);
    fb_add_png_img_lvl(110, 10*DPI_MUL, HEADER_HEIGHT/2 - MIRI_W/2, MIRI_W, MIRI_W, buff);

    for(i = 0; i < TAB_COUNT; ++i)
    {
        center_text(tab_texts[i], x, 0, maxW, HEADER_HEIGHT);

        tab_btns[i] = mzalloc(sizeof(button));
        tab_btns[i]->x = x;
        tab_btns[i]->y = 0;
        tab_btns[i]->w = maxW;
        tab_btns[i]->h = HEADER_HEIGHT;
        tab_btns[i]->clicked_data = malloc(sizeof(int));
        *((int*)tab_btns[i]->clicked_data) = i;
        tab_btns[i]->clicked = &multirom_ui_switch_btn;
        tab_btns[i]->level_off = 100;
        button_init_ui(tab_btns[i], "", 0);

        keyaction_add(tab_btns[i], button_keyaction_call, tab_btns[i]);

        x += maxW;

         if(i < TAB_COUNT-1)
            t->selected_rect[i] = fb_add_rect_lvl(120, 0, 0, 0, 0, (0x4C << 24) | (C_HIGHLIGHT_BG & 0x00FFFFFF));
    }

    t->selected_tab_rect = fb_add_rect_lvl(110, tab_btns[0]->x, HEADER_HEIGHT-SELECTED_RECT_H + (3*DPI_MUL), maxW, SELECTED_RECT_H, C_HIGHLIGHT_TEXT);
    t->tabs = tabview_create(0, HEADER_HEIGHT, fb_width, fb_height-HEADER_HEIGHT);
    header_set_tab_selector_pos(t, 0.f);
}
Exemple #6
0
void start_menu() {
	int i;
	clear_display();
	center_text(TITLE, 0);
	for (i = 0; i < TITLE_ROWS; i++)
		put_string_display(TITLE_TEXT[i], 5, i+1);
	
	start_menu_selection = 0;
	put_string_display("*", 3, 1);
}
Exemple #7
0
void button_move(button *b, int x, int y)
{
    b->x = x;
    b->y = y;

    if(b->text)
    {
        b->rect->x = x;
        b->rect->y = y;

        center_text(b->text, b->x, b->y, b->w, b->h);
    }
}
Exemple #8
0
Button::Button(Canvas *the_canvas, Font *the_font, const char *the_text) {
	init(the_canvas, the_font, the_text);

	set_colors(BUTTON_DEFAULT_COLORS, BUTTON_DEFAULT_COLORS);
	colors[BUTTON_DISABLED] = BUTTON_DISABLED_COLORS;

	x = 0;
	y = 0;

	width = font->string_width(text) + BUTTON_DEFAULT_PADDING;
	height = font->get_font_height() + BUTTON_DEFAULT_PADDING;

	center_text();

	state = BUTTON_NORMAL;
}
Exemple #9
0
void Button::set_width(u32 new_width) {
	width = new_width;

	center_text();
}
Exemple #10
0
void glk_main(void)
{
    winid_t win_a = NULL, win_b = NULL, win_c = NULL, win_d = NULL;
	
	fprintf(stderr, "TEST CASES FROM GLK SPEC\n\n"
			"(Press a key in window A to continue each time)\n\n"
			"Say you do two splits, each a 50-50 percentage split. You start\n"
			"with the original window A, and split that into A and B; then\n"
			"you split B into B and C.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Or, you could split A into A and B, and then split A\n"
			"again into A and C.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Here are more ways to perform the first example; all of\n"
			"them have the same tree structure, but look different on the\n"
			"screen. Here, we turn the second split (B into B/C) upside down;\n"
			"we put the new window (C) above the old window (B).\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Above,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
			
	fprintf(stderr, "Here, we mess with the percentages. The first split (A\n"
			"into A/B) is a 25-75 split, which makes B three times the size\n"
			"of A. The second (B into B/C) is a 33-66 split, which makes C\n"
			"twice the size of B. This looks rather like the second example,\n"
			"but has a different internal structure.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							75, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Below,
							67, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Here, the second split (B into B/C) is vertical instead\n"
			"of horizontal, with the new window (C) on the left of the old\n"
			"one.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Left,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "In the following two-split process, you can see that\n"
			"when a window is split, it is replaced by a new pair window, and\n"
			"moves down to become one of its two children.\n\n");
	
	if(!(win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	wait_for_key(win_a);
	
	if(!(win_b = glk_window_open(win_a, 
								 winmethod_Proportional | winmethod_Below,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	if(!(win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Left,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "What happens when there is a conflict? The rules are\n"
			"simple. Size control always flows down the tree, and the player\n"
			"is at the top. Let's bring out an example: first we split A into\n"
			"A and B, with a 50%% proportional split. Then we split A into A\n"
			"and C, with C above, being a text grid window, and C gets a\n"
			"fixed size of two rows (as measured in its own font size). A\n"
			"gets whatever remains of the 50%% it had before.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above,
							2, wintype_TextGrid, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B: 50%");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 1) Now the player stretches the window\n"
			"vertically.\n\n");
	
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 2) Then the user maliciously starts squeezing the\n"
			"window down, in stages.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B: 50%");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 3) The logic remains the same. At stage 3,\n"
			"there's no room left for A, so it winds up with zero height.\n"
			"Nothing displayed in A will be visible.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 4) At stage 4, there isn't even room in the upper\n"
			"50%% to give C its two rows; so it only gets one.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 5) Finally, C is squashed out of existence as\n"
			"well.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "What happens when you split a fixed-size window? The\n"
			"resulting pair window retains the same size constraint as the\n"
			"original window that was split. The key window for the original\n"
			"split is still the key window for that split, even though it's\n"
			"now a grandchild instead of a child.\n\n");
	
	if(!(win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	wait_for_key(win_a);
	
	fprintf(stderr, "After the first split, the new pair window (O1, which\n"
			"covers the whole screen) knows that its first child (A) is above\n"
			"the second, and gets 50%% of its own area. (A is the key window\n"
			"for this split, but a proportional split doesn't care about key\n"
			"windows.)\n\n");
	
	if(!(win_b = glk_window_open(win_a, 
								 winmethod_Proportional | winmethod_Below,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A: 50%");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	fprintf(stderr, "After the second split, all this remains true; O1 knows\n"
			"that its first child gets 50%% of its space, and A is O1's key\n"
			"window. But now O1's first child is O2 instead of A. The newer\n"
			"pair window (O2) knows that its first child (C) is above the\n"
			"second, and gets a fixed size of two rows. (As measured in C's\n"
			"font, because C is O2's key window.)\n\n");
	
	if(!(win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above, 2,
								 wintype_TextGrid, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "If we split C, now, the resulting pair will still be two\n"
			"C-font rows high -- that is, tall enough for two lines of\n"
			"whatever font C displays. For the sake of example, we'll do this\n"
			"vertically.\n\n");
	
	if(!(win_d = glk_window_open(win_c, 
								 winmethod_Proportional | winmethod_Right,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "When you close a window (and it is not the root window),\n"
			"the other window in its pair takes over all the freed-up area.\n"
			"Let's close D, in the current example:\n\n");
	
	glk_window_close(win_d, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "But what if we had closed C instead of D? We would have\n"
			"gotten this:\n\n");
	
	glk_window_close(glk_window_get_root(), NULL);
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below, 50,
							wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above, 2,
							wintype_TextGrid, 0);
	win_d = glk_window_open(win_c, winmethod_Proportional | winmethod_Right, 50,
							wintype_TextBuffer, 0);
	glk_window_close(win_c, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Consider the example above, where D had collapsed to\n"
			"zero height. Say D was a text buffer window. You could make a\n"
			"more useful layout:\n\n");
	winid_t o2 = glk_window_get_parent(win_d);
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Fixed, 3, win_d);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "If you later wanted to expand D to five rows:\n\n");
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Fixed, 5, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "This changes the constraint to be on the lower child of\n"
			"O2, which is A. The key window is still D; so A would then be\n"
			"three rows high as measured in D's font, and D would get the\n"
			"rest of O2's space. That may not be what you want.\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Fixed, 3, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "To set A to be three rows high as measured in A's font,\n"
			"you would do:\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Fixed, 3, win_a);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Or you could change O2 to a proportional split:\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Proportional, 30,
							   NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Or:\n\n");
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Proportional, 70,
							   NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	glk_window_close(win_d, NULL);
	glk_window_close(win_b, NULL);
	glk_window_clear(win_a);
	glk_set_window(win_a);
	glk_put_string("That's all, folks...");
}
Exemple #11
0
void pong(void)
{
    enable_computer = 1;
    paddle_touch_id[L] = -1;
    paddle_touch_id[R] = -1;

    score_val[L] = 0;
    score_val[R] = 0;

    fb_set_background(BLACK);

    fb_text_proto *p = fb_text_create(0, 0, GRAYISH, SIZE_SMALL, "Press power button to go back");
    p->style = STYLE_ITALIC;
    fb_text *help = fb_text_finalize(p);
    help->y = fb_height/2 - help->h*1.5;
    center_text(help, 0, -1, fb_width, -1);

    // middle line
    fb_add_rect(0, fb_height/2 - 1, fb_width, 1, WHITE);

    score[L] = fb_add_text(0, 0, WHITE, SIZE_EXTRA, "0");
    score[L]->y = fb_height/2 - score[L]->h - 20*DPI_MUL;
    score[R] = fb_add_text(0, fb_height/2 + 20*DPI_MUL, WHITE, SIZE_EXTRA, "0");

    paddles[L] = fb_add_rect(100, PADDLE_Y, PADDLE_W, PADDLE_H, WHITE);
    paddles[R] = fb_add_rect(100, fb_height-PADDLE_Y-PADDLE_H, PADDLE_W, PADDLE_H, WHITE);

    ball = fb_add_rect(0, 0, BALL_W, BALL_W, WHITE);

    pong_spawn_ball(rand()%2);
    pong_calc_movement();

    add_touch_handler(&pong_touch_handler, NULL);

    int step = 0;
    volatile int run = 1;
    while(run)
    {
        switch(get_last_key())
        {
            case KEY_POWER:
                run = 0;
                break;
            case KEY_VOLUMEUP:
                ball_speed += 5;
                pong_spawn_ball(rand()%2);
                pong_calc_movement();
                step = 0;
                break;
            case KEY_VOLUMEDOWN:
                if(ball_speed > 5)
                    ball_speed -= 5;
                pong_spawn_ball(rand()%2);
                pong_calc_movement();
                step = 0;
                break;
        }

        step = pong_do_movement(step);

        fb_request_draw();
        usleep(16000);
    }

    rm_touch_handler(&pong_touch_handler, NULL);

    list_clear(&movement_steps, &free);
}
Exemple #12
0
void Button::center_x() {
	x = (canvas->get_width() - width) / 2;
	center_text();
}
Exemple #13
0
static void prepare_about(void) {
	clear_text();
	center_text(-1, screen_height - FONT_H * 2, "mpflow Copyright (C) 2009 Walter de Jong <*****@*****.**>", YELLOW);
}
Exemple #14
0
void Button::set_text(const char *new_text) {
	strncpy(text, new_text, MAX_BUTTON_TEXT_LENGTH);
	center_text();
}
Exemple #15
0
void Button::set_height(u32 new_height) {
	height = new_height;

	center_text();
}
Exemple #16
0
void Button::center_y() {
	y = (canvas->get_height() - height) / 2;
	center_text();
}
Exemple #17
0
void Button::set_y(u32 new_y) {
	y = new_y;

	center_text();
}
Exemple #18
0
void Button::set_x(u32 new_x) {
	x = new_x;

	center_text();
}
Exemple #19
0
void Button::set_position(u32 new_x, u32 new_y) {
	x = new_x;
	y = new_y;

	center_text();
}