Merge branch 'dev' of collaborating.tuhh.de:czg6669/breakout into dev

This commit is contained in:
Michael Chen 2018-01-18 15:45:55 +01:00
commit c60688dcf8
3 changed files with 64 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

49
settings.c Normal file
View File

@ -0,0 +1,49 @@
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.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;
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};
Setting_Texture = IMG_LoadTexture(renderer, "assets/images/settings_title.png");
Settings_rect = (SDL_Rect){.x = 800, .y = 180, .w=313, .h=100};
}
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>780){
BV_Scalar_rect.x=780;
}
else{
BV_Scalar_rect.x=x;
}
}
else{
SDL_RenderDrawRect(renderer,&BV_Scalar_rect);
}
printf("%d,%d\n",x,y);
}

15
settings.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __Settings__
#define __Settings__
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
void Settings_Initialize (SDL_Renderer* renderer);
void Settings_Draw (SDL_Renderer* renderer);
#endif