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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
/*
* Don Ceferino Hazaa - video game similary to Super Pang!
* Copyright (c) 2004, 2005 Hugo Ruscitti
* web site: http://www.loosersjuegos.com.ar
*
* This file is part of Don Ceferino Hazaa (ceferino).
* Written by Hugo Ruscitti <hugoruscitti@yahoo.com.ar>
*
* Don Ceferino Hazaa is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Don Ceferino Hazaa is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <string.h>
#include <ctype.h>
#include "fuente.h"
#include "procesos.h"
#include "juego.h"
/*!
* \brief vincula la barra al juego
*/
void barra :: iniciar(class juego *_juego, grafico *_graficos, SDL_Surface *_screen)
{
graficos=_graficos;
pjuego=_juego;
screen=_screen;
rect.x=0;
rect.y=screen->h - graficos->get_h();
rect.w=screen->w;
rect.h=graficos->get_h();
ant_tiempo=-1;
ant_vidas=-1;
ant_puntos=-1;
}
/*!
* \brief imprime todo el fondo de la barra
*/
void barra :: imprimir_fondo(void)
{
SDL_Rect tmp;
int i;
graficos->imprimir(0, screen, &tmp, 0, 448, 1);
for (i=0; i<6; i++)
graficos->imprimir(1, screen, &tmp, 32+i*32, 448, 1);
// etiqueta tiempo
graficos->imprimir(3, screen, &tmp, 224, 448, 1);
graficos->imprimir(4, screen, &tmp, 256, 448, 1);
for (i=0; i<5; i++)
graficos->imprimir(1, screen, &tmp, 288+i*32, 448, 1);
// etiqueta puntos
graficos->imprimir(5, screen, &tmp, 448, 448, 1);
graficos->imprimir(6, screen, &tmp, 480, 448, 1);
for (i=0; i<2; i++)
graficos->imprimir(1, screen, &tmp, 512+i*32, 448, 1);
graficos->imprimir(2, screen, &tmp, 608, 448, 1);
}
/*!
* \brief imprime el tiempo restante
*/
void barra :: imprimir_tiempo(void)
{
SDL_Rect tmp;
if (tiempo<0)
tiempo=0;
graficos->imprimir(1, screen, &tmp, 224+64, 448,1);
graficos->imprimir(1, screen, &tmp, 224+64+32, 448,1);
graficos->imprimir(10+ tiempo/10, screen, &tmp, 224+32+32, 448, 1);
graficos->imprimir(10+ tiempo%10, screen, &tmp, 224+32+32+32, 448, 1);
}
/*!
* \brief informa la cantidad de vidas
*/
void barra :: imprimir_vidas(void)
{
SDL_Rect tmp;
int i;
// imprime las vidas
for (i=0; i < vidas && i <6; i++)
graficos->imprimir(8, screen, &tmp, 32*i, 448, 1);
graficos->imprimir(1, screen, &tmp, 32*i, 448, 1);
}
/*!
* \brief informa los puntos acumulados
*/
void barra :: imprimir_puntos(void)
{
SDL_Rect tmp;
graficos->imprimir(1, screen, &tmp, 512, 448, 1);
graficos->imprimir(1, screen, &tmp, 544, 448, 1);
graficos->imprimir(1, screen, &tmp, 576, 448, 1);
graficos->imprimir(1, screen, &tmp, 608, 448, 1);
graficos->imprimir(10+(puntos/1000), screen, &tmp, 512, 448, 1);
graficos->imprimir(10+(puntos/100)%10, screen, &tmp, 544, 448, 1);
graficos->imprimir(10+(puntos/10)%10, screen, &tmp, 576, 448, 1);
graficos->imprimir(10+(puntos%10), screen, &tmp, 608, 448, 1);
}
/*!
* \brief imprime la barra nuevamente
*/
void barra :: imprimir_todo(void)
{
int h;
if (screen->h == 480)
h=32;
else
h=16;
imprimir_fondo();
imprimir_tiempo();
imprimir_vidas();
imprimir_puntos();
SDL_UpdateRect(screen, 0, screen->h-h, screen->w, h);
}
/*!
* \brief imprime y actualiza los nuevos valores
*
* \param _tiempo segundos restantes para pasar de nivel
* \param _vidas vidas del protagonista
* \param _puntos puntaje del protagonista
*/
void barra :: actualizar(int _tiempo, int _vidas, int _puntos)
{
tiempo = _tiempo;
vidas = _vidas;
puntos = _puntos;
if (ant_tiempo != tiempo)
imprimir_tiempo();
if (ant_vidas != vidas)
imprimir_vidas();
if (ant_puntos != puntos)
imprimir_puntos();
ant_tiempo = tiempo;
ant_vidas = vidas;
ant_puntos = puntos;
SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h);
}
|