From 546cc0f89bf6326f53ce1a40492b2d774767195b Mon Sep 17 00:00:00 2001 From: Yaroslav Orlianskyi Date: Sat, 4 Jun 2022 17:51:34 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20'f?= =?UTF-8?q?inal/world.git'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- final/world.git | 1854 ----------------------------------------------- 1 file changed, 1854 deletions(-) delete mode 100644 final/world.git diff --git a/final/world.git b/final/world.git deleted file mode 100644 index 676177e..0000000 --- a/final/world.git +++ /dev/null @@ -1,1854 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GitHub - hladek/world: Text game library for learning C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - - -
- -
- - - - - - - -
- - - -
- - - - - - - - - -
-
-
- - - - - - - - - - - - - - - - - -
- - - - - - -

hladek/world

-
- - -
- - -
- -
- - - - - -
-
- -
- -
-
- - - master - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - - -
- - - - - - - - -
- Code - -
- -
-
- -
- - -
-
- - - - -
-
-

Latest commit

-
- -
-
 
-
-

Git stats

- -
-
-
-

Files

- - - - - Permalink - -
- - - Failed to load latest commit information. - - - -
-
-
-
Type
-
Name
-
Latest commit message
-
Commit time
-
- -
-
- -
- - - -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- LICENSE -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- Makefile -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- README.md -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- game.c -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- game.h -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- main.c -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- world.c -
- -
-
 
-
- -
-
 
-
- -
-
-
- -
- -
- world.h -
- -
-
 
-
- -
-
 
-
- -
-
- -
- -
- - -
- - - - -
- -
-
- - -

- README.md - -

-
-
- -
-

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:

-
make
-

Run:

-
./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.
  2. -
  3. 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.
  4. -
  5. Draw the game state. In the beginning of the step function the screen is empty.
  6. -
  7. Returning non-zero value ends the game loop.
  8. -
-
-
-
- -
- - -
-
- -
-
-
-

About

- -

- Text game library for learning C -

- -

Topics

- - -

Resources

- - -

License

- - - - - - - -

Stars

- - -

Watchers

- - -

Forks

- - -
-
-
-
-

- - Releases - -

- -
No releases published
- -
-
-
-
-

- - Packages - -

- - -
- No packages published
-
- - - -
-
- -
-
-

Languages

-
- - - -
- - -
-
-
-
- -
- -
- - -
- - -
-
- -
- - - - - - - - - - - - - - - - - - - - -