- replaced texture in settings.c
- added return button in settings.c
This commit is contained in:
parent
2a3c056909
commit
21012dbc70
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 |
27
settings.c
27
settings.c
@ -4,6 +4,7 @@
|
|||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "breakout.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#define Slider_height 100
|
#define Slider_height 100
|
||||||
@ -13,9 +14,14 @@
|
|||||||
|
|
||||||
SDL_Texture * Settings_Texture;
|
SDL_Texture * Settings_Texture;
|
||||||
SDL_Texture * Settings_Ball_Texture;
|
SDL_Texture * Settings_Ball_Texture;
|
||||||
|
SDL_Texture * Settings_Skins_Texture;
|
||||||
|
SDL_Texture * Return_Button_Texture;
|
||||||
|
|
||||||
SDL_Rect Settings_rect;
|
SDL_Rect Settings_rect;
|
||||||
SDL_Rect Settings_Ball_rect;
|
SDL_Rect Settings_Ball_rect;
|
||||||
|
SDL_Rect Settings_Skins_rect;
|
||||||
|
SDL_Rect Return_Button_rect;
|
||||||
|
|
||||||
Slider BV;
|
Slider BV;
|
||||||
Slider BS;
|
Slider BS;
|
||||||
Slider BT;
|
Slider BT;
|
||||||
@ -25,11 +31,18 @@ bool Settings_IsInit = false;
|
|||||||
void Settings_Initialize (SDL_Renderer* renderer) {
|
void Settings_Initialize (SDL_Renderer* renderer) {
|
||||||
Initialize_Slider(400,300,Scalar_width,Bar_width,Slider_height,1,2,&BV);
|
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,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_Texture = IMG_LoadTexture(renderer, "assets/images/settings_title.png");
|
||||||
Settings_rect = (SDL_Rect){.x = 800, .y = 130, .w=470, .h=150};
|
Settings_rect = (SDL_Rect){.x = 647, .y = 50, .w=626, .h=200};
|
||||||
Settings_Ball_Texture = IMG_LoadTexture(renderer, "assets/images/ball.png");
|
|
||||||
Settings_Ball_rect = (SDL_Rect){.x = 1200, .y = 300, .w=100, .h=100};
|
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;
|
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_Texture, NULL, &Settings_rect);
|
||||||
SDL_RenderCopy(renderer, Settings_Ball_Texture, NULL, &Settings_Ball_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, &BV);
|
||||||
Draw_Slider(renderer, &BS);
|
Draw_Slider(renderer, &BS);
|
||||||
Draw_Slider(renderer, &BT);
|
Draw_Slider(renderer, &BT);
|
||||||
Draw_Ballstate(renderer, scenery);
|
//Draw_Ballstate(renderer, scenery);
|
||||||
|
BALL_DrawTexture(renderer, &Settings_Ball_rect, scenery->ball.TextureIndex);
|
||||||
mapping(&x, &BS);
|
mapping(&x, &BS);
|
||||||
scenery->ball.Speed = x;
|
scenery->ball.Speed = x;
|
||||||
mapping(&x, &BT);
|
mapping(&x, &BT);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
extern float XScale, YScale;
|
extern float XScale, YScale;
|
||||||
|
extern SDL_Rect Return_Button_rect;
|
||||||
|
|
||||||
SDL_Texture * TITLE_Texture;
|
SDL_Texture * TITLE_Texture;
|
||||||
SDL_Texture * PLAYBUTTON_Texture;
|
SDL_Texture * PLAYBUTTON_Texture;
|
||||||
@ -64,4 +65,9 @@ void button_clicked(SDL_MouseButtonEvent b, GameState gameState) {
|
|||||||
GAME_Escape();
|
GAME_Escape();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (gameState == Settings) {
|
||||||
|
if (clickInRect(b, &Return_Button_rect) == 1) {
|
||||||
|
GAME_ChangeState(MainMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user