diff --git a/.vscode/launch.json b/.vscode/launch.json index 38f0354..c09f005 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,8 +8,8 @@ "type": "lldb", "request": "launch", "name": "Debug", - "program": "${workspaceFolder}/builddir/2048", - "args": [], + "program": "${workspaceFolder}/builddir/src/2048", + "args": ["--y", "5", "--x", "4"], "cwd": "${workspaceFolder}" } ] diff --git a/2048.code-workspace b/2048.code-workspace deleted file mode 100644 index 876a149..0000000 --- a/2048.code-workspace +++ /dev/null @@ -1,8 +0,0 @@ -{ - "folders": [ - { - "path": "." - } - ], - "settings": {} -} \ No newline at end of file diff --git a/README.md b/README.md index 7cef32a..7ace871 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,8 @@ To run, run: # Usage -You can pass `--help` as an command line argument to print help message. You can force incomplete TUI mode that exists for a demonstration of portability and independence of SDL. This TUI mode is incomplete only because it's missing few UI elements and not because it is not feasible. You can also force other sizes of the game area. \ No newline at end of file +You can pass `--help` as an command line argument to print help message. You can force incomplete TUI mode that exists for a demonstration of portability and independence on SDL. This TUI mode is incomplete only because it's missing few UI elements and not because it is not feasible. You can also force other sizes of the game area (square ones are recommended). + +# Note + +This project uses open source font. You can find the font licence file in the resource folder. \ No newline at end of file diff --git a/res/LiberationSerif-Regular.ttf b/res/LiberationSerif-Regular.ttf new file mode 100644 index 0000000..8d27335 Binary files /dev/null and b/res/LiberationSerif-Regular.ttf differ diff --git a/res/font LICENSE b/res/font LICENSE new file mode 100644 index 0000000..aba73e8 --- /dev/null +++ b/res/font LICENSE @@ -0,0 +1,102 @@ +Digitized data copyright (c) 2010 Google Corporation + with Reserved Font Arimo, Tinos and Cousine. +Copyright (c) 2012 Red Hat, Inc. + with Reserved Font Name Liberation. + +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 + +PREAMBLE The goals of the Open Font License (OFL) are to stimulate +worldwide development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to provide +a free and open framework in which fonts may be shared and improved in +partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. +The fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + + + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. +This may include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components +as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting ? in part or in whole ? +any of the components of the Original Version, by changing formats or +by porting the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical writer +or other person who contributed to the Font Software. + + +PERMISSION & CONDITIONS + +Permission is hereby granted, free of charge, to any person obtaining a +copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components,in + Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, + redistributed and/or sold with any software, provided that each copy + contains the above copyright notice and this license. These can be + included either as stand-alone text files, human-readable headers or + in the appropriate machine-readable metadata fields within text or + binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font + Name(s) unless explicit written permission is granted by the + corresponding Copyright Holder. This restriction only applies to the + primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font + Software shall not be used to promote, endorse or advertise any + Modified Version, except to acknowledge the contribution(s) of the + Copyright Holder(s) and the Author(s) or with their explicit written + permission. + +5) The Font Software, modified or unmodified, in part or in whole, must + be distributed entirely under this license, and must not be distributed + under any other license. The requirement for fonts to remain under + this license does not apply to any document created using the Font + Software. + + + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + + + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER +DEALINGS IN THE FONT SOFTWARE. + diff --git a/src/2048.c b/src/2048.c index 30a82d2..c6b7d6f 100644 --- a/src/2048.c +++ b/src/2048.c @@ -48,12 +48,12 @@ Game game_init(size_t field_size_x, size_t field_size_y) { return game; } -void game_destroy(Game game) { - for (size_t i = 0; i < game.field_size_y; i++) { - free(game.field[i]); +void game_destroy(Game *game) { + for (size_t i = 0; i < game->field_size_x; i++) { + free(game->field[i]); } - free(game.field); - game.field = NULL; + free(game->field); + game->field = NULL; } void game_move(Game *game, Direction direction) { diff --git a/src/2048.h b/src/2048.h index f5990c3..cabe0c1 100644 --- a/src/2048.h +++ b/src/2048.h @@ -24,6 +24,6 @@ typedef struct Game Game game_init(size_t field_size_x, size_t field_size_y); void game_move(Game *game, Direction direction); -void game_destroy(Game game); +void game_destroy(Game *game); #endif \ No newline at end of file diff --git a/src/gui.c b/src/gui.c index 18fadbd..2016b76 100644 --- a/src/gui.c +++ b/src/gui.c @@ -70,7 +70,7 @@ void gui_init() { game_over_texture = texture_from_png("res/game_over.png"); you_won_texture = texture_from_png("res/you_won.png"); - Sans = TTF_OpenFont("/usr/share/fonts/liberation/LiberationSerif-Regular.ttf", 92); + Sans = TTF_OpenFont("res/LiberationSerif-Regular.ttf", 92); } void gui_destroy() { diff --git a/src/main.c b/src/main.c index aa141b6..beea78b 100644 --- a/src/main.c +++ b/src/main.c @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { gui_init(); gui_loop(&game); gui_destroy(); - game_destroy(game); } + game_destroy(&game); return 0; }