Commit Graph

195 Commits

Author SHA1 Message Date
thisSyntaxSucksAndYouKnowIt
f583cddaf7 Solitaire: Don't allow the player to draw cards while mouse is down 2021-08-07 16:59:46 +02:00
Jamie Mansfield
705e91d332 Spider: Use YesNo dialog for user confirmation when closing
Cancel was superflous, and provided no difference to No.
2021-08-06 01:12:32 +02:00
Jamie Mansfield
c3c1a9ca1d Solitaire: Get user confirmation to close when there is a active game 2021-08-06 01:12:32 +02:00
Jamie Mansfield
506363c08d Solitaire: Clear selection when starting new game
Fixes #9218.
2021-08-05 12:52:33 +02:00
Jamie Mansfield
22aeec1218 Spider: Clear selection when starting new game
Fixes #9217.
2021-08-05 12:52:33 +02:00
LuK1337
4b81b9718d Breakout: Add menus before showing the window
Otherwise, space is reserved but menus aren't shown.
2021-07-31 08:08:31 +02:00
LuK1337
7f99497378 Pong: Add menus before showing the window
Otherwise, space is reserved but menus aren't shown.
2021-07-31 08:08:31 +02:00
Jamie Mansfield
28ee513bdf Spider: Make statusbar high score display configurable
You can now choose what statistic (currently only high score or best
time) to display in the statusbar.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
821af6a6ef Spider: Start game if first move is to draw cards
This fixes a bug where the game wouldn't consider it had started.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
26cb559d37 Spider: Track win and loss counts
Again, this isn't exposed anywhere yet.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
f7eb6772ce Spider: Get user confirmation to close when there is a active game 2021-07-27 16:53:56 +02:00
Jamie Mansfield
4df9d05f91 Spider: Track quickest game time
This isn't exposed in the game anywhere yet.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
29f15cfbae Spider: Standardise fetching the mode identifier
This eliminates some code duplication, and will be helpful for future
commits introducing further statistic tracking.
2021-07-27 16:53:56 +02:00
Gunnar Beutner
3c1797c42d Solitaire: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Gunnar Beutner
58d1e46628 Spider: Use AK::get_random_uniform() instead of rand()/srand()
This also has the added benefit that after a restart we don't get the
same random numbers all the time because we forgot to initialize the
RNG with srand().
2021-07-24 01:40:51 +02:00
Gunnar Beutner
807b79d89e Spider: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
d76b42599e Hearts: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
5201c17d9b Hearts: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Gunnar Beutner
59007bba84 Hearts: Avoid redrawing the UI unnecessarily 2021-07-23 02:34:59 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Karol Kosek
fd5bc36fc1 Pong: Disable resizing the window
The game doesn't handle resize events.

It's a pretty lazy fix.  The proper way would be to actually allow
the game to be resized, with some scaling trickery, but most games
here don't do that anyway, so I guess that's good enough.
2021-07-20 01:51:11 +02:00
Hendiadyoin1
ed46d52252 Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.

Also clean up some stale math includes and improper floatingpoint usage.
2021-07-19 16:34:21 +04:30
Jamie Mansfield
0150ae4bbd Solitaire: Reduce overdraw when drawing initial cards 2021-07-15 21:47:36 +02:00
Jamie Mansfield
882b4dc848 Spider: Reduce overdraw when playing 2021-07-15 20:11:22 +02:00
Jamie Mansfield
0f9873475b Spider: Reduce overdraw when drawing initial cards 2021-07-15 20:11:22 +02:00
Jamie Mansfield
c0bc884295 Spider: Automatically reveal top cards
This matches basically all other Spider implementations I've played,
and makes playing much easier :)

I have left click-to-reveal in place, but mostly incase there is a
condition I've forgotten about.
2021-07-15 19:52:14 +02:00
Karol Kosek
67e3daa679 Breakout: Only paint areas that needs to be updated 2021-07-12 12:26:15 +02:00
Karol Kosek
a90c484d4b Pong: Only paint areas that needs to be updated 2021-07-11 14:11:26 +02:00
Timothy Flynn
dd65f52331 FlappyBug: Only paint areas which need to be painted
Drawing the entire PNG background is rather expensive. Instead, only
draw the rects that are updating.
2021-07-10 23:28:20 +02:00
networkException
39a3f42534 GameOfLife: Properly switch between play and pause icon
The play and pause icon were previously set on the toggle Action
and not on the Button of the Action that is part of the Toolbar
2021-07-07 15:29:37 +01:00
Jamie Mansfield
3f8857cd21 Games: Add Spider
Scoring is designed to mimic Microsoft's implementation - starting at
500, decreasing by 1 every move, and increasing by 100 for every full
stack.

Fixes GH-5319.
2021-06-24 10:32:53 +02:00
Sam Atkins
f2d6cac692
Solitaire: Maybe fix rare crash from completing a game with TAB (#8217)
The crash happens very rarely and is hard to reproduce so it is
hard to know for certain, but I am confident this fixes it.

I previously delayed the start of the game-over animation by one
frame, but neglected to check m_start_game_over_animation_next_frame
wasn't set. This means multiple calls to start_game_over_animation()
on the same frame (or rather, before the first timer_event) would
each call Object::start_timer(). Now that we do check the flag,
that should no longer be possible.

Fixes #8122.
2021-06-24 09:25:01 +02:00
Timothy Flynn
675b8ba995 FlappyBug: Standardize on "high score" rather than "highscore"
"High score" should be two words, and this matches other games in the
system.
2021-06-22 23:05:10 +02:00
Timothy Flynn
1a2053781f FlappyBug: Persist high score to disk
Previously, the high score was only in-memory, so only persisted for as
long as the FlappyBug window was open.
2021-06-22 23:05:10 +02:00
Timothy Flynn
25c53e35e7 FlappyBug: Convert the main game widget to a GUI::Frame 2021-06-22 23:05:10 +02:00
Linus Groh
ade85d980b FlappyBug: Add missing component declaration
The PR for this pre-dates the concept of components, so it was forgotten
to add one.
2021-06-20 11:13:30 +01:00
Mim Hufford
ddc855ffcd FlappyBug: Add cloud and sky graphics
We now have a nice sunset sky and some random cloud graphics.
The obstacles will get graphics at some point too :)
2021-06-20 10:54:27 +01:00
Mim Hufford
28e08f08c2 FlappyBug: Add new graphics and tweak colors
This adds some actual graphics to the game, and tweaks the obstacle and
sky colors. Eventually there will be graphics for those elements too.
2021-06-20 10:54:27 +01:00
Mim Hufford
f50003bdd2 FlappyBug: Add an input cooldown after game over
This makes sure the player doesn't accidentally start a new game after
they bump into an obstacle.
2021-06-20 10:54:27 +01:00
Mim Hufford
018344bb07 FlappyBug: Keep track of score and highscore
Better information is now shown to the player. Instructions are shown
when first loading the program, and any available scores are shown on
the game over screen.
2021-06-20 10:54:27 +01:00
Mim Hufford
3f603ab082 FlappyBug: Start obstacles off the screen
Previously obstacles were respawning fully on-screen which caused a
discontinuous look. Now they smoothly move into view from off-screen.
2021-06-20 10:54:27 +01:00
Mim Hufford
444fcfd0d2 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 :)
2021-06-20 10:54:27 +01:00
Mim Hufford
811d9722f9 FlappyBug: Introduce a new Flappy Bug game
This introduces a Flappy Bug game. It's pretty simple currently, but is
playable.
2021-06-20 10:54:27 +01:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Sam Atkins
364d728e66 Solitaire: Disable filling with background color during end animation
This fixes #7792.

The visual glitches with card corners, and the screen-clear when
opening a menu, were both caused by the widgets having
`fill_with_background_color` set. We need that set most of the time,
so we just disable it for the duration of the game-over animation.

Also resove a FIXME that no longer applies. :^)
2021-06-13 19:29:52 +01:00
Sam Atkins
679f831451 Solitaire: Only start timer when a move happens
Previously, the timer started if you clicked within the game area,
whether that was on a card or not. Now, we only start when you click
on a card or otherwise attempt a move.

As a bonus, we now immediately update the status bar time indicator
on game start, instead of having to wait until 1 second has elapsed.
2021-06-13 19:29:52 +01:00
Sam Atkins
8ee447b718 Solitaire: Prevent undo when the game is over 2021-06-13 19:29:52 +01:00
Sam Atkins
cf504ccc6a Solitaire: Allow automatic moves to end the game and animate
Previously, if a tab-move moved all the remaining cards to the
foundations, the game would not notice until you moved a card
away and then back again.

I had to add a 1-frame delay to starting the animation, so that it
would have time to re-paint the foundation in that case.
2021-06-13 19:29:52 +01:00
Dmitrii Ubskii
f11000b176
2048: Fix move success detection
Whether or not tiles moved used to be determined by comparing new_tiles
with m_tiles. This is no longer possible since the slide is done
in-place.

This fix makes the game look through the m_sliding_tiles, which contains
previous and current position for each tile on the board, to determine
whether any tile moved at all. If not, the move is deemed unsuccessful.

Fixes #8008.
2021-06-12 00:46:11 +01:00