1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:37:44 +00:00

FlappyBug: Make the obstacle gap position random

The position of the gap in the obstacle is now randomly generated each
time it spawns. The game is more fun to play now :)
This commit is contained in:
Mim Hufford 2021-06-01 17:31:54 +01:00 committed by Linus Groh
parent 811d9722f9
commit 444fcfd0d2
2 changed files with 2 additions and 1 deletions

View file

@ -5,7 +5,6 @@
*/ */
#include "Game.h" #include "Game.h"
#include <AK/Random.h>
namespace FlappyBug { namespace FlappyBug {

View file

@ -7,6 +7,7 @@
#pragma once #pragma once
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/Random.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/Painter.h> #include <LibGUI/Painter.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
@ -77,6 +78,7 @@ private:
void reset() void reset()
{ {
x = game_width; x = game_width;
gap_top_y = get_random_uniform(game_height - gap_height);
} }
Gfx::FloatRect top_rect() const Gfx::FloatRect top_rect() const