Page MenuHomePhabricator (Chris)

No OneTemporary

Size
16 KB
Referenced Files
None
Subscribers
None
diff --git a/SRC/AlmacenDeFuentes.cpp b/SRC/AlmacenDeFuentes.cpp
index 7acf50b..f71f3b2 100644
--- a/SRC/AlmacenDeFuentes.cpp
+++ b/SRC/AlmacenDeFuentes.cpp
@@ -1,8 +1,8 @@
#include "AlmacenDeFuentes.hpp"
#include <iostream>
AlmacenDeFuentes::AlmacenDeFuentes()
{
- if (!liberation.loadFromFile("/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf"))
+ if (!arial.loadFromFile("/usr/share/comecocos/Fonts/arial.ttf"))
std::cout<<"fallo al leer la fuente "<<std::endl;
}
diff --git a/SRC/AlmacenDeFuentes.hpp b/SRC/AlmacenDeFuentes.hpp
index 2137bc9..2a6e0ae 100644
--- a/SRC/AlmacenDeFuentes.hpp
+++ b/SRC/AlmacenDeFuentes.hpp
@@ -1,22 +1,22 @@
#ifndef ALMACENDEFUENTES_H
#define ALMACENDEFUENTES_H
#include <SFML/Graphics.hpp>
class AlmacenDeFuentes
{
private:
AlmacenDeFuentes();
- sf::Font liberation;
+ sf::Font arial;
public:
static const AlmacenDeFuentes& getInstancia()
{
static AlmacenDeFuentes instancia;
return instancia;
}
- const sf::Font& getLiberation() const {return liberation;}
+ const sf::Font& getArial() const {return arial;}
};
#endif // ALMACENDEFUENTES_H
diff --git a/SRC/Puntuacion.cpp b/SRC/Puntuacion.cpp
index adfd6e9..f3bb3f6 100644
--- a/SRC/Puntuacion.cpp
+++ b/SRC/Puntuacion.cpp
@@ -1,61 +1,61 @@
#include "Puntuacion.hpp"
#include "AlmacenDeFuentes.hpp"
#include "AlmacenDeGraficos.hpp"
#include "Puntuacion.hpp"
#include <sstream>
#include "Estado.hpp"
Puntuacion::Puntuacion()
{
//ctor
- marcador.setFont(AlmacenDeFuentes::getInstancia().getLiberation());
+ marcador.setFont(AlmacenDeFuentes::getInstancia().getArial());
marcador.setPosition(300,640);
marcador.setCharacterSize(24);
marcador.setColor(sf::Color::White);
actualizarMarcador();
Estado::getInstancia().anyadirCallback(this);
}
void Puntuacion::comerComida()
{
puntos += 20;
actualizarMarcador();
}
void Puntuacion::comerPildora()
{
puntos += 30;
actualizarMarcador();
}
void Puntuacion::comerFantasma(sf::Vector2f pos)
{
puntos += 200*incr;
incr *= 2;
sprite.setPosition(pos);
sprite.setTexture(AlmacenDeGraficos::getInstancia().getPuntos(consecutivos));
consecutivos++;
actualizarMarcador();
}
void Puntuacion::actualizarMarcador()
{
std::stringstream stream;
stream<<"Puntos: "<<puntos;
marcador.setString(stream.str());
}
void Puntuacion::disableRampage()
{
consecutivos = 0;
incr = 1;
sprite.setPosition(-20,-20);
}
Puntuacion::~Puntuacion()
{
Estado::getInstancia().eliminarCallback(this);
}
diff --git a/SRC/main.cpp b/SRC/main.cpp
index b629b3a..d9325ca 100644
--- a/SRC/main.cpp
+++ b/SRC/main.cpp
@@ -1,190 +1,190 @@
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "Tablero.hpp"
#include "Pacman.hpp"
#include "FantasmaRojo.hpp"
#include "FantasmaRosa.hpp"
#include "FantasmaAmarillo.hpp"
#include "FantasmaAzul.hpp"
#include "Estado.hpp"
#include "AlmacenDeSonido.hpp"
#include "AlmacenDeFuentes.hpp"
#include "Puntuacion.hpp"
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <memory>
const int RESOLUCIONX = 560;
const int RESOLUCIONY = 680;
const int POS_INICIAL_PACMANX = 13;
const int POS_INICIAL_PACMANY = 23;
int main()
{
std::srand(std::time(0));
// Create the main window
sf::RenderWindow app(sf::VideoMode(560, 680), "Comecocos");
app.setFramerateLimit(60);
/**
* Bucle principal del juego:
*
* - Eventos, llamadas a las set Dirrecion
* - moverPersonaje()
* - moverFantasmas()
* - Dibujado
*/
int vidas = 3;
int nivel = 1;
sf::Text vidas_y_nivel;
- vidas_y_nivel.setFont(AlmacenDeFuentes::getInstancia().getLiberation());
+ vidas_y_nivel.setFont(AlmacenDeFuentes::getInstancia().getArial());
vidas_y_nivel.setCharacterSize(24);
vidas_y_nivel.setPosition(50,RESOLUCIONY-40);
sf::Sound introduccion;
introduccion.setBuffer(AlmacenDeSonido::getInstancia().getPacman_beginning());
Puntuacion puntuacion;
std::unique_ptr<Tablero> tablero(new Tablero(RESOLUCIONX,RESOLUCIONY,puntuacion));
while (vidas && app.isOpen())
{
std::cout<<"Vidas: "<<vidas<<std::endl<<"Nivel: "<<nivel<<std::endl<<std::endl;
vidas_y_nivel.setString("Vidas: "+std::to_string(vidas) + " Nivel: " + std::to_string(nivel));
//Tablero tablero(RESOLUCIONX,RESOLUCIONY);
Pacman pacman(*tablero,POS_INICIAL_PACMANX,POS_INICIAL_PACMANY);
FantasmaRojo fantasma_rojo(*tablero,pacman,puntuacion,13,13);
FantasmaRosa fantasma_rosa(*tablero,pacman,puntuacion,13,14,fantasma_rojo);
FantasmaAmarillo fantasma_amarillo(*tablero,pacman,puntuacion,14,13);
FantasmaAzul fantasma_azul(*tablero,pacman,puntuacion,14,14);
pacman.disableMov();
fantasma_rojo.disableMov();
fantasma_rosa.disableMov();
fantasma_amarillo.disableMov();
fantasma_azul.disableMov();
// sf::Event event;
sf::Clock reloj;
reloj.restart();
introduccion.play();
//Fantasmas fantasmas;
// Start the game loop
while (app.isOpen() && tablero->getComida() > 0 && !pacman.terminado())
{
// Process events
sf::Event event;
while (app.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
app.close();
if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::A || event.key.code == sf::Keyboard::Left)
{
pacman.setIzquierdaDireccion();
}
else if (event.key.code == sf::Keyboard::D || event.key.code == sf::Keyboard::Right)
{
pacman.setDerechaDireccion();
}
else if (event.key.code == sf::Keyboard::W || event.key.code == sf::Keyboard::Up)
{
pacman.setArribaDireccion();
}
else if (event.key.code == sf::Keyboard::S || event.key.code == sf::Keyboard::Down)
{
pacman.setAbajoDireccion();
}
else if (event.key.code == sf::Keyboard::K)
{
pacman.matar();
}
else if (event.key.code == sf::Keyboard::Escape)
{
app.close();
}
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A) || sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
pacman.setIzquierdaDireccion();
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D) || sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
pacman.setDerechaDireccion();
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) || sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
pacman.setAbajoDireccion();
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
pacman.setArribaDireccion();
}
if (reloj.getElapsedTime() >= sf::seconds(4))
{
// Ya ha terminado la animación. Ya se puede correr
pacman.enableMov();
fantasma_rojo.enableMov();
fantasma_rosa.enableMov();
fantasma_amarillo.enableMov();
fantasma_azul.enableMov();
}
Estado::getInstancia().refresh();
pacman.mover();
fantasma_rojo.mover();
fantasma_rosa.mover();
fantasma_amarillo.mover();
fantasma_azul.mover();
/*if (fantasmas.mover())
{
app.close();
}*/
app.clear();
app.draw(tablero->getRepresentacion());
app.draw(fantasma_rojo.getSprite());
app.draw(fantasma_rosa.getSprite());
app.draw(fantasma_amarillo.getSprite());
app.draw(fantasma_azul.getSprite());
app.draw(pacman.getSprite());
app.draw(puntuacion.getText());
app.draw(puntuacion.getPuntuacionEmergente());
app.draw(vidas_y_nivel);
//app.draw(sf::Sprite(AlmacenDeGraficos::getInstancia().getFantasma(0,0,1)));
app.display();
}
vidas -= pacman.terminado();
if (tablero->getComida() == 0)
{
tablero.reset(new Tablero(RESOLUCIONX,RESOLUCIONY,puntuacion));
nivel++;
}
Estado::getInstancia().desactivarRampage();
}
return EXIT_SUCCESS;
}
diff --git a/makefile b/makefile
index e162e07..3ac94f8 100644
--- a/makefile
+++ b/makefile
@@ -1,163 +1,163 @@
WORKDIR = `pwd`
CC = gcc
CXX = g++
AR = ar
LD = g++
WINDRES = windres
INC =
CFLAGS = -std=c++11 -Wall
RESINC =
LIBDIR =
LIB = -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
LDFLAGS =
INC_DEBUG = $(INC) -Iinclude -ISRC -ISRC/
CFLAGS_DEBUG = $(CFLAGS) -g
RESINC_DEBUG = $(RESINC)
RCFLAGS_DEBUG = $(RCFLAGS)
LIBDIR_DEBUG = $(LIBDIR)
LIB_DEBUG = $(LIB)
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = obj/Debug
DEP_DEBUG =
OUT_DEBUG = RemakeComecocos-Debug
INC_RELEASE = $(INC) -Iinclude -ISRC -ISRC/
CFLAGS_RELEASE = $(CFLAGS) -O2
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB)
LDFLAGS_RELEASE = $(LDFLAGS) -s
OBJDIR_RELEASE = obj/Release
DEP_RELEASE =
-OUT_RELEASE = comecocos
+OUT_RELEASE = RemakeComecocos
OBJ_DEBUG = $(OBJDIR_DEBUG)/SRC/Tablero.o $(OBJDIR_DEBUG)/SRC/FantasmaRosa.o $(OBJDIR_DEBUG)/SRC/Pacman.o $(OBJDIR_DEBUG)/SRC/Personaje.o $(OBJDIR_DEBUG)/SRC/Puntuacion.o $(OBJDIR_DEBUG)/SRC/main.o $(OBJDIR_DEBUG)/SRC/Estado.o $(OBJDIR_DEBUG)/SRC/AlmacenDeFuentes.o $(OBJDIR_DEBUG)/SRC/AlmacenDeGraficos.o $(OBJDIR_DEBUG)/SRC/AlmacenDeSonido.o $(OBJDIR_DEBUG)/SRC/Fantasma.o $(OBJDIR_DEBUG)/SRC/FantasmaAmarillo.o $(OBJDIR_DEBUG)/SRC/FantasmaAzul.o $(OBJDIR_DEBUG)/SRC/FantasmaRojo.o
OBJ_RELEASE = $(OBJDIR_RELEASE)/SRC/Tablero.o $(OBJDIR_RELEASE)/SRC/FantasmaRosa.o $(OBJDIR_RELEASE)/SRC/Pacman.o $(OBJDIR_RELEASE)/SRC/Personaje.o $(OBJDIR_RELEASE)/SRC/Puntuacion.o $(OBJDIR_RELEASE)/SRC/main.o $(OBJDIR_RELEASE)/SRC/Estado.o $(OBJDIR_RELEASE)/SRC/AlmacenDeFuentes.o $(OBJDIR_RELEASE)/SRC/AlmacenDeGraficos.o $(OBJDIR_RELEASE)/SRC/AlmacenDeSonido.o $(OBJDIR_RELEASE)/SRC/Fantasma.o $(OBJDIR_RELEASE)/SRC/FantasmaAmarillo.o $(OBJDIR_RELEASE)/SRC/FantasmaAzul.o $(OBJDIR_RELEASE)/SRC/FantasmaRojo.o
all: release
clean: clean_debug clean_release
before_debug:
test -d bin/Debug || mkdir -p bin/Debug
test -d $(OBJDIR_DEBUG)/SRC || mkdir -p $(OBJDIR_DEBUG)/SRC
after_debug:
debug: before_debug out_debug after_debug
out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
$(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG)
$(OBJDIR_DEBUG)/SRC/Tablero.o: SRC/Tablero.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Tablero.cpp -o $(OBJDIR_DEBUG)/SRC/Tablero.o
$(OBJDIR_DEBUG)/SRC/FantasmaRosa.o: SRC/FantasmaRosa.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/FantasmaRosa.cpp -o $(OBJDIR_DEBUG)/SRC/FantasmaRosa.o
$(OBJDIR_DEBUG)/SRC/Pacman.o: SRC/Pacman.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Pacman.cpp -o $(OBJDIR_DEBUG)/SRC/Pacman.o
$(OBJDIR_DEBUG)/SRC/Personaje.o: SRC/Personaje.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Personaje.cpp -o $(OBJDIR_DEBUG)/SRC/Personaje.o
$(OBJDIR_DEBUG)/SRC/Puntuacion.o: SRC/Puntuacion.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Puntuacion.cpp -o $(OBJDIR_DEBUG)/SRC/Puntuacion.o
$(OBJDIR_DEBUG)/SRC/main.o: SRC/main.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/main.cpp -o $(OBJDIR_DEBUG)/SRC/main.o
$(OBJDIR_DEBUG)/SRC/Estado.o: SRC/Estado.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Estado.cpp -o $(OBJDIR_DEBUG)/SRC/Estado.o
$(OBJDIR_DEBUG)/SRC/AlmacenDeFuentes.o: SRC/AlmacenDeFuentes.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/AlmacenDeFuentes.cpp -o $(OBJDIR_DEBUG)/SRC/AlmacenDeFuentes.o
$(OBJDIR_DEBUG)/SRC/AlmacenDeGraficos.o: SRC/AlmacenDeGraficos.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/AlmacenDeGraficos.cpp -o $(OBJDIR_DEBUG)/SRC/AlmacenDeGraficos.o
$(OBJDIR_DEBUG)/SRC/AlmacenDeSonido.o: SRC/AlmacenDeSonido.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/AlmacenDeSonido.cpp -o $(OBJDIR_DEBUG)/SRC/AlmacenDeSonido.o
$(OBJDIR_DEBUG)/SRC/Fantasma.o: SRC/Fantasma.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/Fantasma.cpp -o $(OBJDIR_DEBUG)/SRC/Fantasma.o
$(OBJDIR_DEBUG)/SRC/FantasmaAmarillo.o: SRC/FantasmaAmarillo.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/FantasmaAmarillo.cpp -o $(OBJDIR_DEBUG)/SRC/FantasmaAmarillo.o
$(OBJDIR_DEBUG)/SRC/FantasmaAzul.o: SRC/FantasmaAzul.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/FantasmaAzul.cpp -o $(OBJDIR_DEBUG)/SRC/FantasmaAzul.o
$(OBJDIR_DEBUG)/SRC/FantasmaRojo.o: SRC/FantasmaRojo.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c SRC/FantasmaRojo.cpp -o $(OBJDIR_DEBUG)/SRC/FantasmaRojo.o
clean_debug:
rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
rm -rf bin/Debug
rm -rf $(OBJDIR_DEBUG)/SRC
before_release:
test -d bin/Release || mkdir -p bin/Release
test -d $(OBJDIR_RELEASE)/SRC || mkdir -p $(OBJDIR_RELEASE)/SRC
after_release:
release: before_release out_release after_release
out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
$(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)
$(OBJDIR_RELEASE)/SRC/Tablero.o: SRC/Tablero.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Tablero.cpp -o $(OBJDIR_RELEASE)/SRC/Tablero.o
$(OBJDIR_RELEASE)/SRC/FantasmaRosa.o: SRC/FantasmaRosa.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/FantasmaRosa.cpp -o $(OBJDIR_RELEASE)/SRC/FantasmaRosa.o
$(OBJDIR_RELEASE)/SRC/Pacman.o: SRC/Pacman.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Pacman.cpp -o $(OBJDIR_RELEASE)/SRC/Pacman.o
$(OBJDIR_RELEASE)/SRC/Personaje.o: SRC/Personaje.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Personaje.cpp -o $(OBJDIR_RELEASE)/SRC/Personaje.o
$(OBJDIR_RELEASE)/SRC/Puntuacion.o: SRC/Puntuacion.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Puntuacion.cpp -o $(OBJDIR_RELEASE)/SRC/Puntuacion.o
$(OBJDIR_RELEASE)/SRC/main.o: SRC/main.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/main.cpp -o $(OBJDIR_RELEASE)/SRC/main.o
$(OBJDIR_RELEASE)/SRC/Estado.o: SRC/Estado.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Estado.cpp -o $(OBJDIR_RELEASE)/SRC/Estado.o
$(OBJDIR_RELEASE)/SRC/AlmacenDeFuentes.o: SRC/AlmacenDeFuentes.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/AlmacenDeFuentes.cpp -o $(OBJDIR_RELEASE)/SRC/AlmacenDeFuentes.o
$(OBJDIR_RELEASE)/SRC/AlmacenDeGraficos.o: SRC/AlmacenDeGraficos.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/AlmacenDeGraficos.cpp -o $(OBJDIR_RELEASE)/SRC/AlmacenDeGraficos.o
$(OBJDIR_RELEASE)/SRC/AlmacenDeSonido.o: SRC/AlmacenDeSonido.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/AlmacenDeSonido.cpp -o $(OBJDIR_RELEASE)/SRC/AlmacenDeSonido.o
$(OBJDIR_RELEASE)/SRC/Fantasma.o: SRC/Fantasma.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/Fantasma.cpp -o $(OBJDIR_RELEASE)/SRC/Fantasma.o
$(OBJDIR_RELEASE)/SRC/FantasmaAmarillo.o: SRC/FantasmaAmarillo.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/FantasmaAmarillo.cpp -o $(OBJDIR_RELEASE)/SRC/FantasmaAmarillo.o
$(OBJDIR_RELEASE)/SRC/FantasmaAzul.o: SRC/FantasmaAzul.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/FantasmaAzul.cpp -o $(OBJDIR_RELEASE)/SRC/FantasmaAzul.o
$(OBJDIR_RELEASE)/SRC/FantasmaRojo.o: SRC/FantasmaRojo.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c SRC/FantasmaRojo.cpp -o $(OBJDIR_RELEASE)/SRC/FantasmaRojo.o
clean_release:
rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
rm -rf bin/Release
rm -rf $(OBJDIR_RELEASE)/SRC
.PHONY: before_debug after_debug clean_debug before_release after_release clean_release

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 11, 1:34 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42665
Default Alt Text
(16 KB)

Event Timeline