nSnake
A ncurses implementation of the classic Snake game
 All Data Structures Files Functions Variables Enumerations Macros Pages
player.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * nSnake - The classic snake game with ncurses. *
3  * Copyright (C) 2011-2012 Alexandre Dantas (kure) *
4  * *
5  * This file is part of nSnake. *
6  * *
7  * nSnake is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  * homepage: http://sourceforge.net/projects/nsnake/ *
21  * *
22 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
23 
29 #ifndef PLAYER_DEFINED
30 #define PLAYER_DEFINED
31 
32 
33 #include "nsnake.h"
34 
35 
39 {
40  int x;
41  int y;
42 };
43 
44 
47 enum directions { UP = 0, LEFT, DOWN, RIGHT };
48 
49 
56 struct player_t
57 {
58  int is_alive;
59  int speed;
60  int size;
61  int score;
62  int direction;
64  struct player_pieces* body;
65 };
66 
67 
69 extern struct player_t snake;
70 
71 
72 void player_change_direction (int new_direction);
74 void player_exit ();
75 int player_hit_borders ();
76 int player_hit_fruit ();
77 int player_hit_self ();
78 void player_increase_score (int add);
79 void player_increase_size (int size);
80 void player_init ();
82 void player_update ();
83 
84 
85 #endif