From 8134191c10bac06da1f5e46bd9dc6a6c80bbbe18 Mon Sep 17 00:00:00 2001 From: sOlaris38 Date: Sun, 6 Dec 2020 17:05:26 +0100 Subject: [PATCH] =?UTF-8?q?=C3=A9cran=20game=20over?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objects/oGame/Create_0.gml | 2 +- objects/oGame/Draw_64.gml | 57 +++++++++++++++----------- objects/oGame/KeyPress_82.gml | 1 + objects/oGame/Step_0.gml | 16 +++++--- objects/oGame/oGame.yy | 1 + objects/oPlayer/Collision_oMonster.gml | 2 +- objects/oPlayer/Draw_0.gml | 2 +- scripts/Script1/Script1.gml | 5 ++- 8 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 objects/oGame/KeyPress_82.gml diff --git a/objects/oGame/Create_0.gml b/objects/oGame/Create_0.gml index 773685b..6782161 100644 --- a/objects/oGame/Create_0.gml +++ b/objects/oGame/Create_0.gml @@ -15,7 +15,7 @@ global.minutes = 1; global.secondes = 20; global.transition = -1; -perdu = false; +global.perdu = false; posX = irandom(3); posY = irandom(3); diff --git a/objects/oGame/Draw_64.gml b/objects/oGame/Draw_64.gml index 388e6f3..0684eac 100644 --- a/objects/oGame/Draw_64.gml +++ b/objects/oGame/Draw_64.gml @@ -1,34 +1,43 @@ +if (room != rOver) { + draw_rectangle_color(1280,0,display_get_gui_width(),96,c_black,c_black,c_black,c_black,false); -draw_rectangle_color(1280,0,display_get_gui_width(),display_get_gui_height() - 128,c_black,c_black,c_black,c_black,true); + draw_text(1312,72,"map"); -draw_text(640,16,"vie : " + string(oPlayer.pv)); + draw_text(640,16,"vie : " + string(oPlayer.pv)); -for (i = 0; i < 4; i++) -{ - for(j = 0; j < 4; j++) + for (i = 0; i < 4; i++) { - draw_text(i*16,j*16,tableau[i, j]); + for(j = 0; j < 4; j++) + { + draw_text(i*16,j*16,tableau[i, j]); + } } + + draw_text(640,16,"vie : " + string(oPlayer.pv)); + + + for (i = 0; i < 4; i++) + { + for(j = 0; j < 4; j++) + { + if (i = posX and j = posY) draw_text(i*16 + 1300,j*16,"o"); + else draw_text(i*16 + 1300,j*16,"-"); + } + } + + if (!global.perdu) draw_text(160,16, string(global.minutes) + " : " + string(global.secondes)); + else draw_text(160,16, "PERDU"); + + draw_text(320,16,global.difficulty); + + draw_text(480,16,"pos : (" + string(posX) + ", " + string(posY) + ")"); + + draw_text(800,16,room_get_name(room)); } -draw_text(640,16,"vie : " + string(oPlayer.pv)); - - -for (i = 0; i < 4; i++) -{ - for(j = 0; j < 4; j++) - { - if (i = posX and j = posY) draw_text(i*16 + 1300,j*16,"o"); - else draw_text(i*16 + 1300,j*16,"-"); - } +else { + draw_text_transformed(room_width / 2, room_height / 2, "GAME OVER!", 2, 2, image_angle); + draw_text_transformed(room_width / 2, room_height / 2 + 128, "PRESS R TO RESTART", 2, 2, image_angle); } -if (!perdu) draw_text(160,16, string(global.minutes) + " : " + string(global.secondes)); -else draw_text(160,16, "PERDU"); - -draw_text(320,16,global.difficulty); - -draw_text(480,16,"pos : (" + string(posX) + ", " + string(posY) + ")"); - -draw_text(800,16,room_get_name(room)); \ No newline at end of file diff --git a/objects/oGame/KeyPress_82.gml b/objects/oGame/KeyPress_82.gml new file mode 100644 index 0000000..f01f105 --- /dev/null +++ b/objects/oGame/KeyPress_82.gml @@ -0,0 +1 @@ +if (room = rOver) game_restart(); \ No newline at end of file diff --git a/objects/oGame/Step_0.gml b/objects/oGame/Step_0.gml index a3bd5f7..ab53d93 100644 --- a/objects/oGame/Step_0.gml +++ b/objects/oGame/Step_0.gml @@ -1,14 +1,13 @@ // chrono -if (!perdu) { +if (!global.perdu) { global.secondes -= 1/room_speed; if (global.secondes <= 0) { global.minutes --; global.secondes = 20; - } - - if (global.minutes <= 0) { - perdu = true; + if (global.minutes < 0) { + global.perdu = true; + } } } @@ -32,3 +31,10 @@ if (global.transition != -1) { global.transition = -1; room_goto(asset_get_index("r" + string(tableau[posX, posY]))); } + +// défaite + +if (global.perdu) { + room_goto(rOver); + global.perdu = false; +} diff --git a/objects/oGame/oGame.yy b/objects/oGame/oGame.yy index 084456d..aa39b2a 100644 --- a/objects/oGame/oGame.yy +++ b/objects/oGame/oGame.yy @@ -23,6 +23,7 @@ {"isDnD":false,"eventNum":69,"eventType":9,"collisionObjectId":null,"parent":{"name":"oGame","path":"objects/oGame/oGame.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, {"isDnD":false,"eventNum":0,"eventType":3,"collisionObjectId":null,"parent":{"name":"oGame","path":"objects/oGame/oGame.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, {"isDnD":false,"eventNum":72,"eventType":8,"collisionObjectId":null,"parent":{"name":"oGame","path":"objects/oGame/oGame.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, + {"isDnD":false,"eventNum":82,"eventType":9,"collisionObjectId":null,"parent":{"name":"oGame","path":"objects/oGame/oGame.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, ], "properties": [], "overriddenProperties": [], diff --git a/objects/oPlayer/Collision_oMonster.gml b/objects/oPlayer/Collision_oMonster.gml index 6596ed9..5384ead 100644 --- a/objects/oPlayer/Collision_oMonster.gml +++ b/objects/oPlayer/Collision_oMonster.gml @@ -1,6 +1,6 @@ if (inv == 0) { hit(other, self, other.attack); - inv = 120; + inv = 30; } else { knockBack(other, self); } diff --git a/objects/oPlayer/Draw_0.gml b/objects/oPlayer/Draw_0.gml index d693e22..2d74894 100644 --- a/objects/oPlayer/Draw_0.gml +++ b/objects/oPlayer/Draw_0.gml @@ -1,7 +1,7 @@ // Suppression de l'invinsibilité if (inv > 0) { inv--; - draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, c_lime, image_alpha); + draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, c_red, image_alpha); } else { draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha); } \ No newline at end of file diff --git a/scripts/Script1/Script1.gml b/scripts/Script1/Script1.gml index 2129a51..1b72b2a 100644 --- a/scripts/Script1/Script1.gml +++ b/scripts/Script1/Script1.gml @@ -29,7 +29,10 @@ function knockBack(obj, objRepousse) { */ function hit(objAttaquant, objAttaque, degats) { objAttaque.pv -= degats; - if (objAttaque.pv <= 0) instance_destroy(objAttaque); + if (objAttaque.pv <= 0) { + if (objAttaque.object_index = oPlayer) global.perdu = true; + else instance_destroy(objAttaque); + } else knockBack(objAttaquant, objAttaque); }