-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cambio a entidad_t #28
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
80656b3
Ref: Se pasa a usar un solo entidad_t
brunograssano 3fd2104
Ref: efecto_t ahora es tambien entidad_t
brunograssano 09d7aaa
Ref: el nombre de los jugadores ya no se manda en ronda_t
brunograssano a730ed3
Ref: emprolijo codigo
brunograssano 81fc00a
ref: Se eliminan conexiones perdidas durante el transcurso del server
brunograssano 40ed331
ref: Las flores son mas raras ahora
brunograssano 8ef1e84
Docs: Completo algo el readme
brunograssano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
|
||
pthread_mutex_t mutexJuegoCliente = PTHREAD_MUTEX_INITIALIZER; | ||
|
||
bool operator == (const bloque_t &bloque1, const bloque_t &bloque2){ | ||
return bloque1.posX == bloque2.posX && bloque1.posY == bloque2.posY && bloque1.numeroRecorteY == bloque2.numeroRecorteY; | ||
bool operator == (const entidad_t &bloque1, const entidad_t &bloque2){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nunca había visto esto... Habría que extenderlo a entidad_t y no quedarse sólo con ladrillo, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se puede hacer tambien |
||
return bloque1.x == bloque2.x && bloque1.y == bloque2.y && bloque1.recorteY == bloque2.recorteY; | ||
} | ||
|
||
|
||
|
@@ -59,6 +59,13 @@ SDL_Rect JuegoCliente::obtenerCamara()const{ | |
return rectanguloCamara; | ||
} | ||
|
||
void JuegoCliente::cargarLista(list<entidad_t>* listaACargar, entidad_t *vector, unsigned short tope) { | ||
listaACargar->clear(); | ||
for(int i=0;i<tope;i++){ | ||
listaACargar->push_front(vector[i]); | ||
} | ||
} | ||
|
||
void JuegoCliente::actualizar(){ | ||
if(rondas.empty()){ | ||
return; | ||
|
@@ -81,33 +88,20 @@ void JuegoCliente::actualizar(){ | |
ganaron = ronda.ganaron; | ||
perdieron = ronda.perdieron; | ||
|
||
bloques.clear(); | ||
enemigos.clear(); | ||
jugadores.clear(); | ||
monedas.clear(); | ||
efectos.clear(); | ||
cargarLista(&bloques,ronda.bloques,ronda.topeBloques); | ||
cargarLista(&enemigos,ronda.enemigos,ronda.topeEnemigos); | ||
cargarLista(&monedas,ronda.monedas,ronda.topeMonedas); | ||
cargarLista(&efectos,ronda.efectos,ronda.topeEfectos); | ||
|
||
for(int i=0;i<ronda.topeBloques;i++){ | ||
bloques.push_front(ronda.bloques[i]); | ||
} | ||
for(int i=0;i<ronda.topeEnemigos;i++){ | ||
enemigos.push_front(ronda.enemigos[i]); | ||
} | ||
for(int i=0;i<ronda.topeMonedas;i++){ | ||
monedas.push_front(ronda.monedas[i]); | ||
} | ||
for(int i=0;i<cantidadJugadores;i++){ | ||
jugadores[i]=ronda.jugadores[i]; | ||
jugadores[i].mario=ronda.jugadores[i]; | ||
} | ||
for(int i=0;i<ronda.topeEfectos;i++){ | ||
efectos.push_front(ronda.efectos[i]); | ||
} | ||
|
||
list<bloque_t> ladrillosASacar; | ||
list<bloque_t> ladrillosNuevos; | ||
list<entidad_t> ladrillosASacar; | ||
list<entidad_t> ladrillosNuevos; | ||
bool agregado = false; | ||
for(auto ladrillo: ladrillos){ | ||
if(enRango(ladrillo.posX, LARGO_BLOQUE)){ | ||
if(enRango(ladrillo.x, LARGO_BLOQUE)){ | ||
for(auto bloque : bloques) { | ||
if(ladrillo == bloque){ | ||
ladrillosASacar.push_front(ladrillo); | ||
|
@@ -138,19 +132,19 @@ map<int,jugador_t> JuegoCliente::obtenerJugadores(){ | |
return jugadores; | ||
} | ||
|
||
list<enemigo_t> JuegoCliente::obtenerEnemigos(){ | ||
list<entidad_t> JuegoCliente::obtenerEnemigos(){ | ||
return enemigos; | ||
} | ||
|
||
list<bloque_t> JuegoCliente::obtenerBloques(){ | ||
list<entidad_t> JuegoCliente::obtenerBloques(){ | ||
return bloques; | ||
} | ||
|
||
bool JuegoCliente::enRango(int posX, int w) const { | ||
return (rectanguloCamara.x - RANGO_VISTA) <= posX + w && posX <= (rectanguloCamara.x + anchoVista + RANGO_VISTA); | ||
} | ||
|
||
list<moneda_t> JuegoCliente::obtenerMonedas(){ | ||
list<entidad_t> JuegoCliente::obtenerMonedas(){ | ||
return monedas; | ||
} | ||
|
||
|
@@ -166,29 +160,29 @@ int JuegoCliente::obtenerMundoActual() const{ | |
return numeroMundo; | ||
} | ||
|
||
list<pozo_t> JuegoCliente::obtenerPozos() { | ||
list<pozo_t> pozosAMostrar; | ||
list<entidad_t> JuegoCliente::obtenerPozos() { | ||
list<entidad_t> pozosAMostrar; | ||
for(auto pozo:pozos){ | ||
if(enRango(pozo.posX, ANCHO_POZO)){ | ||
if(enRango(pozo.x, ANCHO_POZO)){ | ||
pozosAMostrar.push_front(pozo); | ||
} | ||
} | ||
return pozosAMostrar; | ||
} | ||
|
||
|
||
list<tuberia_t> JuegoCliente::obtenerTuberias() { | ||
list<tuberia_t> tuberiasAMostrar; | ||
list<entidad_t> JuegoCliente::obtenerTuberias() { | ||
list<entidad_t> tuberiasAMostrar; | ||
for(auto tuberia:tuberias){ | ||
int ancho = tuberia.tipo==TUBERIA_CHICA?ANCHO_TUBERIA_CHICA:ANCHO_TUBERIA_GRANDE; | ||
if(enRango(tuberia.posX, ancho)){ | ||
if(enRango(tuberia.x, ancho)){ | ||
tuberiasAMostrar.push_front(tuberia); | ||
} | ||
} | ||
return tuberiasAMostrar; | ||
} | ||
|
||
list<efecto_t> JuegoCliente::obtenerEfectos() { | ||
list<entidad_t> JuegoCliente::obtenerEfectos() { | ||
return efectos; | ||
} | ||
|
||
|
@@ -198,18 +192,10 @@ void JuegoCliente::agregarNivel(nivel_t nivel) { | |
this->hayQueMostrarPuntosDeNivel = true; | ||
} | ||
numeroMundo = nivel.mundo; | ||
ladrillos.clear(); | ||
tuberias.clear(); | ||
pozos.clear(); | ||
for(int i=0;i<nivel.topeBloques;i++){ | ||
ladrillos.push_front(nivel.bloques[i]); | ||
} | ||
for(int i=0;i<nivel.topeTuberias;i++){ | ||
tuberias.push_front(nivel.tuberias[i]); | ||
} | ||
for(int i=0;i<nivel.topePozos;i++){ | ||
pozos.push_front(nivel.pozos[i]); | ||
} | ||
|
||
cargarLista(&ladrillos,nivel.bloques,nivel.topeBloques); | ||
cargarLista(&tuberias,nivel.tuberias,nivel.topeTuberias); | ||
cargarLista(&pozos,nivel.pozos,nivel.topePozos); | ||
|
||
if(!hayQueCargarPodioNivel){ | ||
hayQueCargarPodioNivel = true; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acá se pide a gritos el refactor de los dibujadores
Aquel que no realiza dicho if allá abajo.
Son cosas que vendrán pronto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sip