Fullscreen now supported (absolute, not scaled)
This commit is contained in:
parent
b9cd095b1c
commit
77bd1ed996
BIN
bin/System.Web.Helpers.dll
Normal file
BIN
bin/System.Web.Helpers.dll
Normal file
Binary file not shown.
BIN
bin/bhi.exe
BIN
bin/bhi.exe
Binary file not shown.
33
breakout.c
33
breakout.c
@ -24,8 +24,12 @@ SDL_Rect * PADDLE_SourceRects;
|
||||
Uint8 * PADDLE_MoveLeftKeys, * PADDLE_MoveRightKeys;
|
||||
double BALL_Speed = 10.0f;
|
||||
int PADDLE_Speed = 10;
|
||||
bool BREAKOUT_IsInit = false;
|
||||
bool BALL_IsInit = false;
|
||||
bool PADDLE_IsInit = false;
|
||||
|
||||
void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height){
|
||||
if (!BREAKOUT_IsInit) {
|
||||
printf("Initializing Game...\n");
|
||||
srand(time(NULL));
|
||||
BREAKOUT_BoxWidth = width;
|
||||
@ -33,6 +37,13 @@ void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height){
|
||||
BALL_Initialize(renderer);
|
||||
PADDLE_Initialize(renderer);
|
||||
printf("Game initialized!\n");
|
||||
BREAKOUT_IsInit = true;
|
||||
} else printf("Game is already initialized!\n");
|
||||
}
|
||||
|
||||
void BREAKOUT_ChangeSize(int width, int height){
|
||||
BREAKOUT_BoxWidth = width;
|
||||
BREAKOUT_BoxHeight = height;
|
||||
}
|
||||
|
||||
void BREAKOUT_Update(Uint8 * keystate){
|
||||
@ -46,12 +57,17 @@ void BREAKOUT_Draw(SDL_Renderer * renderer){
|
||||
}
|
||||
|
||||
void BREAKOUT_DEINITIALIZE(){
|
||||
if (BREAKOUT_IsInit) {
|
||||
printf("De-initializing Game...\n");
|
||||
SDL_DestroyTexture(BALL_Texture);
|
||||
SDL_DestroyTexture(PADDLE_Texture);
|
||||
printf("Game de-initialized!\n");
|
||||
BREAKOUT_IsInit = false;
|
||||
} else printf("Game is already de-initialized!\n");
|
||||
}
|
||||
|
||||
void BALL_Initialize(SDL_Renderer * renderer){
|
||||
if (!BALL_IsInit) {
|
||||
printf("Initializing Ball...\n");
|
||||
BALL_Texture = IMG_LoadTexture(renderer, "assets/images/ball.png");
|
||||
if (!BALL_Texture) printf("Ball texture failed to load!\n");
|
||||
@ -61,6 +77,8 @@ void BALL_Initialize(SDL_Renderer * renderer){
|
||||
ball = BALL_CreateDefault();
|
||||
paddle = PADDLE_CreateDefault();
|
||||
printf("Ball initialized!\n");
|
||||
BALL_IsInit = true;
|
||||
} else printf("Ball is already initialized!\n");
|
||||
}
|
||||
|
||||
Ball BALL_CreateDefault(){
|
||||
@ -149,13 +167,17 @@ void BALL_Update(Ball * obj, Paddle * paddle){
|
||||
void BALL_DestroyObject(Ball * obj){
|
||||
}
|
||||
void BALL_Deinitialize(){
|
||||
if (BALL_IsInit) {
|
||||
printf("De-initializing Ball...\n");
|
||||
|
||||
printf("Ball de-initialized!\n");
|
||||
BALL_IsInit = false;
|
||||
} else printf("Ball is already de-initialized!\n");
|
||||
}
|
||||
|
||||
|
||||
void PADDLE_Initialize(SDL_Renderer * renderer){
|
||||
if (!PADDLE_IsInit) {
|
||||
printf("Initializing Paddle...\n");
|
||||
PADDLE_Texture = IMG_LoadTexture(renderer, "assets/images/paddle.png");
|
||||
if (!PADDLE_Texture) printf("Paddle texture failed to load!\n");
|
||||
@ -174,7 +196,9 @@ void PADDLE_Initialize(SDL_Renderer * renderer){
|
||||
PADDLE_MoveRightKeys[2] = SDL_SCANCODE_D;
|
||||
ball = BALL_CreateDefault();
|
||||
printf("Paddle initialized!\n");
|
||||
}
|
||||
PADDLE_IsInit = true;
|
||||
} else printf("Paddle is already initialized!\n");
|
||||
} /* PADDLE_Initialize */
|
||||
|
||||
Paddle PADDLE_CreateDefault(){
|
||||
int defaultpaddlewidth = 300;
|
||||
@ -217,7 +241,10 @@ void PADDLE_Update(Paddle * obj, Uint8 * keystate){
|
||||
void PADDLE_DestroyObject(Paddle * obj){
|
||||
}
|
||||
void PADDLE_Deinitialize(){
|
||||
printf("De-initializing Ball...\n");
|
||||
if (PADDLE_IsInit) {
|
||||
printf("De-initializing Paddle...\n");
|
||||
|
||||
printf("Ball de-initialized!\n");
|
||||
printf("Paddle de-initialized!\n");
|
||||
PADDLE_IsInit = false;
|
||||
} else printf("Paddle is already de-initialized!\n");
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ typedef struct blockStruct {
|
||||
|
||||
// Prototypes
|
||||
void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height);
|
||||
void BREAKOUT_ChangeSize(int width, int height);
|
||||
void BREAKOUT_Update(Uint8 * keystate);
|
||||
void BREAKOUT_Draw(SDL_Renderer * renderer);
|
||||
void BREAKOUT_DEINITIALIZE();
|
||||
|
3
main.c
3
main.c
@ -79,7 +79,7 @@ void mousePress(SDL_MouseButtonEvent b){ // Debug prop
|
||||
|
||||
void keyPress(SDL_KeyboardEvent b){ // Debug prop
|
||||
printf("Key pressed: ID is %d\n", b.keysym.scancode);
|
||||
if (b.keysym.scancode == SDL_SCANCODE_F11) {
|
||||
if (b.keysym.scancode == SDL_SCANCODE_F11 || b.keysym.scancode == SDL_SCANCODE_5) {
|
||||
toggleFullscreen();
|
||||
}
|
||||
}
|
||||
@ -97,6 +97,7 @@ void windowChanged(SDL_WindowEvent b){ // Debug prop
|
||||
switch (b.event) {
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
printf("Window was resized to (%d|%d)!\n", event.window.data1, event.window.data2);
|
||||
BREAKOUT_ChangeSize(event.window.data1, event.window.data2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user