AgarrablePiedra::AgarrablePiedra(int posX, int posY, Render *render, int anchoBase, int largoBase, int pixelRefX, int pixelRefY, std::string path) { if ((anchoBase == 0) | (largoBase == 0) | (pixelRefX == 0) | (pixelRefY == 0) | (path == "")) { //ACA HAY ALGUN DATO QUE NO VINO, TOMO TODO LO DEFAULT. Logger::Instancia().logMsj("Los datos de la piedra que se cargaron al yaml son erróneos. Se toman valores por default","Aviso"); this->renderizador->Iniciar(posX, posY); pixelX = posX; pixelY = posY; this->renderizador->SetOrigen(15, 5); tamanioX = 1; tamanioY = 1; } else { //ACA ESTARIAN TODOS LOS DATOS DEL YAML Logger::Instancia().logMsj("Se cargan correctamente los datos de la piedra desde el yaml","Aviso"); this->renderizador = new RenderizadorObstaculo(render, path.c_str(), Colision(0, 0, 200, 200)); this->renderizador->Iniciar(posX, posY); this->renderizador->SetOrigen(pixelRefX, pixelRefY); tamanioX = largoBase; tamanioY = anchoBase; } //this->renderizador->SetEsIsometrica(); tipo = "piedra"; mensaje = "Esto es una piedra"; esAgarrable = true; vidaActual = VIDA_RECURSO; }
void BolaEntity::Update( float delta ) { mFSM.Update(); setBolaPrevPos (getBolaPos()); //mBolaDir es un vector 2d de valores 1 y -1 //necesito otra variable que cambie el angulo del vector mBolaPos. mBolaPos.x+= mBolaDir.x* mBolaSpeed * delta; mBolaPos.y+= mBolaDir.y* mBolaSpeed * delta; Colision(); if (mBolaPos.y<-400.0f) { MainState::Lifes_Count--; EntityManager::Instance()->Remove(this); //std::vector<BaseGameEntity*>& Barras = EntityManager::Instance()->GetType( Barra_TYPE ); //mFSM es un StateMachine de tipo Bola, yo el que quiero es el de Barra, pero está privado. Tendría que hacer //un get o usar una variable global para los estados de la barra y luego según el valor de esa variable, en //barraEntity se elegiría un estado u otro. Y así con todas las clases que tienen estados. //Barras.SetCurrentState(ControledByHuman::Instance()); return; } D3DXMATRIX T, S; D3DXMatrixScaling(&S, 60.0f, 60.0f, 0.0f); D3DXMatrixTranslation(&T, mBolaPos.x, mBolaPos.y, 0.1f); BolaSprite.matWorld = (S*T); }
ObstaculoAgua::ObstaculoAgua(int posX, int posY, Render *render, int anchoBase, int largoBase, int pixelRefX, int pixelRefY, std::string path) { if ((anchoBase == 0) | (largoBase == 0) | (pixelRefX == 0) | (pixelRefY == 0) | (path == "")) { this->renderizador->Iniciar(posX, posY); this->renderizador->SetEsIsometrica(); pixelX = posX; pixelY = posY; this->renderizador->SetOrigen(35, 35); tamanioX = 1; tamanioY = 1; esAgarrable = false; } else { this->renderizador = new RenderizadorObstaculo(render, path.c_str(), Colision(0, 0, 200, 200)); this->renderizador->Iniciar(posX, posY); this->renderizador->SetEsIsometrica(); this->renderizador->SetOrigen(pixelRefX, pixelRefY); tamanioX = largoBase; tamanioY = anchoBase; esAgarrable = false; mensaje = "Esto es una laguna"; tipo = "agua"; } }
Bandera::Bandera(int posX, int posY, Render* render, int anchoBase, int largoBase, int pixelRefX, int pixelRefY, std::string path) { Logger::Instancia().logMsj("Se cargan correctamente los datos de la piedra desde el yaml", "Aviso"); this->renderizador = new RenderizadorObstaculo(render, path.c_str(), Colision(0, 0, 200, 200)); this->renderizador->Iniciar(posX, posY); this->renderizador->SetOrigen(pixelRefX, pixelRefY); tamanioX = largoBase; tamanioY = anchoBase; tipo = "bandera"; mensaje = "Esto es una bandera"; esAgarrable = true; vidaActual = 1; }
ObstaculoCuartel::ObstaculoCuartel(int x, int y, Render *render, int anchoBase, int largoBase, int pixelRefX, int pixelRefY, std::string path, int idUnico) { if ((anchoBase == 0) | (largoBase == 0) | (pixelRefX == 0) | (pixelRefY == 0) | (path == "")) { //ACA HAY ALGUN DATO QUE NO VINO, TOMO TODO LO DEFAULT. Logger::Instancia().logMsj( "Los datos del cuartel que se cargaron al yaml son erróneos. Se toman valores por default", "Aviso"); //this->renderizador = new RenderizadorObstaculo(render, "img/house.png"); this->renderizador->Iniciar(x, y); pixelX = x; pixelY = y; this->renderizador->SetOrigen(90, 138); tamanioX = 2; tamanioY = 2; vidaActual = vidaTotal = 1800; tiempoDeEspera = 0; esAgarrable = false; } else { //ACA ESTARIAN TODOS LOS DATOS DEL YAML Logger::Instancia().logMsj("Se cargan correctamente los datos del cuartel desde el yaml", "Aviso"); this->renderizador = new RenderizadorObstaculo(render, path.c_str(), Colision(0, 0, 200, 200)); this->renderizador->Iniciar(x, y); pixelX = x; pixelY = y; this->renderizador->SetOrigen(pixelRefX, pixelRefY); tamanioX = largoBase; tamanioY = anchoBase; esAgarrable = false; vidaActual = vidaTotal = VIDA_CUARTEL; tiempoDeEspera = 0; mensaje = "Esto es un cuartel para los soldaditos"; tipo = "cuartel"; tipoDeEntidad = cuartel; this->idUnico = idUnico; cout << "llega" << endl; } }
int main(void) { // Nastavíme pozici ètvercù //int pos_x = 10; //int pos_y = 10; //int pos_x2 = 100; //int pos_y2 = 100; //------------------------ // Nastavíme barvu ètvercù r,g,b //int r = 0; //int g = 255; //int b = 0; //------------------------- allegro_init(); // inicializace allegra install_keyboard(); // inicializace klavesnice obr = load_bitmap("obr.bmp",NULL); //obr2 = load_bitmap("obr2.bmp",NULL); set_color_depth(8); // Nastavíme hloubku , Grafický mod ,a výšku a šíøku obrazovky if (set_gfx_mode(GFX_AUTODETECT|GFX_AUTODETECT_WINDOWED, SCR_W ,SCR_H, 0, 0)) { set_color_depth(24); if (set_gfx_mode(GFX_AUTODETECT|GFX_AUTODETECT_WINDOWED, SCR_W , SCR_H, 0, 0)) { set_color_depth(16); if (set_gfx_mode(GFX_AUTODETECT|GFX_AUTODETECT_WINDOWED, SCR_W , SCR_H , 0, 0)) { set_color_depth(15); if (set_gfx_mode(GFX_AUTODETECT|GFX_AUTODETECT_WINDOWED, SCR_W , SCR_H, 0, 0)) { allegro_message("Video Error: %s.\n", allegro_error); return 1; } } } } InitDoubleBuffering(); Init(); while (!key[KEY_ESC]) { /* if(key[KEY_UP]) { pos_y -= 1;} if(key[KEY_DOWN]) { pos_y += 1;} if(key[KEY_RIGHT]) { pos_x += 1;} if(key[KEY_LEFT]) { pos_x -= 1;} if(key[KEY_W]) { pos_y2 -= 1;} if(key[KEY_S]) { pos_y2 += 1;} if(key[KEY_D]) { pos_x2 += 1;} if(key[KEY_A]) { pos_x2 -= 1;} if((pos_x > pos_x2 - 20) && ( pos_x < pos_x2 + 20) && (pos_y > pos_y2 - 20 ) && (pos_y < pos_y2 + 20)){} else{} */ Posun(); DrawEnemy(); // Draw(); DrawBuffer(); Colision(); clear_bitmap(buffer); rest(10); //jinak tez wait() } destroy_bitmap(obr); return 0; }