Пример #1
0
/**
 * Draw the current frame
 */
static void ms_draw(struct stMenustate *ms) {
    char optionsEN[] = "  CONTINUE  \n"
                       "  NEW GAME  \n"
                       "  OPTIONS   \n"
                       "  QUIT";
    char optionsPT[] = "  CONTINUAR \n"
                       "  NOVO JOGO \n"
                       "  OPCOES    \n"
                       "  SAIR";
    char devTextEN[]   = "A GAME BY";
    char devTextPT[]   = "UM JOGO DE";
    char twitterText[] = "@SIRGFM";
    char *options, *devText;
    
    if (gl_lang == EN_US) {
        options = optionsEN;
        devText = devTextEN;
    }
    else if (gl_lang == PT_BR) {
        options = optionsPT;
        devText = devTextPT;
    }
    
    GFraMe_event_draw_begin();
        if (ms->isTitleSet) {
            int i, l;
            
            map_draw(ms->pM);
            // Put the 'selected' mark
            if (ms->curOpt < OPT_MAX) {
                i = 13 * ms->curOpt;
                options[i] = '-'; options[i+1] = '-';
            }
            // Render texts
            l = strlen(options) + 1;
            if (!ms->hasSave) {
                _ms_renderText(options, ms->textX, ms->textY + 8, 13/*i*/, l);
            }
            else {
                _ms_renderText(options, ms->textX, ms->textY, 0/*i*/, l);
            }
            l = strlen(devText) + 1;
            _ms_renderText(devText, ms->iconX - l*8, ms->iconY + 16, 0, l);
            l = strlen(twitterText) + 1;
            _ms_renderText(twitterText, ms->iconX - l*8, ms->iconY + 24, 0, l);
            // Render the dev icon
            GFraMe_spriteset_draw(gl_sset32x32, GFM_ICON, ms->iconX, ms->iconY, 0);
            // Draw both characters
            GFraMe_spriteset_draw(gl_sset32x32, 20, 18*8+4, 11*8-13, 0);
            // Draw the 'heartup' terminal
            obj_draw(ms->pO);
        }
        
        // Draw the title
        GFraMe_spriteset_draw(gl_sset64x32, J_TILE, ms->j1X, ms->j1Y, 0);
        GFraMe_spriteset_draw(gl_sset64x32, J_TILE, ms->j2X, ms->j2Y, 0);
        GFraMe_spriteset_draw(gl_sset64x32, A_TILE, ms->aX, ms->aY, 0);
        GFraMe_spriteset_draw(gl_sset64x32, T_TILE, ms->tX, ms->tY, 0);
    GFraMe_event_draw_end();
}
Пример #2
0
GFraMe_ret GFraMe_tilemap_draw(GFraMe_tilemap *tmap) {
	int i;
	GFraMe_ret rv = GFraMe_ret_ok;
	// TODO check which rect is inside the screen and draw only that!
/*
	// stupid way to use only one loop and no if *inside* the loop
	i = 0;
	int x = 0;
	int y = 0;
	while (i < tmap->num_tiles) {
		rv = GFraMe_spriteset_draw(tmap->sset, tmap->data[i],
								   tmap->x + x*tmap->sset->tw,
								   tmap->y + y);
		GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to draw tilemap",
						 _ret);
		x++;
		y += tmap->sset->th * (x >= width_in_tiles);
		x -= width_in_tiles * (x >= width_in_tiles);
		i++;
	}
*/
	// Loop each row
	i = 0;
	while (i < tmap->width_in_tiles) {
		int j;
		// Loop each column
		j = 0;
		while (j < tmap->height_in_tiles) {
			char tile = tmap->data[i + j*tmap->width_in_tiles];
			if (tile > 0)
				rv = GFraMe_spriteset_draw(tmap->sset,
									tmap->data[i + j*tmap->width_in_tiles],
									tmap->x + i*tmap->sset->tw,
									tmap->y + j*tmap->sset->th, 0);
			GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to draw tilemap",
							 _ret);
			j++;
		}
		i++;
	}
_ret:
	return rv;
}
Пример #3
0
/**
 * Render some text into the screen
 * 
 * @param text The text
 * @param X Horizontal position
 * @param Y Vertical position
 * @param l Text length
 */
static void _op_renderText(char *text, int X, int Y, int l) {
    int i, x, y;
    
    i = 0;
    x = X*8;
    y = Y * 10;
    // Draw the text
    while (i < l) {
        char c;
        
        c = text[i];
        
        if (c == '\n') {
            x = X - 8;
            y += 8;
        }
        else if (c != ' ')
            GFraMe_spriteset_draw(gl_sset8x8, c-'!', x, y, 0/*flipped*/);
        
        x += 8;
        i++;
    }
}