Monday, April 28, 2014

Level Ascension

The game involves fighting four different creatures. Each creature is on a different 'level'. The 'level' is a global variable that increments when the variable 'creatureHP' falls to 0 (creatureHP is also a global variable, which is set to the creature's HP at the beginning of each level).


Depending on which 'level' the player is on, the program will know what to display, how effective your magic is, and how much damage the creature can blow to you.

Each level has a unique landscape. The same "level" variable is also used for victory/defeat screens.

The level code looks like:

void level()
{
  if (level == 0)
  {
     background(dark);
     fill(255,0,0);
     text("Alas... you have died by the cruel forces of the world.",width/2,height/2 - 50);
     text("You have chosen the ways of the Good Guys.",width/2,height/2); 
     text("Oh well. Maybe your battle can still be won.",width/2,height/2 + 50); 
  }
  else if (level == 1)
  {
   background(forest);
   if (!begin1)
   {
     goblin = new Creature(width/2,height/2,5,0,1,1,1,1,0.8,25);
     begin1 = !begin1;
   }
  }
   else if (level == 2)
   {
    background(desert);
   if (!begin2)
  {
     snake = new Creature(width/2,height/2,3,1,0.5,0.8,1,0,1,0);
     begin2 = !begin2;
  }
   }
  else if (level == 3)
  {
    background(castle);
    if (!begin3)
   {
     totalAttackTime = 8000;
    wizard = new Creature(width/2,height/2,5,5,0.5,0.5,0,1,1,0);
    begin3 = !begin3;
   } 
  }
  else if (level == 4)
  {
    background(glacier);
        if (!begin3)
   {
    dragon = new Creature(width/2,height/2,6,8,0.75,0,0.35,0.5,0.3,0);
    begin3 = !begin3;
   } 
  }
  else
  {
    background(beach);
    fill(0,255,0);
     text("CONGRATULATIONS!",width/2,height/2 - 50);
     text("Through skill and perserverance, you defeated Fantasy Villains, Inc.",width/2,height/2); 
     text("May you rise to become one of the greatest wizards of all time.",width/2,height/2 + 50); 
  }
  
}

No comments:

Post a Comment