Commit graph

194 commits

Author SHA1 Message Date
AnicJov e119d7d6b9 Chess: Added ability to put markings on the board
With this patch you can use right-click to mark a square on the board.
You can add modifier keys to the click to change to alternate color
(with CTRL) or secondary color (with Shift). If you right-click and
drag from one square to another you will create an arrow. The
markings go away as soon as you left-click on the board or the board
state changes.

Note: The arrows sometimes look weird, and horizontal ones get cut
      off. They also don't account for alpha. This is not a bug in
      Chess code, rather, likely in the fill_path() function that's
      used to draw the arrows. If anyone might know what's up with
      that I urge you to take a look. :)
2020-12-10 20:40:51 +01:00
AnicJov f631e73519 Chess: Added abilty to import PGN files
This patch allows the user to load games using PGN files. The parsing
is not complete and has a bunch of work left to be done, but it's
okay for our use case here. It can load all of the games our PGN
exporter can save. As the Chess program impoves so can the PGN parser.
2020-12-10 20:40:51 +01:00
AnicJov 4d9837d792 Chess: Add ability to replay moves
This patch allows the user to go back and forward in move history
to replay moves from the game. This is view-only however, and as soon
as a move is made the board returns to it's current state. This will
work well for replaying games loaded in with PGN files, once that's
implemented.
2020-12-10 20:40:51 +01:00
AnicJov cf8fce368a Chess: Added ability to copy board state as FEN
You can now copy the board state as Forsyth-Edwards Notation. You can
then paste this into other chess programs/games, or into ours when
it gets implemented.
2020-12-10 20:40:51 +01:00
AnicJov b000a884c8 Chess: Change keyboard shortcuts
Use some better keyboard shortcuts that make more sense and are more
common, instead of random function keys.
2020-12-10 20:40:51 +01:00
AnicJov fe1628746c Chess: Add ability to export game as PGN file
This patch adds an option to the menubar for exporting the current
game as a PGN file. This file can then be read by other chess
programs (and ours eventually) to replay the game or analyze it.
The implementation is mostly PGN spec compliant, however the code
could use some more work. Particularly the `const_cast`s...
But it's a start. :^)

Fixup: Chess: Fixed hard-coded home path in unveil() call

Fixup: Chess: Removed castling flags from Move struct

The castling detection logic is done inside Move::to_algebraic()
now, removing the need for is_castle_short and is_castle_long flags
inside of the Move struct.
2020-12-06 15:51:34 +01:00
AnicJov 01b62cc7f4 Chess: Added ability to resign and flip the board
This patch adds options to the app's menubar to resign the game and
flip the board.
2020-12-06 15:51:34 +01:00
AnicJov 694f68ab86 Chess: Change default piece set
As much as I like the "test" piece set, I think "stelar7" is a much
better first impression for anyone opening the Chess game, so I
consider it a much more sensible default.
2020-12-06 15:51:34 +01:00
John Brehm 6914cf830d
Games: Added level select and aditional level to Breakout (#4302)
Added a level select menu which is shown when the game start where
either of the 2 available levels may be selected.
2020-12-02 23:49:42 +01:00
Andreas Kling 626c17d284 Breakout: Add simple menu and about dialog :^) 2020-11-10 14:32:45 +01:00
Andreas Kling 51e7c6e348 Breakout: Set the window icon 2020-11-10 14:32:45 +01:00
Andreas Kling 8c88bf31ed Breakout: Turn off double-buffering 2020-11-10 14:32:45 +01:00
Andreas Kling 959038d410 Breakout: Change ball x velocity depending on where it hits paddle
This makes the game less deterministic and more fun. The "physics"
definitely feel a little goofy, and I'm sure they can be greatly
improved, but still it's already better. :^)
2020-11-10 14:32:45 +01:00
Andreas Kling 844c2e1f3b Breakout: Stop paddle movement when resetting it 2020-11-10 14:32:45 +01:00
Andreas Kling d05d519b0d Breakout: Use floating point coordinates 2020-11-10 14:32:45 +01:00
Andreas Kling 0bf927a824 Breakout: Use the pending new ball rect for brick collision testing
Otherwise the ball will bounce one frame *after* hitting a brick.
2020-11-09 13:34:27 +01:00
Andreas Kling 8e4e77fcf4 Breakout: Add a very simple breakout game :^)
Made with HackStudio! This needs some love to feel like a proper game,
but the basics are here.
2020-11-09 13:34:27 +01:00
Brendan Coles e558f6b184 Minesweeper+Snake: load config file before calling unveil() 2020-11-04 19:36:27 +01:00
Brendan Coles 9f8a8e07c2 Games: Use pledge and unveil 2020-11-02 13:16:01 +01:00
Brendan Coles 7c5e488de2 Games: Use GUI::Icon::default_icon to set application icon 2020-11-01 10:29:27 +01:00
Andreas Kling 982e066100 LibGfx: Move FontDatabase from LibGUI to LibGfx
Not sure why I put this into LibGUI in the first place.
2020-10-31 13:56:21 +01:00
Brendan Coles e569f7fd1c Applications: Use application icons for dialog windows 2020-10-31 13:48:15 +01:00
Till Mayer 2ac734b7a8 Solitaire: Play animation when starting a new game 2020-10-26 21:36:40 +01:00
Till Mayer ef458f7b66 Solitaire: Refactor CardStack layout code 2020-10-26 21:36:40 +01:00
Andreas Kling 05ff75c321 Snake: Use the system default fixed-width font
Instead of looking one up by name.
2020-10-26 11:33:27 +01:00
Andreas Kling 9d347352a1 LibGfx+LibGUI+Clients: Make fonts findable by their qualified name
The qualified name of a font is "<Family> <Size> <Weight>". You can
get the QN of a Font via the Font::qualified_name() API, and you can
get any system font by QN from the GUI::FontDatabase. :^)
2020-10-25 21:18:18 +01:00
Linus Groh 82956a08b3 LibCore: Rename File::ShouldCloseFile{Description => Descriptor}
From https://youtu.be/YNSAZIW3EM0?t=1474:

"Hmm... I don't think that name is right! From the perspective of
userspace, this is a file descriptor. File description is what the
kernel internally keeps track of, but as far as userspace is concerned,
he just has a file descriptor. [...] Maybe that name should be changed."

Core::File even has a member of this enum type... called
m_should_close_file_descriptor - so let's just rename it :^)
2020-10-25 13:59:41 +01:00
asynts 80e23d1b98 Games: Use new format functions. 2020-10-17 23:20:31 +02:00
Linus Groh bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Ben Wiederhake fa62c5595e Meta+Games: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Peter Elliott e46b4e0865 Minesweeper: Fix inverted Single-Click Chording setting
This was introduced by 705cee528a,
where the '!' was copied from the previous implementation, but the
behavior was not
2020-09-18 09:42:26 +02:00
thankyouverycool a49e0fa5d4 Base: Create /res/icons/solitaire/ and relocate solitaire assets 2020-08-27 15:38:02 +02:00
Ben Wiederhake 9f7ec33180 Meta: Force semi-colon after MAKE_AK_NONXXXABLE()
Before, we had about these occurrence counts:
COPY: 13 without, 33 with
MOVE: 12 without, 28 with

Clearly, 'with' was the preferred way. However, this introduced double-semicolons
all over the place, and caused some warnings to trigger.

This patch *forces* the usage of a semi-colon when calling the macro,
by removing the semi-colon within the macro. (And thus also gets rid
of the double-semicolon.)
2020-08-27 10:12:04 +02:00
Peter Elliott 274be68102 Chess: Allow resizing Chess using resize_aspect_ratio(1,1) 2020-08-23 01:05:22 +02:00
Peter Elliott b0ffd4e946 Chess: Optionaly display coordinates at edge of board 2020-08-23 01:05:22 +02:00
Peter Elliott 1e57e32a93 ChessEngine: Add ChessEngine
This engine is pretty bad, but doesn't let itself get checkmated
2020-08-21 12:26:30 +02:00
Peter Elliott fb62eed058 Chess: Add support for UCI engines 2020-08-21 12:26:30 +02:00
Peter Elliott d2cb5e0f48 Chess: Refactor game logic into LibChess for use in engines
In the future UCI protocol stuff will also go into LibChess.
2020-08-21 12:26:30 +02:00
Peter Elliott ffece9cfba Chess: Add serialization of moves and squares 2020-08-21 12:26:30 +02:00
Peter Elliott 6c2d0dea91 Chess: Fix generation of promotion moves 2020-08-21 12:26:30 +02:00
AnotherTest 5619ed1dc6 2048: Make board size and target tile configurable
This adds a "settings" option that allows the user to configure the
board size and target tile, and optionally save them to a config file.
Closes #3219.
2020-08-21 11:45:46 +02:00
AnotherTest 40c16b3ce5 2048: Do not allow the creation of games with invalid board sizes
The logic only works with nxn grids, so no need to take separate
row_size/column_size arguments.
2020-08-21 11:45:46 +02:00
Sergey Bugaev 4f06cda8f8 2048: Tweak default window size
As requested by @nico
2020-08-18 17:19:52 +02:00
Sergey Bugaev 7861ebaad7 2048: Generate more "2" tiles
This is how the original game does it.
2020-08-18 17:19:52 +02:00
Sergey Bugaev 8dd5b0af4e 2048: Move score to a status bar
See how straightforward this was? That's because, thanks to the separation
between the model and the view, we can tweak the view without modifying the
model in any way.
2020-08-18 17:19:52 +02:00
Sergey Bugaev 05ea144961 2048: Separate game logic from the view :^)
Look Ali, it's simple:

* The *model* (in many cases, an instance of GUI::Model, but it doesn't have to
  be) should implement the "business logic" (in this case, game logic) and
  should not concern itself with how the data/state is displayed to the user.

* The *view*, conversely, should interact with the user (display data/state,
  accept input) and should not concern itself with the logic. As an example, a
  GUI::Button can display some text and accept clicks -- it doesn't know or care
  what that text *means*, or how that click affects the app state. All it does
  is it gets its text from *somebody* and notifies *somebody* of clicks.

* The *controller* connects the model to the view, and acts as "glue" between
  them.

You could connect *several different* views to one model (see FileManager), or
use identical views with different models (e.g. a table view can display pretty
much anything, depending on what model you connect to it).

In this case, the model is the Game class, which maintains a board and
implements the rules of 2048, including tracking the score. It does not display
anything, and it does not concern itself with undo management. The view is the
BoardView class, which displays a board and accepts keyboard input, but doesn't
know how exactly the tiles move or merge -- all it gets is a board state, ready
to be displayed. The controller is our main(), which connects the two classes
and bridges between their APIs. It also implements undo management, by basically
making straight-up copies of the game.

Isn't this lovely?
2020-08-18 17:19:52 +02:00
Sergey Bugaev 99efc01b2e 2048: Automatically pick an appropriate font size 2020-08-18 17:19:52 +02:00
Sergey Bugaev 50d81f1e14 2048: Use the original colors 2020-08-18 17:19:52 +02:00
Sergey Bugaev 70356429ae 2048: Tweak cell metrics
This makes the game look closer to the original.

It also fixes a weird thing where cells were displayed in a wrong order (as if
mirrored or something), and to accommodate for that keyboard actions were also
mixed up. Now it's all working as intended.
2020-08-18 17:19:52 +02:00
Tibor Nagy fbc3b8e3c8 Solitaire: Rename "Restart game" menu item to "New game"
Also adding a shortcut (F2) to make it consistent with other games.
2020-08-17 17:39:56 +02:00