void Oscillator::reset() { parameters.amp = 0.5f; parameters.wave = OSC_SAWTOOTH; counter = 0.0f; sqp = 1.0f; sqc = 0; parameters.pulsewidth = 0.0f; parameters.detune = 0; setAmp(1.0f); setWave(OSC_SAWTOOTH); setPulseWidth(0.0f); setNote(12); setDetune(0); }
int hit(App *app, Body *source, Body *target){ if(target == NULL || source == NULL) { return 0; } if(target == &app->game.indy.body && source == &app->game.indy.power_body || target == &app->game.allan.body && source == &app->game.allan.power_body ){ return; } float dist = sqrt( pow(target->pos.x - source->pos.x,2)+ pow(target->pos.y - source->pos.y,2) ); float damage = source->damage; int alive = target->life > 0; target->life -= damage; if(target->life > 0 && source != &app->game.allan.body && source != &app->game.indy.body ){ playBite(); } if(target->life <= 0){ target->life = 0; if(alive){ int enemy_killed = !!target->score; if(!app->debug || enemy_killed) { // player immortal on debug int x0 = target->pos.x/tileSize; int y0 = target->pos.y/tileSize; int search[21][2] = { {+0,+0}, {+1,+0}, {+0,+1}, {-1,+0}, {+0,-1}, {+1,-1}, {+1,+1}, {-1,+1}, {-1,-1}, {+0,-2}, {+2,+0}, {+0,+2}, {-2,+0}, {-1,-2}, {+1,-2}, {+2,-1}, {+2,+1}, {+1,+2}, {-1,+2}, {-2,+1}, {-2,-1} }; int i; Wave *wave = &app->game.wave[app->game.wave_index]; if(enemy_killed && target->action != ACTION_DEATH) { app->game.board.on_screen_enemies --; app->game.board.kill_count ++; app->game.total_kill_count ++; source->kills++; float score = target->score; source->life += score; for(i=0;i<21;i++) { int x = x0+search[i][0]; int y = y0+search[i][1]; if( x < 0 || y < 0 || x >= mapWidth || y >= mapHeight || walkability[x][y]==1) continue; // dont outside or on the enemy spawn borders int s = score * ceil( (21-i) / 4.); app->game.board.death1[x][y] += s; app->game.board.death2[x][y] += s; } } if(!enemy_killed && target->action != ACTION_DEATH) {// player_killed int x1 = source->pos.x/tileSize; int y1 = source->pos.y/tileSize; for(i=0;i<21;i++) { int x = x1+search[i][0]; int y = y1+search[i][1]; if( x < 0 || y < 0 || x >= mapWidth || y >= mapHeight || walkability[x][y]==1) continue; // dont outside or on the enemy spawn borders app->game.board.death1[x][y] /= 2; } for(i=0;i<21;i++) { int x = x0+search[i][0]; int y = y0+search[i][1]; if( x < 0 || y < 0 || x >= mapWidth || y >= mapHeight || walkability[x][y]==1) continue; // dont outside or on the enemy spawn borders app->game.board.death1[x][y] /= 2; } } #if 0 int index = app->game.board.wave_index; int count = app->game.wave[app->game.board.wave_index].enemy_count; if(count == app->game.board.kill_count){ setWave(app, index+1); } #endif } } return 1; } return 0; }