about summary refs log tree commit diff stats
path: root/src/pause.c
blob: c3264ec895a0f5f567c97e78894cd9ec89909afc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highligh
#include "pong.h"
#include <raylib.h>

bool pause_screen(Camera2D *MainCamera) {
	bool PauseScreenGoing = true;
	
	/* Mouse */
	Rectangle Mouse = {
        	1280.0f/2, 720.0f/2, 10, 10
	};
	Vector2 OldPosition = GetMousePosition();
	Vector2 NewPosition = GetMousePosition();
	Texture2D MouseCursor = LoadTexture("resources/cursor.png");
	bool MouseCursorIn = false;
	EnableCursor();
	int Choice = 0;
	while(PauseScreenGoing == true && GameGoing == true) {
		/* Update Camera */
        MainCamera->zoom = GetScreenHeight()/720.0f;
		MainCamera->offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f};
		MainCamera->target = (Vector2){1280/2.0f, 720/2.0f};
		/* Mouse */
        if (MouseCursorIn == true) {
           		OldPosition = NewPosition;
           		NewPosition = GetMousePosition();
           		Mouse.y -= OldPosition.y-NewPosition.y;
           		Mouse.x -= OldPosition.x-NewPosition.x;
           		if (Mouse.y >= 720 || Mouse.y <= 0) {
               		Mouse.y += OldPosition.y-NewPosition.y;
           		}
           		if (Mouse.x >= 1280 || Mouse.x <= 0) {
               		Mouse.x += OldPosition.x-NewPosition.x;
           		}
        }

		if(IsKeyPressed(KEY_Y)) {
			return false;
		} else if(IsKeyPressed(KEY_N)) {
			return true;
		}
        
		if (IsKeyPressed(KEY_ESCAPE)) {
			EnableCursor();
			MouseCursorIn = false;
       	} else if (IsCursorOnScreen() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
			DisableCursor();
           	MouseCursorIn = true;
       	}
		if (player_controls() == CONTROLLER_LEFT) {
			Choice--;
		} else if (player_controls() == CONTROLLER_RIGHT) {
			Choice++;
		}

		if (Choice >= 2) {
			Choice = 1;
		} else if (Choice <= -1) {
			Choice = 0;
		}

		BeginDrawing();
			ClearBackground(BLACK);
			BeginMode2D(*MainCamera);
				DrawRectangle(0, 0, 1280, 720, (Color){20,20,20,255});
				if(CheckCollisionRecs(Mouse, (Rectangle){1280/3.0f, (720/3.0f)+50, 100, 50})) {
					Choice = 0;
				} else if(CheckCollisionRecs(Mouse, (Rectangle){(1280/3.0f)+150, (720/3.0f)+50, 70, 50})) {
					Choice = 1;
				}
				switch(Choice) {
					case 0:
						DrawRectangle((1280/3.0f)-5, (720/3.0f)+50, 104, 50, RED);
						break;
					default:
						DrawRectangle((1280/3.0f)+150,(720/3.0f)+50, 70, 50, RED);
						break;
				}
				if ( player_controls() == CONTROLLER_ACTIVATE ) {
					switch(Choice) {
						case 0:
							return false;
							break;
						default:
							return true;
							break;
					}
				}
				DrawText("Paused. Exit?", 1280/3, 720/3, 48, WHITE);
				DrawText("YES   NO", 1280/3, (720/3)+50, 48, WHITE);
				DrawTexture(MouseCursor, Mouse.x, Mouse.y, WHITE);
			EndMode2D();
		EndDrawing();
	}
	return true;
}