1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/* $Id: info.c,v 1.8 2005/07/02 05:32:28 oohara Exp $ */
#include <stdio.h>
/* strlen */
#include <string.h>
#include "tenm_object.h"
#include "const.h"
#include "util.h"
#include "score.h"
#include "ship.h"
#include "chain.h"
#include "info.h"
static int chain_scroll = 0;
static int ship_scroll = 0;
static int score_scroll = 0;
void
clear_chain_scroll(void)
{
chain_scroll = 0;
}
/* return 0 on success, 1 on error */
int
show_chain(const tenm_object *player)
{
char temp[16];
int chain;
/* sanity check */
chain = get_chain();
if (chain < 0)
return 0;
/* hide the stat if the game is still on and
* if the player is near it
*/
if ((player != NULL) && (get_ship() >= 0)
&& (player->x > (double) (WINDOW_WIDTH * 2 / 3))
&& (player->y < 60.0))
{
if (chain_scroll < 20)
chain_scroll += 2;
}
else
{
if (chain_scroll > 0)
chain_scroll -= 2;
}
sprintf(temp, "chain %4d", chain);
if (draw_string(WINDOW_WIDTH - 100, 10 - chain_scroll,
temp, (int) strlen(temp)) != 0)
{
fprintf(stderr, "show_chain: draw_string failed\n");
return 1;
}
return 0;
}
void
clear_ship_scroll(void)
{
ship_scroll = 0;
}
/* return 0 on success, 1 on error */
int
show_ship(const tenm_object *player)
{
int ship;
char temp[16];
/* sanity check */
ship = get_ship();
if (ship < 0)
return 0;
/* hide the stat if the game is still on and
* if the player is near it
*/
if ((player != NULL) && (get_ship() >= 0)
&& (player->x > (double) (WINDOW_WIDTH * 2 / 3))
&& (player->y > (double) (WINDOW_HEIGHT - 60)))
{
if (ship_scroll < 20)
ship_scroll += 2;
}
else
{
if (ship_scroll > 0)
ship_scroll -= 2;
}
sprintf(temp, "ship %3d", ship);
if (draw_string(WINDOW_WIDTH - 80, WINDOW_HEIGHT - 10 + ship_scroll,
temp, (int) strlen(temp)) != 0)
{
fprintf(stderr, "show_ship: draw_string failed\n");
return 1;
}
return 0;
}
void
clear_score_scroll(void)
{
score_scroll = 0;
}
/* return 0 on success, 1 on error */
int
show_score(const tenm_object *player)
{
int score;
char temp[32];
score = get_score();
/* hide the stat if the game is still on and
* if the player is near it
*/
if ((player != NULL) && (get_ship() >= 0)
&& (player->x < (double) (WINDOW_WIDTH / 3))
&& (player->y > (double) (WINDOW_HEIGHT - 60)))
{
if (score_scroll < 20)
score_scroll += 2;
}
else
{
if (score_scroll > 0)
score_scroll -= 2;
}
sprintf(temp, "score %8d", score);
if (draw_string(10, WINDOW_HEIGHT - 10 + score_scroll,
temp, (int) strlen(temp)) != 0)
{
fprintf(stderr, "show_score: draw_string failed\n");
return 1;
}
return 0;
}
|