Merge branch 'dev' of collaborating.tuhh.de:czg6669/breakout into dev
This commit is contained in:
commit
725ed1a7a2
70
settings.c
70
settings.c
@ -4,22 +4,24 @@
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
SDL_Texture* Setting_Texture;
|
||||
|
||||
SDL_Rect Settings_rect;
|
||||
SDL_Rect BV_Bar_rect;
|
||||
SDL_Rect BV_Scalar_rect;
|
||||
SDL_Rect BS_Bar_rect;
|
||||
SDL_Rect BT_Bar_rect;
|
||||
SDL_Rect BVController_rect;
|
||||
Slider BV;
|
||||
Slider BS;
|
||||
Slider BT;
|
||||
|
||||
bool Settings_IsInit=false;
|
||||
|
||||
void Settings_Initialize (SDL_Renderer* renderer) {
|
||||
BV_Bar_rect = (SDL_Rect){.y = 300,.x = 400 , .w=400, .h=100};
|
||||
BV_Scalar_rect = (SDL_Rect){.y=300,.x=420,.w=20,.h=100};
|
||||
BS_Bar_rect = (SDL_Rect){.y = 500,.x = 400, .w=400, .h=100};
|
||||
BT_Bar_rect = (SDL_Rect){.y = 700,.x = 400, .w=400, .h=100};
|
||||
BV.Scalar_rect = (SDL_Rect){.y=300,.x=590,.w=20,.h=100};
|
||||
BS.Scalar_rect = (SDL_Rect){.y=500,.x=590,.w=20,.h=100};
|
||||
BT.Scalar_rect = (SDL_Rect){.y=700,.x=590,.w=20,.h=100};
|
||||
BV.Bar_rect = (SDL_Rect){.y = 300,.x = 400 , .w=400, .h=100};
|
||||
BS.Bar_rect = (SDL_Rect){.y = 500,.x = 400, .w=400, .h=100};
|
||||
BT.Bar_rect = (SDL_Rect){.y = 700,.x = 400, .w=400, .h=100};
|
||||
Setting_Texture = IMG_LoadTexture(renderer, "assets/images/settings_title.png");
|
||||
Settings_rect = (SDL_Rect){.x = 800, .y = 180, .w=313, .h=100};
|
||||
Settings_IsInit = true;
|
||||
@ -27,31 +29,10 @@ void Settings_Initialize (SDL_Renderer* renderer) {
|
||||
|
||||
void Settings_Draw (SDL_Renderer* renderer) {
|
||||
SDL_SetRenderDrawColor(renderer,255,255,255,255);
|
||||
SDL_RenderDrawRect(renderer,&BV_Bar_rect);
|
||||
SDL_RenderDrawRect(renderer,&BS_Bar_rect);
|
||||
SDL_RenderDrawRect(renderer,&BT_Bar_rect);
|
||||
SDL_RenderDrawRect(renderer,&BV_Scalar_rect);
|
||||
SDL_RenderCopy(renderer, Setting_Texture, NULL, &Settings_rect);
|
||||
int x,y;
|
||||
Uint32 Mousestate=SDL_GetMouseState(&x,&y);
|
||||
if(y<=400&&y>=300&&x<=800&&x>=400&&(Mousestate & SDL_BUTTON(SDL_BUTTON_LEFT))){
|
||||
SDL_RenderFillRect(renderer,&BV_Scalar_rect);
|
||||
SDL_RenderDrawRect(renderer,&BV_Scalar_rect);
|
||||
if(x>790){
|
||||
BV_Scalar_rect.x=780;
|
||||
}
|
||||
else if(x<410){
|
||||
BV_Scalar_rect.x=400;
|
||||
}
|
||||
else{
|
||||
BV_Scalar_rect.x=x-10;
|
||||
}
|
||||
}
|
||||
else{
|
||||
SDL_RenderDrawRect(renderer,&BV_Scalar_rect);
|
||||
}
|
||||
printf("%d,%d\n",x,y);
|
||||
|
||||
Draw_Slider(renderer,&BV);
|
||||
Draw_Slider(renderer,&BS);
|
||||
Draw_Slider(renderer,&BT);
|
||||
}
|
||||
|
||||
void Settings_Deinitialize(){
|
||||
@ -60,3 +41,26 @@ void Settings_Deinitialize(){
|
||||
Settings_IsInit=false;
|
||||
}
|
||||
}
|
||||
|
||||
void Draw_Slider(SDL_Renderer* renderer,Slider* beta){
|
||||
SDL_RenderDrawRect(renderer,&beta->Bar_rect);
|
||||
int x,y;
|
||||
Uint32 Mousestate=SDL_GetMouseState(&x,&y);
|
||||
SDL_SetRenderDrawColor(renderer,255,255,255,255);
|
||||
if(y<=((beta->Scalar_rect.y)+100)&&y>=(beta->Scalar_rect.y)&&x<=800&&x>=400&&(Mousestate & SDL_BUTTON(SDL_BUTTON_LEFT))){
|
||||
SDL_RenderFillRect(renderer,&beta->Scalar_rect);
|
||||
SDL_RenderDrawRect(renderer,&beta->Scalar_rect);
|
||||
if(x>790){
|
||||
beta->Scalar_rect.x=780;
|
||||
}
|
||||
else if(x<410){
|
||||
beta->Scalar_rect.x=400;
|
||||
}
|
||||
else{
|
||||
beta->Scalar_rect.x=x-10;
|
||||
}
|
||||
}
|
||||
else{
|
||||
SDL_RenderDrawRect(renderer,&beta->Scalar_rect);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,11 @@
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct sliderstruct {
|
||||
SDL_Rect Bar_rect;
|
||||
SDL_Rect Scalar_rect;
|
||||
double Slider_value,min,max;
|
||||
} Slider;
|
||||
|
||||
void Settings_Initialize (SDL_Renderer* renderer);
|
||||
|
||||
@ -15,4 +20,6 @@ void Settings_Draw (SDL_Renderer* renderer);
|
||||
|
||||
void Settings_Deinitialize();
|
||||
|
||||
void Draw_Slider(SDL_Renderer* renderer,Slider* beta);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user