|
|
|
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
|
|
|
|
#include "draw.h" |
|
|
|
|
#include "game.h" |
|
|
|
|
#include "types.h" |
|
|
|
|
#include <SDL2/SDL_mutex.h> |
|
|
|
|
#include <SDL2/SDL_render.h> |
|
|
|
|
#include <time.h> |
|
|
|
@ -530,10 +531,25 @@ int draw_end_screen(SDL_Renderer *ren) {
@@ -530,10 +531,25 @@ int draw_end_screen(SDL_Renderer *ren) {
|
|
|
|
|
|
|
|
|
|
struct colour bg = scene.colours.bg; |
|
|
|
|
struct colour colour = scene.colours.fg1; |
|
|
|
|
struct colour_pallete pal = scene.colours; |
|
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(ren, bg.r, bg.g, bg.b,255); |
|
|
|
|
|
|
|
|
|
SDL_RenderClear(ren); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(ren, pal.fg2.r, pal.fg2.g, pal.fg2.b,255); |
|
|
|
|
for (int i = width - 300; i < width; i++) { |
|
|
|
|
SDL_RenderDrawLine(ren, i, height, width, height - i); |
|
|
|
|
if (!(i % 240)) { |
|
|
|
|
SDL_SetRenderDrawColor(ren, pal.fg3.r, pal.fg3.g, pal.fg3.b,255); |
|
|
|
|
} |
|
|
|
|
if (!(i % 350)) { |
|
|
|
|
SDL_SetRenderDrawColor(ren, pal.fg1.r, pal.fg1.g, pal.fg1.b,255); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int margin = height / 10; |
|
|
|
|
// Vect position = {.x = width - width / 10, .y = height - margin};
|
|
|
|
|
|
|
|
|
@ -544,10 +560,9 @@ int draw_end_screen(SDL_Renderer *ren) {
@@ -544,10 +560,9 @@ int draw_end_screen(SDL_Renderer *ren) {
|
|
|
|
|
char time_string[250]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char * end_str = "level over."; |
|
|
|
|
|
|
|
|
|
Vect position = {.x = width/3, .y = height / 4}; |
|
|
|
|
Vect position = {.x = width/4, .y = height / 4}; |
|
|
|
|
draw_text(ren, position, colour, end_str); |
|
|
|
|
position.y += 60; |
|
|
|
|
|
|
|
|
@ -580,7 +595,7 @@ int draw_end_screen(SDL_Renderer *ren) {
@@ -580,7 +595,7 @@ int draw_end_screen(SDL_Renderer *ren) {
|
|
|
|
|
snprintf(time_string, 250, "NEW BEST TIME: %d:%.4f", minutes, seconds); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vect position2 = {.x = 3 * width/5, .y = 60 + height / 4}; |
|
|
|
|
Vect position2 = {.x = position.x + width/3, .y = 60 + height / 4}; |
|
|
|
|
|
|
|
|
|
if (fastest > 0) { |
|
|
|
|
//position.y += 40;
|
|
|
|
@ -630,6 +645,59 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
@@ -630,6 +645,59 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void draw_pause_screen(SDL_Renderer *ren, struct environment *e) { |
|
|
|
|
|
|
|
|
|
char *te[] = { "GAME PAUSED.", |
|
|
|
|
"controls", |
|
|
|
|
"________", |
|
|
|
|
"pause/unpause: esc", |
|
|
|
|
"grapple: left click", |
|
|
|
|
"grapple and pull: right click", |
|
|
|
|
"go to level: g", |
|
|
|
|
"mute/unmute: m", |
|
|
|
|
"quit: q" |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct colour textc = e->colours.fg1; |
|
|
|
|
struct colour bg = e->colours.bg; |
|
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(ren, bg.r, bg.g, bg.b, 255); |
|
|
|
|
int boxwidth = 360; |
|
|
|
|
int boxheight = 348; |
|
|
|
|
int box_x = (2 * width / 3) - (boxwidth / 2); |
|
|
|
|
int box_y = (height - boxheight) / 2; |
|
|
|
|
SDL_Rect r = {.w = boxwidth, .h = boxheight, .x = box_x, .y = box_y}; |
|
|
|
|
SDL_RenderFillRect(ren, &r); |
|
|
|
|
|
|
|
|
|
Vect p = {.x = box_x + 10, .y = box_y + 10}; |
|
|
|
|
draw_text(ren, p, textc, te[0]); |
|
|
|
|
p.y += 60; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[1]); |
|
|
|
|
p.y += 5; |
|
|
|
|
draw_text(ren, p, textc, te[2]); |
|
|
|
|
p.y += 35; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[3]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[4]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[5]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[6]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[7]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
draw_text(ren, p, textc, te[8]); |
|
|
|
|
p.y += 40; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void redraw_buffer(SDL_Renderer * ren) { |
|
|
|
|
static int mousex = 0; |
|
|
|
|
static int mousey = 0; |
|
|
|
@ -709,6 +777,13 @@ void redraw_buffer(SDL_Renderer * ren) {
@@ -709,6 +777,13 @@ void redraw_buffer(SDL_Renderer * ren) {
|
|
|
|
|
draw_collision_poly(ren, &lplayer); |
|
|
|
|
draw_forces(ren, &lplayer); |
|
|
|
|
|
|
|
|
|
if (game_paused) { |
|
|
|
|
SDL_Rect r = {.x = 0, .y = 0, .w = width, .h = height}; |
|
|
|
|
SDL_SetRenderDrawColor(ren, 0, 0, 0, 90); |
|
|
|
|
SDL_RenderFillRect(ren, &r); |
|
|
|
|
if (in_game) |
|
|
|
|
draw_pause_screen(ren, &scene); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*if (newmousex != mousex || newmousey != mousey) {*/ /*mousey = newmousey;*/ |
|
|
|
|
/*mousex = newmousex;*/ |
|
|
|
|