Initial save commit contains recent premerge content!
This commit is contained in:
parent
85be40dcda
commit
8b8771fd41
BIN
bin/assets/images/return_button.png
Normal file
BIN
bin/assets/images/return_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 8.0 KiB |
@ -151,6 +151,7 @@ void BREAKOUT_Update(Scenery * scenery, const Uint8 * keystate){
|
||||
PADDLE_ResetPosition(&(scenery->paddle));
|
||||
scenery->StartCountdown = 240;
|
||||
scenery->IsGameOver = false;
|
||||
scenery->Frames = 0;
|
||||
if (--(scenery->Lives) <= 0)
|
||||
GAME_ChangeState(GameOver);
|
||||
else
|
||||
|
45
gameover.c
45
gameover.c
@ -9,47 +9,47 @@
|
||||
|
||||
#include "gameover.h"
|
||||
#include "gamestate.h"
|
||||
#include "breakout.h"
|
||||
#include "vector.h"
|
||||
#include "background.h"
|
||||
#include "main.h"
|
||||
|
||||
#define GAMEOVER_TexturePath "assets/images/gameover.png"
|
||||
#define GAMEOVER_NumbersTexturePath "assets/images/numbers.png"
|
||||
#define GAMEOVER_ScoreTexturePath "assets/images/yourscore.png"
|
||||
#define GAMEOVER_UploadTexturePath "assets/images/upload.png"
|
||||
#define GAMEOVER_HUDScale 16.0f
|
||||
#define GAMEOVER_Scale 4.0f
|
||||
|
||||
extern int width, height;
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
#include "breakout.h"
|
||||
#include "vector.h"
|
||||
#include "background.h"
|
||||
|
||||
int GAMEOVER_HUDMargin = 5;
|
||||
SDL_Texture * GAMEOVER_Texture;
|
||||
SDL_Texture * GAMEOVER_Numbers;
|
||||
SDL_Texture * GAMEOVER_ScoreTexture;
|
||||
SDL_Texture * GAMEOVER_UploadTexture;
|
||||
SDL_Rect * GAMEOVER_NumberRects;
|
||||
SDL_Rect * GAMEOVER_UploadRects;
|
||||
SDL_Rect GAMEOVER_TargetRect;
|
||||
SDL_Rect GAMEOVER_ScoreTargetRect;
|
||||
SDL_Rect GAMEOVER_HUDScoreTargetRect;
|
||||
SDL_Rect GAMEOVER_UploadTargetRect;
|
||||
int * GAMEOVER_Digits;
|
||||
bool GAMEOVER_IsInit = false;
|
||||
UploadState GAMEOVER_UploadState = Initial;
|
||||
|
||||
void GAMEOVER_Initialize(SDL_Renderer * renderer){
|
||||
if (!GAMEOVER_IsInit) {
|
||||
printf("Initializing Gameover...\n");
|
||||
GAMEOVER_UploadState = Initial;
|
||||
GAMEOVER_Texture = IMG_LoadTexture(renderer, GAMEOVER_TexturePath);
|
||||
if (!GAMEOVER_Texture) printf("Gameover Texture couldn't be loaded!\n");
|
||||
GAMEOVER_Numbers = IMG_LoadTexture(renderer, GAMEOVER_NumbersTexturePath);
|
||||
if (!GAMEOVER_Numbers) printf("Gameover Numbers couldn't be loaded!\n");
|
||||
GAMEOVER_ScoreTexture = IMG_LoadTexture(renderer, GAMEOVER_ScoreTexturePath);
|
||||
if (!GAMEOVER_ScoreTexture) printf("Gameover Score Texture couldn't be loaded!\n");
|
||||
GAMEOVER_UploadTexture = IMG_LoadTexture(renderer, GAMEOVER_UploadTexturePath);
|
||||
if (!GAMEOVER_UploadTexture) printf("Gameover Score Texture couldn't be loaded!\n");
|
||||
int w, h;
|
||||
SDL_QueryTexture(GAMEOVER_Texture, NULL, NULL, &w, &h);
|
||||
w /= 2;
|
||||
@ -73,12 +73,6 @@ void GAMEOVER_Initialize(SDL_Renderer * renderer){
|
||||
GAMEOVER_ScoreTargetRect.y = 450;
|
||||
GAMEOVER_ScoreTargetRect.h = 183;
|
||||
GAMEOVER_ScoreTargetRect.w = 1000;
|
||||
GAMEOVER_UploadTargetRect = (SDL_Rect) {.x = 0, .y = 600, .w = 1000, .h = 200 };
|
||||
GAMEOVER_UploadRects = calloc(3, sizeof(SDL_Rect));
|
||||
if (!GAMEOVER_UploadRects) printf("FATAL: Memory Allocation Failed!\n");
|
||||
GAMEOVER_UploadRects[0] = (SDL_Rect) {.x = 1, .y = 735, .w = 3981, .h = 734 };
|
||||
GAMEOVER_UploadRects[1] = (SDL_Rect) {.x = 1, .y = 1, .w = 4634, .h = 732 };
|
||||
GAMEOVER_UploadRects[2] = (SDL_Rect) {.x = 1, .y = 1471, .w = 3024, .h = 666 };
|
||||
GAMEOVER_HUDScoreTargetRect = (SDL_Rect) {.x = GAMEOVER_HUDMargin, .y = GAMEOVER_HUDMargin, .w = 250, .h = 46 };
|
||||
GAMEOVER_Digits = malloc(25 * sizeof(int));
|
||||
printf("Gameover initialized!\n");
|
||||
@ -106,18 +100,10 @@ void GAMEOVER_Draw(SDL_Renderer * renderer, Scenery * scenery){
|
||||
target.h = (int)roundf((float)(GAMEOVER_NumberRects[GAMEOVER_Digits[i]].h) / GAMEOVER_Scale);
|
||||
target.w = (int)roundf((float)(GAMEOVER_NumberRects[GAMEOVER_Digits[i]].w) / GAMEOVER_Scale);
|
||||
SDL_RenderCopy(renderer, GAMEOVER_Numbers, (GAMEOVER_NumberRects + GAMEOVER_Digits[i]), &target);
|
||||
xOffset += target.w - 1;
|
||||
xOffset += target.w;
|
||||
}
|
||||
GAMEOVER_DrawHorizontalCenter(renderer, GAMEOVER_UploadTexture, (GAMEOVER_UploadRects + GAMEOVER_UploadState), &GAMEOVER_UploadTargetRect);
|
||||
} /* GAMEOVER_Draw */
|
||||
|
||||
void GAMEOVER_DrawHorizontalCenter(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Rect * srcRect, SDL_Rect * dstRect){
|
||||
SDL_Rect target = *dstRect;
|
||||
|
||||
target.x = ((width - target.x) / 2);
|
||||
SDL_RenderCopy(renderer, texture, srcRect, &target);
|
||||
}
|
||||
|
||||
void GAMEOVER_GetDigits(int input, int * digitCount){
|
||||
int score = input;
|
||||
int count = 0;
|
||||
@ -151,7 +137,7 @@ void SCORE_DrawHUD(SDL_Renderer * renderer, Scenery * scenery){
|
||||
target.h = (int)roundf((float)(GAMEOVER_NumberRects[GAMEOVER_Digits[i]].h) / GAMEOVER_HUDScale);
|
||||
target.w = (int)roundf((float)(GAMEOVER_NumberRects[GAMEOVER_Digits[i]].w) / GAMEOVER_HUDScale);
|
||||
SDL_RenderCopy(renderer, GAMEOVER_Numbers, (GAMEOVER_NumberRects + GAMEOVER_Digits[i]), &target);
|
||||
xOffset += target.w - 1;
|
||||
xOffset += target.w;
|
||||
}
|
||||
} /* SCORE_DrawHUD */
|
||||
|
||||
@ -159,12 +145,9 @@ void GAMEOVER_Deinitialize(){
|
||||
if (GAMEOVER_IsInit) {
|
||||
printf("De-initializing Gameover...\n");
|
||||
free(GAMEOVER_Digits);
|
||||
free(GAMEOVER_NumberRects);
|
||||
free(GAMEOVER_UploadRects);
|
||||
SDL_DestroyTexture(GAMEOVER_Texture);
|
||||
SDL_DestroyTexture(GAMEOVER_ScoreTexture);
|
||||
SDL_DestroyTexture(GAMEOVER_Numbers);
|
||||
SDL_DestroyTexture(GAMEOVER_UploadTexture);
|
||||
printf("Gameover de-initialized!\n");
|
||||
GAMEOVER_IsInit = false;
|
||||
} else
|
||||
|
@ -14,14 +14,9 @@
|
||||
#include "gamestate.h"
|
||||
#include "main.h"
|
||||
|
||||
// Enums
|
||||
typedef enum uploadStateEnum { Initial = 0, Uploading = 1, Finished = 2 } UploadState;
|
||||
// Enums
|
||||
|
||||
// Prototypes
|
||||
void GAMEOVER_Initialize(SDL_Renderer * renderer);
|
||||
void GAMEOVER_Draw(SDL_Renderer * renderer, Scenery * scenery);
|
||||
void GAMEOVER_DrawHorizontalCenter(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Rect * srcRect, SDL_Rect * dstRect);
|
||||
void GAMEOVER_GetDigits(int input, int * digitCount);
|
||||
void SCORE_DrawHUD(SDL_Renderer * renderer, Scenery * scenery);
|
||||
void GAMEOVER_Deinitialize();
|
||||
|
27
settings.c
27
settings.c
@ -4,6 +4,7 @@
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "breakout.h"
|
||||
#include "settings.h"
|
||||
|
||||
#define Slider_height 100
|
||||
@ -13,9 +14,14 @@
|
||||
|
||||
SDL_Texture * Settings_Texture;
|
||||
SDL_Texture * Settings_Ball_Texture;
|
||||
SDL_Texture * Settings_Skins_Texture;
|
||||
SDL_Texture * Return_Button_Texture;
|
||||
|
||||
SDL_Rect Settings_rect;
|
||||
SDL_Rect Settings_Ball_rect;
|
||||
SDL_Rect Settings_Skins_rect;
|
||||
SDL_Rect Return_Button_rect;
|
||||
|
||||
Slider BV;
|
||||
Slider BS;
|
||||
Slider BT;
|
||||
@ -25,11 +31,18 @@ bool Settings_IsInit = false;
|
||||
void Settings_Initialize (SDL_Renderer* renderer) {
|
||||
Initialize_Slider(400,300,Scalar_width,Bar_width,Slider_height,1,2,&BV);
|
||||
Initialize_Slider(400,500,Scalar_width,Bar_width,Slider_height,10.0f,20.0f,&BS);
|
||||
Initialize_Slider(400,700,Scalar_width,Bar_width,Slider_height,0,1,&BT);
|
||||
Initialize_Slider(400,700,Scalar_width,Bar_width,Slider_height,0,8,&BT);
|
||||
Settings_Texture = IMG_LoadTexture(renderer, "assets/images/settings_title.png");
|
||||
Settings_rect = (SDL_Rect){.x = 800, .y = 130, .w=470, .h=150};
|
||||
Settings_Ball_Texture = IMG_LoadTexture(renderer, "assets/images/ball.png");
|
||||
Settings_Ball_rect = (SDL_Rect){.x = 1200, .y = 300, .w=100, .h=100};
|
||||
Settings_rect = (SDL_Rect){.x = 647, .y = 50, .w=626, .h=200};
|
||||
|
||||
Settings_Ball_rect = (SDL_Rect){.x = 1200, .y = 700, .w=90, .h=90};
|
||||
|
||||
Settings_Skins_Texture = IMG_LoadTexture(renderer, "assets/images/skins_button.png");
|
||||
Settings_Skins_rect = (SDL_Rect){.x = 50, .y = 710, .w=315, .h=70};
|
||||
|
||||
Return_Button_Texture = IMG_LoadTexture(renderer, "assets/images/return_button.png");
|
||||
Return_Button_rect = (SDL_Rect){.x = 30, .y = 30, .w=261, .h=100};
|
||||
|
||||
Settings_IsInit = true;
|
||||
}
|
||||
|
||||
@ -38,10 +51,14 @@ void Settings_Draw(SDL_Renderer * renderer, Scenery * scenery) {
|
||||
|
||||
SDL_RenderCopy(renderer, Settings_Texture, NULL, &Settings_rect);
|
||||
SDL_RenderCopy(renderer, Settings_Ball_Texture, NULL, &Settings_Ball_rect);
|
||||
SDL_RenderCopy(renderer, Settings_Skins_Texture, NULL, &Settings_Skins_rect);
|
||||
SDL_RenderCopy(renderer, Return_Button_Texture, NULL, &Return_Button_rect);
|
||||
|
||||
Draw_Slider(renderer, &BV);
|
||||
Draw_Slider(renderer, &BS);
|
||||
Draw_Slider(renderer, &BT);
|
||||
Draw_Ballstate(renderer, scenery);
|
||||
//Draw_Ballstate(renderer, scenery);
|
||||
BALL_DrawTexture(renderer, &Settings_Ball_rect, scenery->ball.TextureIndex);
|
||||
mapping(&x, &BS);
|
||||
scenery->ball.Speed = x;
|
||||
mapping(&x, &BT);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "main.h"
|
||||
|
||||
extern float XScale, YScale;
|
||||
extern SDL_Rect Return_Button_rect;
|
||||
|
||||
SDL_Texture * TITLE_Texture;
|
||||
SDL_Texture * PLAYBUTTON_Texture;
|
||||
@ -64,4 +65,9 @@ void button_clicked(SDL_MouseButtonEvent b, GameState gameState) {
|
||||
GAME_Escape();
|
||||
}
|
||||
}
|
||||
if (gameState == Settings) {
|
||||
if (clickInRect(b, &Return_Button_rect) == 1) {
|
||||
GAME_ChangeState(MainMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user