00001 /************************************************************************* 00002 stats.cpp 00003 Project Piedmont game 00004 ------------------------- 00005 00006 Date Created: 11/30/00 Last Modified: 05/07/08 00007 Programmer: David Foster 00008 Copyright: (C) 2000 David Foster (see file COPYING) 00009 E-mail: dfoster@computer.org 00010 00011 Description: Responsible for updating the stats (health, score, etc) 00012 to the screen 00013 00014 This program is free software; you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License as published by 00016 the Free Software Foundation; either version 2 of the License, or 00017 (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00027 00028 ************************************************************************/ 00029 00030 #include "stats.h" 00031 00032 Stats::Stats(){ 00033 x = 10; 00034 y = 10; 00035 color1 = 0x0000; //black 00036 color2 = 0xFF00; //yellow 00037 scale = 2; 00038 } 00039 00040 Stats::~Stats(){ 00041 } 00042 00043 void Stats::set_stats_display(Screen &s){ 00044 screen = s; 00045 } 00046 00047 void Stats::set_paul_info(paul_info *p){ 00048 pinfo = p; 00049 // print_paul_info(pinfo); 00050 } 00051 00052 void Stats::update(){ 00053 static char *stat_string = new char[80]; 00054 sprintf(stat_string, "Health: %d/%d Damage: %-2d Keys: %d Score: %-6d Level: %-2d", 00055 pinfo->hitpoints, pinfo->base_health, pinfo->damage, pinfo->keys, pinfo->score, 00056 pinfo->level); 00057 // printf("stat_string: %s\n", stat_string); 00058 // printf("stat_string: %d pixels\n", screen.get_text_width(stat_string)); 00059 00060 screen.write(stat_string, x, y, color1, scale); 00061 screen.write(stat_string, x+2, y+2, color2, scale); 00062 } 00063