ladybird/Userland/Games/2048/CMakeLists.txt

24 lines
474 B
Text
Raw Normal View History

serenity_component(
2048
RECOMMENDED
TARGETS 2048
)
stringify_gml(GameSizeDialog.gml GameSizeDialogGML.h game_size_dialog_gml)
stringify_gml(GameWindow.gml GameWindowGML.h game_window_gml)
2022-10-17 17:03:09 +00:00
2020-08-08 22:10:41 +00:00
set(SOURCES
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 13:01:25 +00:00
BoardView.cpp
Game.cpp
GameSizeDialog.cpp
2020-08-08 22:10:41 +00:00
main.cpp
)
2022-10-17 17:03:09 +00:00
set(GENERATED_SOURCES
GameSizeDialogGML.h
GameWindowGML.h
)
serenity_app(2048 ICON app-2048)
target_link_libraries(2048 PRIVATE LibConfig LibCore LibGfx LibGUI LibMain LibDesktop)