Hopefully last commit
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
|
||||
#define HEALTH_MARGIN 4
|
||||
|
||||
Player mainPlayer;
|
||||
|
||||
int playerSpeed = 2;
|
||||
|
||||
int playerReach = DISPLAY_MAP_HEIGHT / 2 - 2;
|
||||
int playerReach = 5;
|
||||
|
||||
SDL_Texture *entityTexture;
|
||||
SDL_Texture *hudTexture;
|
||||
@@ -112,8 +114,8 @@ void initPlayer(Player *plr) {
|
||||
plr->health = 64;
|
||||
plr->healthIdle = 0;
|
||||
|
||||
plr->rect.x = DISPLAY_WIDTH / 2;
|
||||
plr->rect.y = DISPLAY_HEIGHT / 2;
|
||||
plr->rect.x = 10 * TILE_SIZE;
|
||||
plr->rect.y = (MAP_HEIGHT - 10) * TILE_SIZE;
|
||||
plr->rect.w = TILE_SIZE;
|
||||
plr->rect.h = TILE_SIZE;
|
||||
|
||||
@@ -140,17 +142,17 @@ void initPlayer(Player *plr) {
|
||||
plr->cursor.targetTileRect.h = TILE_SIZE;
|
||||
|
||||
targetItemBGRect.w = DISPLAY_WIDTH;
|
||||
targetItemBGRect.h = TILE_SIZE + fonts[2].size * 2;
|
||||
targetItemBGRect.x = 0;
|
||||
targetItemBGRect.y = DISPLAY_HEIGHT - TILE_SIZE - fonts[2].size * 2;
|
||||
targetItemBGRect.h = (TILE_SIZE / 2) + fonts[2].size * 2;
|
||||
targetItemBGRect.y = DISPLAY_HEIGHT - (TILE_SIZE / 2) - fonts[2].size * 2;
|
||||
|
||||
waveInfoBGRect.y = 0;
|
||||
waveInfoBGRect.x = 0;
|
||||
waveInfoBGRect.w = 380;
|
||||
waveInfoBGRect.w = 450;
|
||||
waveInfoBGRect.h = 80;
|
||||
|
||||
targetItemRect.w = TILE_SIZE;
|
||||
targetItemRect.h = TILE_SIZE;
|
||||
targetItemRect.w = TILE_SIZE / 2;
|
||||
targetItemRect.h = TILE_SIZE / 2;
|
||||
|
||||
plr->cursor.heldItemRect.w = TILE_SIZE;
|
||||
plr->cursor.heldItemRect.h = TILE_SIZE;
|
||||
@@ -172,8 +174,8 @@ void updatePlayer(Player *plr) {
|
||||
plr->prevHealth = plr->health;
|
||||
|
||||
if (plr->health <= 0) {
|
||||
plr->rect.x = DISPLAY_WIDTH / 2;
|
||||
plr->rect.y = DISPLAY_HEIGHT / 2;
|
||||
plr->rect.x = 10 * TILE_SIZE;
|
||||
plr->rect.y = (MAP_HEIGHT - 10) * TILE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +187,8 @@ void renderPlayer(Player *plr) {
|
||||
SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 0);
|
||||
|
||||
SDL_SetRenderTarget(mainRenderer, entityTexture);
|
||||
SDL_RenderCopy(mainRenderer, atlasTexture, &playerTextureRect, &PlayerRect);
|
||||
double angle = angle_between_points_deg(PlayerRect.x, PlayerRect.y, plr->cursor.windowX, plr->cursor.windowY) + 90;
|
||||
SDL_RenderCopyEx(mainRenderer, atlasTexture, &playerTextureRect, &PlayerRect, angle, NULL, SDL_FLIP_NONE);
|
||||
//SDL_RenderCopy(mainRenderer, PlayerTexture, NULL, &PlayerRect);
|
||||
SDL_SetRenderTarget(mainRenderer, hudTexture);
|
||||
SDL_RenderClear(mainRenderer);
|
||||
@@ -255,21 +258,24 @@ void renderPlayer(Player *plr) {
|
||||
|
||||
|
||||
SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 255);
|
||||
targetItemBGRect.h = (TILE_SIZE / 2) + fonts[2].size * 2;
|
||||
targetItemBGRect.w = DISPLAY_WIDTH;
|
||||
targetItemBGRect.y = DISPLAY_HEIGHT - (TILE_SIZE / 2) - fonts[2].size * 2;
|
||||
SDL_RenderFillRect(mainRenderer, &targetItemBGRect);
|
||||
SDL_RenderFillRect(mainRenderer, &waveInfoBGRect);
|
||||
|
||||
|
||||
char hudStr[50];
|
||||
char waveStr[30];
|
||||
char hudStr[80];
|
||||
char waveStr[50];
|
||||
if (entities.activeCount > 0) {
|
||||
snprintf(waveStr, 30, "Remaining enemies: %d", entities.activeCount);
|
||||
snprintf(waveStr, 50, "Remaining enemies: %d", entities.activeCount);
|
||||
} else {
|
||||
snprintf(waveStr, 30, "Next wave in: %dm %ds", waveInfo.waveTimer / 60, waveInfo.waveTimer % 60);
|
||||
snprintf(waveStr, 50, "Next wave in: %dm %ds", waveInfo.waveTimer / 3600, (waveInfo.waveTimer / 60) % 60);
|
||||
}
|
||||
snprintf(hudStr, 30, "Wave: %d\n%s\n", waveInfo.waveCounter, waveStr);
|
||||
renderText(mainRenderer, fonts[1], hudStr, 0,0);
|
||||
snprintf(hudStr, 80, "Wave: %d/%d\n%s\n", waveInfo.waveCounter, waveInfo.totalWaves, waveStr);
|
||||
renderText(mainRenderer, fonts[1], hudStr, 0, 0);
|
||||
|
||||
targetItemRect.y = DISPLAY_HEIGHT - TILE_SIZE;
|
||||
targetItemRect.y = DISPLAY_HEIGHT - (TILE_SIZE / 2);
|
||||
targetItemRect.x = TILE_SIZE / 4;
|
||||
|
||||
SDL_SetTextureBlendMode(atlasTexture, SDL_BLENDMODE_ADD);
|
||||
@@ -310,7 +316,7 @@ void renderPlayer(Player *plr) {
|
||||
renderText(mainRenderer, fonts[2], itemStringCount, targetItemRect.x - 3,
|
||||
targetItemRect.y - (fonts[2].size * 3 / 2));
|
||||
//targetItemRect.x += (TILE_SIZE / 2) + (TILE_SIZE / 4);
|
||||
targetItemRect.x += TILE_SIZE / 2 * 3;
|
||||
targetItemRect.x += TILE_SIZE;
|
||||
}
|
||||
}
|
||||
SDL_SetTextureBlendMode(atlasTexture, SDL_BLENDMODE_BLEND);
|
||||
|
Reference in New Issue
Block a user