process GAME_A();
private
int intro_ = true; // if true.. intro plays..
int estado = 0; // for control states..
int fade_delay = 0; // delay for shot fade..
int game_state = 0; // intro state machine..
int anima_; // for dog animation..
int anima_walk[14] = 12,12,12,12,12,11,11,11,11,11,10,10,10,10,10; // dog walk animation..
int anima_snif[11] = 13,13,13,13,13,13,14,14,14,14,14,14; // dog snif animation..
int x_dog, y_dog; // the position of dog..
int delay_x_dog = 0; // the position of dog..
int counter_ = 0; // counter for intro control steeps..
int flash_counter_ = 0; // for flashing ducks in panel..
int i; // for duck draw active/killed bucle..
int ID_Duck;
int Counter_ducks = 0;
int Round_State = 0;
int Delay_new_duck_ = 0;
int total_kills = 0;
int delay_dog_risa_ = 0;
int counter_game_over_ = 0;
int id_wait_for_reallocate_ducks;
begin
fade(0,0,0,64);
stop_sound(all_sound);
frame(300);
Raton();
score = 0;
shots_left = 3;
shot_posible = 0;
clear_screen();
put_screen(f_main, 4);
fade(100,100,100,63);
play_sound(sfx_5);
loop
//--------------------------------- I N T R O B L O C K C O D E --------------------------------
IF(intro_ == true)
if(game_state <= 4)
draw_text( fnt_white, itoa(round), 4, 160, 55, 199 ); // draw round num..
draw_text( fnt_white, "ROUND", 4, 160, 43, 199 ); // draw round title..
draw_graphic( f_main, 25, 160, 50, 200, 0,0, 100, 100 ); // draw round panel..
end
if(game_state == 0) // start dog position..
x_dog = 30;
y_dog = 200;
game_state = 1;
end
if(game_state == 1) // dog walks forward..
anima_ = ( anima_ + 1 ) % 14;
delay_x_dog = ( delay_x_dog + 1 ) % 2;
if(delay_x_dog == 1)
x_dog++;
end
if(x_dog == 60)
anima_ = 0;
game_state = 2;
end
draw_graphic( f_main, anima_walk[anima_ + 1], x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 2) // dog snnifing..
anima_ = ( anima_ + 1 ) % 11;
if(anima_ == 1)
counter_++;
end
if(counter_ == 3)
counter_ = 0;
anima_ = 0;
game_state = 3;
end
draw_graphic( f_main, anima_snif[anima_ + 1], x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 3) // dog walks forward..
anima_ = ( anima_ + 1 ) % 14;
delay_x_dog = ( delay_x_dog + 1 ) % 2;
if(delay_x_dog == 1)
x_dog++;
end
if(x_dog == 100)
anima_ = 0;
game_state = 4;
end
draw_graphic( f_main, anima_walk[anima_ + 1], x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 4) // dog snnifing..
anima_ = ( anima_ + 1 ) % 11;
if(anima_ == 1)
counter_++;
end
if(counter_ == 3)
counter_ = 0;
anima_ = 0;
game_state = 5;
end
draw_graphic( f_main, anima_snif[anima_ + 1], x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 5) // happy dog..
counter_++;
if(counter_ == 20)
counter_ = 0;
game_state = 6;
end
draw_graphic( f_main, 15, x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 6) // dog jumps..
if(x_dog < 130)
counter_++;
x_dog+=3;
y_dog-=4;
else
game_state = 7;
end
draw_graphic( f_main, 16, x_dog, y_dog, 200, 0,0, 115, 110 );
end
if(game_state == 7) // dog walls..
counter_++;
x_dog+=2;
y_dog+=4;
if(y_dog > 190)
game_state = -1;
intro_ = false;
end
draw_graphic( f_main, 17, x_dog, y_dog, 200, 0,0, 115, 110 ); // draw dog..
draw_graphic( f_main, 22, 160, 176, 128, 0,0, 100, 100 ); // draw grass mask on top..
end
if(game_state == 6 or game_state == 7)
if(counter_ == 1)
play_sound(sfx_9);
end
if(counter_ == 10)
play_sound(sfx_9);
end
if(counter_ == 19)
play_sound(sfx_9);
end
end
END
//----------------------------------------------------------------------------------------------
//-------------------------------- DUCKS PANEL B L O C K C O D E --------------------------------
flash_counter_ = ( flash_counter_ + 1 ) % 30; // flasing ducks counter..
for(i=0; i<=9; i++) // flashing active ducks in panel..
// draw ducks active or not active in panel..
if(ducks[i].active_ == 1)
if(flash_counter_ < 15)
draw_graphic( f_main, 9, ducks[i].panel_x_, ducks[i].panel_y_, 128, 0,0, 100, 100 );
end
else
draw_graphic( f_main, 9, ducks[i].panel_x_, ducks[i].panel_y_, 128, 0,0, 100, 100 );
end
// draw duck killed in panel..
if(flash_ducks_in_red == 0)
if(ducks[i].dead_ == 1)
draw_graphic( f_main, 24, ducks[i].panel_x_, ducks[i].panel_y_, 127, 0,0, 100, 100 );
end
else
if(flash_counter_ < 15)
if(ducks[i].dead_ == 1)
draw_graphic( f_main, 24, ducks[i].panel_x_, ducks[i].panel_y_, 127, 0,0, 100, 100 );
end
end
end
end
//----------------------------------------------------------------------------------------------
//-------------------------- ROUND CONTROLLER B L O C K C O D E --------------------------------
if(game_state == -1) // if intro as finished..
if(round_state == 0) // Starts new round..
put_screen(f_main, 4); // restore initial background..
Shots_left = 3; // now you have 3 shots left..
ID_DUCK = Duck(Counter_Ducks); // launch duck..
Counter_Ducks++; // increase duck counter..
shot_posible = 1; // now has posible to shot..
round_state = 1; // change round state..
end
if(round_state == 1)
if(!exists(ID_DUCK)) // when NOT exists duck process..
shot_posible = 0; // no shot posible..
round_state = 2; // change round state..
end
end
if(round_state == 2)
delay_new_duck_ = ( delay_new_duck_ + 1 ) % 31; // counter for 1 second..
if(delay_new_duck_ == 30) // when 1 second are passed..
delay_new_duck_ = 0; // reset delay por 1 second counter..
if(Counter_Ducks < 10) // if ducks remaining..
round_state = 0; // lauch a new duck..
else // else..
game_state = -2; // finish round.. go to recount ducks..
end
end
end
end
if(game_state == -2)
total_kills += ducks[0].dead_;
total_kills += ducks[1].dead_;
total_kills += ducks[2].dead_;
total_kills += ducks[3].dead_;
total_kills += ducks[4].dead_;
total_kills += ducks[5].dead_;
total_kills += ducks[6].dead_;
total_kills += ducks[7].dead_;
total_kills += ducks[8].dead_;
total_kills += ducks[9].dead_;
if(total_kills > 5)
game_state = -10; // go to next round..
else
play_sound(sfx_16,sound_channel_game_over);
game_state = -3; // game_over..
end
end
//----------------------------------------------------------------------------------------------
//-------------------------- G A M E O V E R B L O C K C O D E --------------------------------
if(game_state == -3)
if(!is_playing_sound(sound_channel_game_over))
game_state = -4;
end
draw_text( fnt_white, "GAME OVER", 4, 160, 43, 199 ); // draw "game over" text..
draw_graphic( f_main, 28, 160, 50, 200, 0,0, 100, 100 ); // draw game over panel..
end
if(game_state == -4)
play_sound(sfx_3,sound_channel_game_over);
game_state = -5;
end
if(game_state == -5)
x = 160;
y = 170;
z = 512;
file = f_main;
graph = 18;
game_state = -6;
end
if(game_state == -6)
delay_dog_risa_ = ( delay_dog_risa_ + 1 ) % 6;
if(delay_dog_risa_ < 3)
graph = 18;
else
graph = 19;
end
if(y > 145)
y--;
else
game_state = -7;
end
draw_graphic( f_main, 22, 160, 176, 128, 0,0, 100, 100 ); // draw grass mask on top..
end
if(game_state == -7)
delay_dog_risa_ = ( delay_dog_risa_ + 1 ) % 6;
if(delay_dog_risa_ < 3)
graph = 18;
else
graph = 19;
end
if(!is_playing_sound(sound_channel_game_over))
round = 0;
estado = 0;
fade_delay = 0;
game_state = 3;
delay_x_dog = 0;
counter_ = 0;
flash_counter_ = 0;
Counter_ducks = 0;
Round_State = 0;
Delay_new_duck_ = 0;
total_kills = 0;
delay_dog_risa_ = 0;
counter_game_over_ = 0;
flash_ducks_in_red = 0;
for(i=0; i<=9; i++);
ducks[i].dead_ = 0;
ducks[i].escape_ = 0;
ducks[i].active_ = 0;
end
inicio();
end
draw_graphic( f_main, 22, 160, 176, 128, 0,0, 100, 100 ); // draw grass mask on top..
end
//----------------------------------------------------------------------------------------------
//------------------------------G O T O N E X T R O U N D--------------------------------------
if(game_state == -10) // round has passed in normal mode..
play_sound(sfx_7, sound_channel_game_over);
id_wait_for_reallocate_ducks = reallocate_ducks_on_panel();
game_state = -11;
end
if(game_state == -11)
if(!is_playing_sound(sound_channel_game_over))
game_state = -12;
end
end
if(game_state == -12)
game_state = -13;
end
if(game_state == -13)
if(!exists(id_wait_for_reallocate_ducks))
game_state = -14;
end
end
if(game_State == -14)
if(total_kills == 10) // round has passed in perfect mode..
play_sound(sfx_13, sound_channel_game_over);
draw_text( fnt_white, "PERFECT", 4, 160, 43, 199 ); // draw "perfect" text..
draw_text( fnt_white, "10000", 4, 160, 53, 199 ); // draw "1000" text..
draw_graphic( f_main, 29, 160, 50, 200, 0,0, 100, 100 ); // draw perfect panel..
score += 10000; // extra bonus score for prefect round..
game_state = -15;
else
game_state = -16;
end
end
if(game_state == -15) // End of round with perfect..
draw_text( fnt_white, "PERFECT", 4, 160, 43, 199 ); // draw "perfect" text..
draw_text( fnt_white, "10000", 4, 160, 53, 199 ); // draw "1000" text..
draw_graphic( f_main, 29, 160, 50, 200, 0,0, 100, 100 ); // draw perfect panel..
if(!is_playing_sound(sound_channel_game_over))
round ++;
intro_ = true;
estado = 0;
fade_delay = 0;
game_state = 3;
x_dog = 60;
y_dog = 200;
delay_x_dog = 0;
counter_ = 0;
flash_counter_ = 0;
Counter_ducks = 0;
Round_State = 0;
Delay_new_duck_ = 0;
total_kills = 0;
delay_dog_risa_ = 0;
counter_game_over_ = 0;
flash_ducks_in_red = 0;
for(i=0; i<=9; i++);
ducks[i].dead_ = 0;
ducks[i].escape_ = 0;
ducks[i].active_ = 0;
end
end
end
if(game_state == -16) // End of round without perfect..
round ++;
intro_ = true;
estado = 0;
fade_delay = 0;
game_state = 3;
x_dog = 60;
y_dog = 200;
delay_x_dog = 0;
counter_ = 0;
flash_counter_ = 0;
Counter_ducks = 0;
Round_State = 0;
Delay_new_duck_ = 0;
total_kills = 0;
delay_dog_risa_ = 0;
counter_game_over_ = 0;
flash_ducks_in_red = 0;
for(i=0; i<=9; i++);
ducks[i].dead_ = 0;
ducks[i].escape_ = 0;
ducks[i].active_ = 0;
end
end
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
// masc of grass and tree..
if(game_state == -1) // after intro animation..
draw_graphic( f_main, 23, 60, 92, 128, 0,0, 110, 110 ); // draw tree on top..
draw_graphic( f_main, 22, 160, 176, 128, 0,0, 100, 100 ); // draw grass mask on top..
else // before intro animation..
draw_graphic( f_main, 23, 60, 92, 512, 0,0, 110, 110 ); // draw tree on background..
end
//----------------------------------------------------------------------------------------------
//--------------------------------- S H O O T B L O C K C O D E --------------------------------
if(shot_posible == 1) // if a shots posible..
if(shots_left > 0) // if shots availables..
if(estado == 0)
if(mouse.left) // if mouse.left..
stop_sound(sound_channel_shot); // stop/clear sound channel of shot..
play_sound(sfx_17, sound_channel_shot); // play sound of shot..
shot_event = true; // enable shot event.. for duck proces..
fade(200,200,200,64); // instant fade to white screen..
shots_left--; // decrease shot counter..
estado = 1; // change state machine..
end
end
end
end
if(estado == 1) // if shot has begun..
fade_Delay = ( fade_Delay + 1 ) % 5; // start delay for fade to normal color screen..
if(fade_delay == 4) // if delay finished..
estado = 2; // change state machine..
end
end
if(estado == 2)
fade_delay = 0; // reset delay var..
shot_event = false; // disable shot event.. for duck proces..
fade(100,100,100,64); // and instant screen fade to normal color..
estado =3; // change state machine..
end
if(estado == 3)
if(!mouse.left) // when release fire button..
estado = 0; // reset state machine..
end
end
//----------------------------------------------------------------------------------------------
//--------------------------------- P A N E L B L O C K C O D E --------------------------------
if(shots_left == 1) // 1 shot available..
draw_graphic( f_main, 5, 26, 216, 200, 0,0, 115, 110 );
end
if(shots_left == 2) // 2 shots availables..
draw_graphic( f_main, 5, 26, 216, 200, 0,0, 115, 110 );
draw_graphic( f_main, 5, 35, 216, 200, 0,0, 115, 110 );
end
if(shots_left == 3) // 3 shots availables..
draw_graphic( f_main, 5, 26, 216, 200, 0,0, 115, 110 );
draw_graphic( f_main, 5, 35, 216, 200, 0,0, 115, 110 );
draw_graphic( f_main, 5, 44, 216, 200, 0,0, 115, 110 );
end
// draw panels and score..
draw_text( fnt_white, itoa(score), 5, 296, 217, 255 ); // draw score..
draw_graphic( f_main, 6, 35, 220, 256, 0,0, 100, 100 ); // shots panel..
draw_graphic( f_main, 7, 150, 220, 256, 0,0, 100, 100 ); // hit panel..
draw_graphic( f_main, 8, 270, 220, 256, 0, 0, 100, 100 ); // score panel..
//----------------------------------------------------------------------------------------------
frame;
end
end