Code: Show/Hide struct PlayerPosition
{ int x, y, xspeed, yspeed, rotation; }; struct player_stats_t { int points; int kills, deaths; }; int Player_GetSelfPid(void); int Player_GetSelfTeam(void); int Player_IsSpectator(int pid); int Player_IsSelfSpectator(void); int Player_GetPlayerCount(void); void Player_GetPlayerName(int pid, char *namebuf, int buflen); int Player_GetPlayerTeam(int pid); /* stats */ void Player_SortByPoints(void); void Player_SortByName(void); void Player_EnumStats(void (*func)(int pid, struct player_stats_t *stats, void *clos), void *clos); /* position */ /* copies the value of pos to internal storage. */ void Player_SetPlayerPosition(int pid, struct PlayerPosition *pos); /* copies the internal values to pos */ void Player_GetPlayerPosition(int pid, struct PlayerPosition *pos); /* pos is a pointer to a read only version of the player's position. you can * modify it but it won't get saved unless you call Player_SetPlayerPosition. * note: this only enums players that are in a ship. */ void Player_EnumPositions(void (*func)(int pid, struct PlayerPosition *pos, void *clos), void *clos); |
Code: Show/Hide /* these settings are ok for one color of an ss font sheet. */
#define TEXT_FRAMES_WIDE 48 #define TEXT_FRAMES_HIGH 2 #define TEXT_START_CHAR ' ' #define TEXT_END_CHAR (TEXT_START_CHAR + TEXT_FRAMES_WIDE * TEXT_FRAMES_HIGH) /** font colors */ enum { F_WHITE, F_GREEN, F_BLUE, F_RED, F_YELLOW, F_PURPLE, F_ORANGE, F_PINK, /* the last one */ F_COUNT }; /** basic write text to dest at xy using fontsheet font (the font sheet should * contain only 1 color). */ void GfxText_DrawText(ImageHandle dest, ImageHandle font, int x, int y, const char *format, ...); /* more complex text drawing */ void GfxText_DrawTextCentered(ImageHandle dest, ImageHandle font, int x, int y, const char *format, ...); void GfxText_DrawColoredText(ImageHandle dest, ImageHandle font, int color, int x, int y, const char *format, ...); void GfxText_DrawColoredTextCentered(ImageHandle dest, ImageHandle font, int color, int x, int y, const char *format, ...); |
Code: Show/Hide #define CFG_MAX_SPEED 3000
#define CFG_FRICTION ((double)10 / CFG_MAX_SPEED) ... // per game tick pos->xspeed -= pos->xspeed * CFG_FRICTION; pos->yspeed -= pos->yspeed * CFG_FRICTION; |