Beispiel #1
0
void menuDraw()
{
	int i;
	int drawPos = curMenu->menuDrawPos;

	if(curMenu == &mainMenu)
	{
		applySurface(screenWidth/2 - 56 , 5, gameLogoIMG, screen, NULL);
	}

	if(menuState == MENU_STATE_NORMAL)
	{
		for(i = 0; i < curMenu->count; i++)
		{
			int multipleChoiceIndex = curMenu->menuItems[i]->curMultipleChoiceIndex;
			dTextCentered(curMenu->menuItems[i]->text[multipleChoiceIndex], 0, 9 * i + drawPos);
		}
		dText(">", screenWidth / 2 - ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2, curMenu->selectedIndex * 9 + drawPos);
		dText("<", screenWidth / 2 + ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2 - 7, curMenu->selectedIndex * 9 + drawPos);
		//dText("*", 40, curMenu->selectedIndex * 9 + drawPos); // this is a quick hack and should be changed later
	}
	else if(menuState == MENU_STATE_REDEFINE_KEYS)
	{
		char *keyName[] = {"UP", "DOWN", "LEFT", "RIGHT", "ACTION", "JUMP", "OK", "BACK", "MENU"};
		char dialog[30];

		sprintf(dialog, "Press key for *%s*", keyName[remapCurKey]);
		dTextCentered(dialog, 0, screenHeight/2);
	}
}
Beispiel #2
0
void boardDraw()
{
	int i;
	int j;
	int x;
	int y;

	drawImage(boardBackgroundIMG, NULL, screen, 0, 0);

	for (i = 0, x = 0; x < BOARD_W; i+=STONE_W, ++x)
	{
		for (j = 0, y = 0; y < BOARD_H; j+=STONE_H, ++y)
		{
			if (stones[x][y].type > 0)
			{
				SDL_SetAlpha(stonesTileset.image, SDL_SRCALPHA, stones[x][y].alpha);
				drawImage(stonesTileset.image, &stonesTileset.clip[stones[x][y].type - 1], screen, BOARD_OFFSET_X + i - x, BOARD_OFFSET_Y + j - y);
				if (showStoneRank && stones[x][y].alpha == 255)
				{
					dText(&gameFontRegular, (char *)stoneRankText(stones[x][y].type), BOARD_OFFSET_X + i - x + 1, BOARD_OFFSET_Y + j - y + 1, SHADOW_OUTLINE);
				}
			}
		}
	}

	if (crossing)
	{
		boardDrawConnection();
	}

	if (!gameOver && !fadeOutTimer)
	{
		int rcolor = SDL_MapRGB(screen->format, 0, 0, 255);

		drawRectangle(screen, BOARD_OFFSET_X + cursorX * STONE_W - 1 - cursorX, BOARD_OFFSET_Y + cursorY * STONE_H - 1 - cursorY, STONE_W + 2, STONE_H + 2, rcolor);
		drawRectangle(screen, BOARD_OFFSET_X + cursorX * STONE_W - cursorX, BOARD_OFFSET_Y + cursorY * STONE_H - cursorY, STONE_W, STONE_H, rcolor);
		if (stoneA.type != STONE_EMPTY)
		{
			drawRectangle(screen, BOARD_OFFSET_X + stoneA.x * STONE_W - 1 - stoneA.x, BOARD_OFFSET_Y + stoneA.y * STONE_H - 1 - stoneA.y, STONE_W + 2, STONE_H + 2, rcolor);
			drawRectangle(screen, BOARD_OFFSET_X + stoneA.x * STONE_W - stoneA.x, BOARD_OFFSET_Y + stoneA.y * STONE_H - stoneA.y, STONE_W, STONE_H, rcolor);
		}
		if (stoneB.type != STONE_EMPTY)
		{
			drawRectangle(screen, BOARD_OFFSET_X + stoneB.x * STONE_W - 1 - stoneB.x, BOARD_OFFSET_Y + stoneB.y * STONE_H - 1 - stoneB.y, STONE_W + 2, STONE_H + 2, rcolor);
			drawRectangle(screen, BOARD_OFFSET_X + stoneB.x * STONE_W - stoneB.x, BOARD_OFFSET_Y + stoneB.y * STONE_H - stoneB.y, STONE_W, STONE_H, rcolor);
		}
	}
}
Beispiel #3
0
void dTextCentered(font *fontObj, char *string, int y, shadowType withShadow)
{
	int width = 0;
	int len = strlen(string);
	int i;

	for (i = 0; string[i] != '\0'; ++i)
	{
		if (string[i] == '\n') // line break
			break;

		width += fontObj->w;
		if (i < len - 1)
			width += fontObj->tracking;
	}

	dText(fontObj, string, SCREEN_W/2 - width/2, y, withShadow);
}