void updateTankFlashing() { if (isTankHit() && TankFlashTime >= TANK_FLASH_TICKS && tankFlashNum != FLASH_TICKS){ setExplosionFlag(1); tankFlashNum++; TankFlashTime = 0; TankFlashState = !TankFlashState; if (tankFlashNum <= 1) flashTank(TankFlashState, true); else flashTank(TankFlashState, false); } if (isTankHit() && tankFlashNum == FLASH_TICKS){ tankFlashNum = 0; TankFlashState = true; flashTank(TankFlashState, false); setTankHit(false); setLives(getLives()-1); // Take out one of the lives int startRow = 5; int startCol = 490 + (getLives())*40; drawTank(true, startRow , startCol); // Check if game over if (getLives() == 0) { setEndOfGame(true); } else { setTankPositionGlobal(20); // Reset Tank drawTank(false, 0, 0); } } TankFlashTime++; }
void move_Tanks(TANK_MANAGER* t_m, BULLET_MANAGER* b_m) { TANK *tank = t_m->nextTank; srand((unsigned int)time(NULL) ); while(NULL != tank) { if( 1 == tank->id ){ operateTankWithInput( tank, b_m ); } else { operateTankWithAI(tank, b_m); if( 0 >= tank->live){ TANK* temp = tank->nextTank; addBoom(tank->x, tank->y, tank->color, t_m); // tank boom^ delTank(t_m, tank); tank = temp; //continue; return; } } moveTank(tank); operate_TankHitTank(tank, t_m); checkBounds(tank, WIDTH, HEIGHT); drawTank(tank); cleanTank(tank); tank = tank->nextTank; } }
// Render the screen. void render() { initAliveAliens(); drawAliens(framePointer0); drawTank(false, 0, 0); drawBunkers(framePointer0); drawStats(framePointer0); }
//updates the position of the tank void moveTank(int direction){ if(tankState == ALIVE_TANK){ if(direction == LEFT){ if(!(tankOriginX - TANK_PIXELS_PER_MOVE < 0)){ tankOriginX -= TANK_PIXELS_PER_MOVE; } else{ tankOriginX = 0; } } else{ if(!(tankOriginX + TANK_PIXELS_PER_MOVE + TANK_WIDTH >= SCREEN_X_PIXELS )){ tankOriginX += TANK_PIXELS_PER_MOVE; } else{ tankOriginX = SCREEN_X_PIXELS - 1 - TANK_WIDTH; } } undrawTank(direction); } drawTank(); }
int main() { init(); Tank *tank = (Tank*)calloc(1,sizeof(Tank)); tank->direction = SOUTH; tank->position.X = 80; tank->position.Y = 48; tank->isFirstTurn = false; tank->isShot = false; func_map(MAP); drawTank(tank); while(true) { int key = getch(); switch (key) { case UP: moveTankWithDirection(tank, SOUTH); drawTank(tank); break; case DOWN: moveTankWithDirection(tank, NORTH); drawTank(tank); break; case LEFT: moveTankWithDirection(tank, WEST); drawTank(tank); break; case RIGHT: moveTankWithDirection(tank, EAST); drawTank(tank); break; case SHOT: if(tank->isShot) break; _beginthread(shootThread, 0, (void*) tank); break; case EXIT: exit(0); break; } } return 0; }
void debounceButtons() { int rightVal = MOVE_TANK_RIGHT; int leftVal = MOVE_TANK_LEFT; int fire = TANK_FIRE; if (currentButtonState == 0) { volFlag = false; } // Control volume of sounds in the game if (debounce_timer_count >= BUTTON_DEBOUNCE_WAIT && !volFlag){ if (currentButtonState == VOL_UP){ setVolLevel(getVolLevel() + 1); } else if (currentButtonState == VOL_DOWN){ setVolLevel(getVolLevel() - 1); } volFlag = true; debounce_timer_count = 0; // Reset the debouncing timer } // This waits the given amount of time, so that button presses can be properly debounced. if (debounce_timer_count >= BUTTON_DEBOUNCE_WAIT && !isTankHit()) { if ((currentButtonState == leftVal || currentButtonState == leftVal + fire) && getTankPositionGlobal() >= TANK_BORDER_LEFT){ setTankPositionGlobal(getTankPositionGlobal() - TANK_INCREMENT); drawTank(false, 0, 0); } else if ((currentButtonState == rightVal || currentButtonState == rightVal + fire) && getTankPositionGlobal() <= TANK_BORDER_RIGHT){ setTankPositionGlobal(getTankPositionGlobal() + TANK_INCREMENT); drawTank(false, 0, 0); } if (!getBulletStatus() && (currentButtonState == fire || currentButtonState == rightVal + fire || currentButtonState == leftVal + fire)){ setBulletStatus(true); // Let globals know that there's a tank bullet in the air point_t bullet; // Create a new bullet for the tank bullet.x = getTankPositionGlobal() + (TANK_WIDTH/SCALING_FACTOR); // Assign the bullet's x-val to the middle of the tank bullet.y = TANK_ROW_START; // Assign the bullets' y-val to the top of the tank setTankBulletPosition(bullet); // Set the bullet in globals drawTankBullet(false); // Draw this new bullet setPingFlag(1); } debounce_timer_count = 0; // Reset the debouncing timer } }
void set_UserTank(int* angle, int* velocity, psController ps, tank* user, tank* enemy, terrain tr) { char done_Charging = 0; char hasxBeenPressed = 0; //Draw background of power bar alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x0_chargeBar, y0_chargeBar, (MAX_VELOCITY) + x0_chargeBar, chargeBar_Width + y0_chargeBar, 0x7BEF, 0); alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x0_chargeBar, y0_chargeBar, (MAX_VELOCITY) + x0_chargeBar, chargeBar_Width + y0_chargeBar, 0x7BEF, 1); //loop continues until x is pressed and released, a collision occurs, or velocity maxed out while(done_Charging == 0) { update_Controller_Keys(&ps); set_Angle( angle, ps); done_Charging = set_Velocity( velocity, ps); if(ps.b.x == 1) hasxBeenPressed = 1; //X has been released if(ps.b.x == 0 && hasxBeenPressed == 1) done_Charging = 1; if(ps.b.right == 1) { moveTank(user, 2, 1); //go right drawTank(user, tr); drawTank(enemy, tr); updateVGA(); } else if(ps.b.left) { moveTank(user, 1, 1); // go left drawTank(user, tr); drawTank(enemy, tr); updateVGA(); } display_Input(*angle, *velocity); delay(); } }
void draw_Tanks(const TANK_MANAGER *tank_manager) { TANK *tank = tank_manager->nextTank; while(NULL != tank) { //operateTankWithAI(tank); //moveTank(tank); drawTank(tank); //cleanTank(tank); tank = tank->nextTank; } }
// Draw the stats (score and lives) on the screen. void drawStats(){ int startRow = STATS_START_ROW; int startCol = STATS_START_COL; int letterColor = WHITE; // Draw the Score drawLetter(false, letterColor, startRow, startCol, S_6x5); // Draw S startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, C_6x5); // Draw C startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, O_6x5); // Draw O startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, R_6x5); // Draw R startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, E_6x5); // Draw E startCol = startCol + KERNING + KERNING; updateScore(); startCol += KERNING_CENTRE; // Draw the Lives drawLetter(false, letterColor, startRow, startCol, L_6x5); // Draw L startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, I_6x5); // Draw I startCol += KERNING_SMALL; drawLetter(false, letterColor, startRow, startCol, V_6x5); // Draw V startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, E_6x5); // Draw E startCol += KERNING; drawLetter(false, letterColor, startRow, startCol, S_6x5); // Draw S startCol = startCol + KERNING + KERNING; startRow -= KERNING_SMALL; drawTank(true, startRow, startCol); startCol += TANK_KERNING; drawTank(true, startRow, startCol); startCol += TANK_KERNING; drawTank(true, startRow, startCol); setInit(false); }
/*! \brief Repaint the widget */ void PTank::paintEvent(QPaintEvent *event) { static QPixmap pixmap; QRect rect = event->rect(); QSize newSize = rect.size().expandedTo(pixmap.size()); pixmap.resize(newSize); pixmap.fill(this,rect.topLeft()); QPainter painter(&pixmap,this); painter.translate(-rect.x(),-rect.y()); drawTank(&painter); bitBlt(this,rect.x(),rect.y(),&pixmap,0,0,rect.width(),rect.height()); }
void MainWindow::render() { double incomeFlow = fluidIncome * (ui->fluidIncomeValveSlider->value()/(double)100) * (16/((double)1000)); fluidVolume += incomeFlow; fluidHeight = fluidVolume/(PI * std::pow(tankDiameter/2,2)); ui->incomeFlowLabel->setText(QString::number((incomeFlow*1000)*(1000.0/16.0))+" l/s"); double outcomeFlow = outcomeValveArea*std::sqrt(2*G*fluidHeight) * (ui->fluidOutcomeValveSlider->value()/(double)100) * (16/((double)1000)); ui->outcomeFlowLabel->setText(QString::number((outcomeFlow*1000)*(1000.0/16.0))+" l/s"); fluidVolume -= outcomeFlow; fluidHeight = fluidVolume/(PI * std::pow(tankDiameter/2,2)); ui->tankVoulumeInLitreLabel->setText(QString::number(fluidVolume*1000.0)+" l"); ui->tankHeightLabel->setText(QString::number(fluidHeight)+" m"); drawTank(); }
void moveTankWithDirection(Tank *tank, TankDirection direction) { if (tank->direction == direction) { tank->isFirstTurn = false; } else { tank->isFirstTurn = true; } ereasePreviousPosition(tank); if (tank->isFirstTurn) { checkCollision(tank, direction); tank->direction = direction; } else { switch (direction) { case SOUTH: if (isFreeWay(tank, direction)) { tank->position.Y--; } break; case NORTH: if (isFreeWay(tank, direction)) { tank->position.Y++; } break; case WEST: if (isFreeWay(tank, direction)) { tank->position.X--; } break; case EAST: if (isFreeWay(tank, direction)) { tank->position.X++; } break; } tank->direction = direction; } drawTank(tank); }
int main() { arr = (unsigned int**)malloc(4377 * sizeof(unsigned int)); psController ps; int velocity = 0; int angle = 0; long ii = 0; int** collisionMatrix; int ee; int numfiles; char * filenames[MAXFILES]; //init_VGA_Pixel(); initVGA(); //pixel init_VGA_Char(); av_config_setup(); numfiles = init_sd(filenames); init_wav(arr); printf("timing audio\n"); //time_of_sound = time_audio(arr); printf("looping audio\n"); audio_isr_k = 0; alt_irq_register(AUDIO_IRQ, NULL, &audio_isr); alt_up_audio_enable_write_interrupt(audio); //====INITIALIZE AND DRAW TERRAIN USING BMP ===========================// short int fd; terrain background; fd = alt_up_sd_card_fopen("bg.bmp", false); initTerrain(fd, &background); drawBackground(background); alt_up_sd_card_fclose(fd); terrain terrain; fd = alt_up_sd_card_fopen("tr.bmp", false); initTerrain(fd, &terrain); drawTerrain(terrain); alt_up_sd_card_fclose(fd); //====INITIALIZE AND DRAW USER TANK USING BMP ===========================// fd = alt_up_sd_card_fopen("tank.bmp", false); tank user; initUserTank(&user, fd); drawTank(&user, background); alt_up_sd_card_fclose(fd); //====INITIALIZE AND DRAW ENEMY TANK USING BMP ===========================// tank enemy; fd = alt_up_sd_card_fopen("tk.bmp", false); initEnemyTank1(&enemy, fd); drawTank(&enemy,background); alt_up_sd_card_fclose(fd); //====SWAP BUFFERS =======================================================// updateVGA(); drawBackground(background); drawTerrain(terrain); drawTank(&enemy, background); for(ee=0;ee < 20;ee++) { moveTank(&user, RIGHT, 1); drawTank(&user,background); updateVGA(); drawTank(&user,background); //delay(); } //for(ii = 0; ii < 300000; ii++); collisionMatrix = init_CollisionMatrix(XMAXSCREEN_RESOLUTION + 1, XMAXSCREEN_RESOLUTION + 1); //alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 120, 340, 240, 0x7E0 , 0); //draw terrain set_CollisionAtRectArea(collisionMatrix, 0 , 0, 340, 240, EMPTY); set_CollisionAtRectArea(collisionMatrix, 0 , 161, 340, 240, TERRAIN_COLOR);//set the rectangular area drawn by terrain to filled with terrain while(1){ //angle = 0; velocity = 0; set_UserTank(&angle, &velocity, ps, &user, &enemy, background); //reads controller to set angle, power, and shoot shoot_Missile(angle, velocity,( user.x + user.t_VGA.width) - 1 , (240 - user.y + user.t_VGA.height) - 7, collisionMatrix, background); } clean_audio(arr); return 0; }
void RadarRenderer::render(SceneRenderer& renderer, bool blank) { const int ox = renderer.getWindow().getOriginX(); const int oy = renderer.getWindow().getOriginY(); float opacity = renderer.getPanelOpacity(); if ((opacity < 1.0f) && (opacity > 0.0f)) { glScissor(ox + x - 2, oy + y - 2, w + 4, h + 4); glColor4f(0.0f, 0.0f, 0.0f, opacity); glRectf((float) x, (float) y, (float)(x + w), (float)(y + h)); } glScissor(ox + x, oy + y, w, h); LocalPlayer *myTank = LocalPlayer::getMyTank(); if (opacity == 1.0f) { // glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // glClear(GL_COLOR_BUFFER_BIT); } if (blank) return; // prepare transforms float worldSize = BZDB.eval(StateDatabase::BZDB_WORLDSIZE); float range = BZDB.eval("displayRadarRange") * worldSize; // when burrowed, limit radar range if (myTank && (myTank->getFlag() == Flags::Burrow) && (myTank->getPosition()[2] < 0.0f)) { #ifdef _MSC_VER range = min(range, worldSize / 4.0f); #else range = std::min(range, worldSize / 4.0f); #endif } glMatrixMode(GL_PROJECTION); glLoadIdentity(); const int xSize = renderer.getWindow().getWidth(); const int ySize = renderer.getWindow().getHeight(); const double xCenter = double(x) + 0.5 * double(w); const double yCenter = double(y) + 0.5 * double(h); const double xUnit = 2.0 * range / double(w); const double yUnit = 2.0 * range / double(h); glOrtho(-xCenter * xUnit, (xSize - xCenter) * xUnit, -yCenter * yUnit, (ySize - yCenter) * yUnit, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); OpenGLGState::resetState(); TextureManager &tm = TextureManager::instance(); int noiseTexture = tm.getTextureID( "noise" ); // if jammed then draw white noise. occasionally draw a good frame. if (jammed && bzfrand() > decay) { glColor3f(1.0,1.0,1.0); if (noiseTexture >= 0 && renderer.useQuality() > 0) { const int sequences = 10; static float np[] = { 0, 0, 1, 1, 1, 1, 0, 0, 0.5f, 0.5f, 1.5f, 1.5f, 1.5f, 1.5f, 0.5f, 0.5f, 0.25f, 0.25f, 1.25f, 1.25f, 1.25f, 1.25f, 0.25f, 0.25f, 0, 0.5f, 1, 1.5f, 1, 1.5f, 0, 0.5f, 0.5f, 0, 1.5f, 1, 1.4f, 1, 0.5f, 0, 0.75f, 0.75f, 1.75f, 1.75f, 1.75f, 1.75f, 0.75f, 0.75f, }; int noisePattern = 4 * int(floor(sequences * bzfrand())); glEnable(GL_TEXTURE_2D); tm.bind(noiseTexture); glBegin(GL_QUADS); glTexCoord2f(np[noisePattern+0],np[noisePattern+1]); glVertex2f(-range,-range); glTexCoord2f(np[noisePattern+2],np[noisePattern+1]); glVertex2f( range,-range); glTexCoord2f(np[noisePattern+2],np[noisePattern+3]); glVertex2f( range, range); glTexCoord2f(np[noisePattern+0],np[noisePattern+3]); glVertex2f(-range, range); glEnd(); glDisable(GL_TEXTURE_2D); } else if (noiseTexture >= 0 && BZDBCache::texture && renderer.useQuality() == 0) { glEnable(GL_TEXTURE_2D); tm.bind(noiseTexture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(-range,-range); glTexCoord2f(1,0); glVertex2f( range,-range); glTexCoord2f(1,1); glVertex2f( range, range); glTexCoord2f(0,1); glVertex2f(-range, range); glEnd(); glDisable(GL_TEXTURE_2D); } if (decay > 0.015f) decay *= 0.5f; } else if (myTank) // only draw if there's a local player { // if decay is sufficiently small then boost it so it's more // likely a jammed radar will get a few good frames closely // spaced in time. value of 1 guarantees at least two good // frames in a row. if (decay <= 0.015f) decay = 1.0f; else decay *= 0.5f; // get size of pixel in model space (assumes radar is square) ps = 2.0f * range / GLfloat(w); // relative to my tank const LocalPlayer* myTank = LocalPlayer::getMyTank(); const float* pos = myTank->getPosition(); float angle = myTank->getAngle(); // draw the view angle blewow stuff // view frustum edges glColor3f(1.0f, 0.625f, 0.125f); const float fovx = renderer.getViewFrustum().getFOVx(); const float viewWidth = range * tanf(0.5f * fovx); glBegin(GL_LINE_STRIP); glVertex2f(-viewWidth, range); glVertex2f(0.0f, 0.0f); glVertex2f(viewWidth, range); glEnd(); glPushMatrix(); glRotatef(90.0f - angle * 180.0f / M_PI, 0.0f, 0.0f, 1.0f); glPushMatrix(); glTranslatef(-pos[0], -pos[1], 0.0f); // Redraw buildings makeList( renderer); // draw my shots int maxShots = world.getMaxShots(); int i; float muzzleHeight = BZDB.eval(StateDatabase::BZDB_MUZZLEHEIGHT); for (i = 0; i < maxShots; i++) { const ShotPath* shot = myTank->getShot(i); if (shot) { const float cs = colorScale(shot->getPosition()[2], muzzleHeight, BZDBCache::enhancedRadar); glColor3f(1.0f * cs, 1.0f * cs, 1.0f * cs); shot->radarRender(); } } //draw world weapon shots WorldPlayer *worldWeapons = World::getWorld()->getWorldWeapons(); maxShots = worldWeapons->getMaxShots(); for (i = 0; i < maxShots; i++) { const ShotPath* shot = worldWeapons->getShot(i); if (shot) { const float cs = colorScale(shot->getPosition()[2], muzzleHeight, BZDBCache::enhancedRadar); glColor3f(1.0f * cs, 1.0f * cs, 1.0f * cs); shot->radarRender(); } } // draw other tanks (and any flags on them) // note about flag drawing. each line segment is drawn twice // (once in each direction); this degrades the antialiasing // but on systems that don't do correct filtering of endpoints // not doing it makes (half) the endpoints jump wildly. const int curMaxPlayers = world.getCurMaxPlayers(); for (i = 0; i < curMaxPlayers; i++) { RemotePlayer* player = world.getPlayer(i); if (!player || !player->isAlive() || ((player->getFlag() == Flags::Stealth) && (myTank->getFlag() != Flags::Seer))) continue; GLfloat x = player->getPosition()[0]; GLfloat y = player->getPosition()[1]; GLfloat z = player->getPosition()[2]; if (player->getFlag() != Flags::Null) { glColor3fv(player->getFlag()->getColor()); drawFlagOnTank(x, y, z); } if (player->isPaused() || player->isNotResponding()) { const float dimfactor = 0.4f; const float *color = Team::getRadarColor(myTank->getFlag() == Flags::Colorblindness ? RogueTeam : player->getTeam()); float dimmedcolor[3]; dimmedcolor[0] = color[0] * dimfactor; dimmedcolor[1] = color[1] * dimfactor; dimmedcolor[2] = color[2] * dimfactor; glColor3fv(dimmedcolor); } else { glColor3fv(Team::getRadarColor(myTank->getFlag() == Flags::Colorblindness ? RogueTeam : player->getTeam())); } // If this tank is hunted flash it on the radar if (player->isHunted() && myTank->getFlag() != Flags::Colorblindness) { if (flashTank.isOn()) { if (!toggleTank) { float flashcolor[3]; flashcolor[0] = 0.0f; flashcolor[1] = 0.8f; flashcolor[2] = 0.9f; glColor3fv(flashcolor); } } else { toggleTank = !toggleTank; flashTank.setClock(0.2f); } } drawTank(x, y, z); } bool coloredShot = BZDB.isTrue("coloredradarshots"); // draw other tanks' shells maxShots = World::getWorld()->getMaxShots(); for (i = 0; i < curMaxPlayers; i++) { RemotePlayer* player = world.getPlayer(i); if (!player) continue; for (int j = 0; j < maxShots; j++) { const ShotPath* shot = player->getShot(j); if (shot && shot->getFlag() != Flags::InvisibleBullet) { const float *shotcolor; if (coloredShot) { if (myTank->getFlag() == Flags::Colorblindness) shotcolor = Team::getRadarColor(RogueTeam); else shotcolor = Team::getRadarColor(player->getTeam()); const float cs = colorScale(shot->getPosition()[2], muzzleHeight, BZDBCache::enhancedRadar); glColor3f(shotcolor[0] * cs, shotcolor[1] * cs, shotcolor[2] * cs); } else { glColor3f(1.0f, 1.0f, 1.0f); } shot->radarRender(); } } } // draw flags not on tanks. const int maxFlags = world.getMaxFlags(); const bool drawNormalFlags = BZDB.isTrue("displayRadarFlags"); for (i = 0; i < maxFlags; i++) { const Flag& flag = world.getFlag(i); // don't draw flags that don't exist or are on a tank if (flag.status == FlagNoExist || flag.status == FlagOnTank) continue; // don't draw normal flags if we aren't supposed to if (flag.type->flagTeam == NoTeam && !drawNormalFlags) continue; // Flags change color by height const float cs = colorScale(flag.position[2], muzzleHeight, BZDBCache::enhancedRadar); const float *flagcolor = flag.type->getColor(); glColor3f(flagcolor[0] * cs, flagcolor[1] * cs, flagcolor[2] * cs); drawFlag(flag.position[0], flag.position[1], flag.position[2]); } // draw antidote flag const float* antidotePos = LocalPlayer::getMyTank()->getAntidoteLocation(); if (antidotePos) { glColor3f(1.0f, 1.0f, 0.0f); drawFlag(antidotePos[0], antidotePos[1], antidotePos[2]); } // draw these markers above all others always centered glPopMatrix(); // north marker GLfloat ns = 0.05f * range, ny = 0.9f * range; glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINE_STRIP); glVertex2f(-ns, ny - ns); glVertex2f(-ns, ny + ns); glVertex2f(ns, ny - ns); glVertex2f(ns, ny + ns); glEnd(); // always up glPopMatrix(); // get size of pixel in model space (assumes radar is square) GLfloat ps = 2.0f * range / GLfloat(w); // forward tick glBegin(GL_LINES); glVertex2f(0.0f, range - ps); glVertex2f(0.0f, range - 4.0f * ps); glEnd(); // my tank glColor3f(1.0f, 1.0f, 1.0f); drawTank(0.0f, 0.0f, myTank->getPosition()[2]); // my flag if (myTank->getFlag() != Flags::Null) { glColor3fv(myTank->getFlag()->getColor()); drawFlagOnTank(0.0f, 0.0f, myTank->getPosition()[2]); } } // restore GL state glPopMatrix(); }
int main() { int numEnemy = 5; Enemy E[8]; pthread_t tid; //inisialisasi init(); PaintBackground(); initTargetPoint(&TP); setTarget(&TP,140,600); //pindahkan target int i; for(i = 0 ; i < numEnemy; i++) { makeEnemy(1300, i*60+30, &(E[i])); } pthread_create(&tid, NULL, inputHandler, NULL); drawTank(); while(stop == 0) { //cek collision int i; for(i = 0; i < numEnemy; i++) { int collide = detectCollision(B, E[i]); if(collide) { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 0, 0, 0); PaintBomb(getPosX(B), getPosY(B), 0,0,0); setActive(&B, 0); makeEnemy(1300, i*60+30, &(E[i])); } } //gerakkan objek & gambar //enemy for(i = 0; i < numEnemy; i++) { moveEnemy(&E[i]); if(getEnemyPosX(E[i]) <= 10) { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 0, 0, 0); makeEnemy(1300, i*60+30, &(E[i])); } else { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 230, 80, 30); } } //gerakkan & gambar bom jika bom aktif if(isActive(B)) { nextStep(&B); if(getPosX(B) < 0 || getPosX(B) > 1340 || getPosY(B) < 10 || getPosY(B) > 740) { setActive(&B,0); PaintBomb(getPosX(B), getPosY(B), 0,0,0); } else { PaintBomb(getPosX(B), getPosY(B), 211,211,211); } } //render gambar usleep(1000); for(i = 0; i < numEnemy; i++) { clearEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i])); } if(isActive(B)) { PaintBomb(getPosX(B), getPosY(B), 0,0,0); } usleep(1000); } pthread_join(tid, NULL); //mapping memory munmap(fbp, screensize); close(fbfd); return 0; }