⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.h

📁 snake game in avr snake game in avr
💻 H
字号:
/*
** board.h
**
** Written by Peter Sutton - October 2004
**
** Function prototypes for those functions available externally
*/

#include <inttypes.h>

/*
** The board is 16 rows in size. Row 0 is considered to be at the top, 
** row 15 is at the bottom.
*/
#define BOARD_ROWS 16
#define BOARD_WIDTH 16

/* We use the following type for each row */
typedef uint16_t rowtype;

/* Make sure rowtype is big enough to hold
** BOARD_WIDTH number of bits
*/

/* Maximum number of food items
*/
#define MAX_FOOD 8


/*
** Initialise the board. This will reset all 
** the variables that contain board information
** and place an initial snake on the board. The
** procedure will NOT update the display.
*/
void init_board(void); 

/*
** Add/remove a block of the snake to the board at
** the given (x,y) position.
*/
void update_snake_block(int8_t x, int8_t y, int8_t add);

/*
** Returns true (1) if the given position is OFF the board, 
** false otherwise.
*/
int8_t is_off_board(int8_t x, int8_t y);

/*
** Returns true (1) if the snake is occupying
** the given position. (The position MUST be
** on the board.)
*/
int8_t is_snake_at(int8_t x, int8_t y);

/* Returns -1 if there is no food at the given position,
** otherwise it returns the food ID of the food at that
** position. The ID is only valid until the next
** consume_food() operation (and can be used as the
** argument to the consume_food() operation).
** (The given position MUST be on the board.)
*/
int8_t food_at(int8_t x, int8_t y);

/* Attempt to add randomly positioned food items. Returns 
** the number of items actually positioned. (We may place
** fewer than the number requested because (a) we ran out
** of space to store them, or (b) we can't find space on
** the board for them.)
*/
int8_t add_food_items(int8_t number_items);

/*
** Remove a food item from our list of food. This could 
** change the IDs of other food items.
*/
void consume_food(int8_t foodID);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -