主要数据结构
本节将对本项目的主要数据存储方式作简要说明。
全局设置项
struct settings {
int map_height; //地图高度
int map_width; //地图宽度
int map_board_length; //跳板长度
int player_height; //玩家高度
int player_width; //玩家宽度
int dp_tpf; //每多少tick刷新画面
int dp_tpl; //每多少tick刷新一行
int dp_tpm; //每多少tick玩家因重力下降/弹射上升一行
int dp_line; //当前游戏最底端所在行的编号
};
命名规则
map_开头的变量与地图初始化有关player_开头的变量与玩家有关dp_开头的变量与显示(Display)有关
玩家
struct player {
float x;
int y; //玩家位置,以玩家最下端的中间位置为基准
int prev_board_line; //上一次碰撞的板的所在行
int remain_bounce_line; //还能往上跳多少行
};
跳板
使用链表方式存储画面上所有跳板的数据。
struct board {
int line_id; //板所在行
int x; //左端点位置
char type; //板的类型,默认为0
struct board* next; //下一个节点
};
跳板类型
- Type = 0:普通跳板