From ffdbbb5e3b8e0d3a2d9b194029b1056ff12a93ac Mon Sep 17 00:00:00 2001 From: mk570rp Date: Sat, 9 May 2026 12:20:49 +0000 Subject: [PATCH] a5 --- a5/.gitignore | 54 ----------------------------------- a5/LICENSE | 29 ------------------- a5/README.md | 78 --------------------------------------------------- a5/main.c | 9 ------ 4 files changed, 170 deletions(-) delete mode 100644 a5/.gitignore delete mode 100644 a5/LICENSE delete mode 100644 a5/README.md delete mode 100644 a5/main.c diff --git a/a5/.gitignore b/a5/.gitignore deleted file mode 100644 index ecf4432..0000000 --- a/a5/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -game - -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/a5/LICENSE b/a5/LICENSE deleted file mode 100644 index 39d1664..0000000 --- a/a5/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2019, Daniel Hládek -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/a5/README.md b/a5/README.md deleted file mode 100644 index b57958c..0000000 --- a/a5/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# World Game Library - -Learn asycnronous C programming by a game. - -The library implements a game loop for a character-based ncurses game; - -The library finds out the event types: - -- start and end -- mouse events -- keyboard events -- screen resize events - -It can print colors and arbitrary characters on the screen. -Running is interrupted when character is drawn out of the screen. - -## Installation and Running - -Make sure, that `ncurses` is installed. - -Clone this repository. - -Compile: - -```c -make -``` - -Run: - -```c -./game -``` - -## Make your own game - -The game happens in a rectangular world of colorful characters. -Your goal as a programmer is to modify the world according to the pressed keys and the internal game state. -The library implements the game loop and draws the world to screen. - -Your game in file `game.c` consists of two functions: - -- `void* init_game()` is called in the beginning. Here you can initialize the internal state of the game. -The function should return a pointer to an instance of the initial game state `game`. -- `int game_event(struct event* event,void* game)` -is called by the game loop in periodic interval or when a key was pressed. Non-zero return value or `Ctrl+C` key interrupts the game loop. - -The world variable represents state of two-dimensional grid of characters on the screen. The screen matrix looks like this: - -``` - origin - [0,0] width - +--------------------+ -h | | -e | | -i | | -g | | -h | | -t | | - +--------------------+ -``` - -The world has the following parameters: - -- `int height`: y-dimension of the grid. -- `int width`: x-dimension of the grid. -- `int interval`: maximum time between steps in milliseconds. - -### The Event Function - -The `int game_event(struct event* event,void* game)` - function should: - -1. Read the game state (from the `void* game`) pointer. -1. Examine the pressed key from event pointer. If the `key` variable is non-zero, a key was pressed. According to the pressed key, modify the game state `game`. -1. Draw the game state. In the beginning of the step function the screen is empty. -1. Returning non-zero value ends the game loop. - diff --git a/a5/main.c b/a5/main.c deleted file mode 100644 index 0446027..0000000 --- a/a5/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "game.h" -#include "world.h" -#include - - -int main(int argc, char** argv){ - start_world(init_game,game_event,free); - return 0; -}