0

I am writing a beginner Java version of the popular game of '90: SkiFree for personal learning. I managed to create most of the game display, but I have an issue with the layout management there regarding three sprites: the skier, the yellow pillar and two tele-chairs (I've named them "teleski"). In the game, when the skier is up on the screen, the order of the sprites is the following:

  • the skier (behind all three sprites);
  • the teleskis;
  • the pillar.

But when the skier passes in front of the yellow pillar (his y-value goes higher than the yellow pillar's y-value + pillar's height), the order changes, but not like in the game, which until now I found impossible to draw. The order should be something like this: the skier must be in front of the pillar, but always behind the teleskis, which in turn are always behind the pillar (but in this order, the teleskis are always in front of the pillar).. I tried all versions, but I still cannot figure it out how the creator did it!

Here is what I've done until now:

//this is the case when the skier is in front of the pillar
//but in this case both the teleskis go over the pillar while in the SkiFree game they always go behind the pillar.. How did the creator do it??
if(skier.y + skier.height > pillar.y + pillar.height && skier.y + skier.height < pillar.y + pillar.height + skier.height 
   && pillar.x + 8 < skier.x + 28 && pillar.x + 8 > skier.x - 16)
{
      g.drawImage(pillar.img, pillar.x, pillar.y, pillar.width, pillar.height,null);
      g.drawImage(skier.img, skier.x, skier.y, skier.width, skier.height,null);
      g.drawImage(teleski1.img, teleski1.x, teleski1.y, teleski1.width, teleski1.height, null);
      g.drawImage(teleski2.img, teleski2.x, teleski2.y, teleski2.width, teleski2.height, null);
} 
//and the case when the skier is behind the pillar
//this one is okay - the teleskis go under the pillar and the skier is behind all of them!
else 
{
      g.drawImage(skier.img, skier.x, skier.y, skier.width, skier.height,null);
      g.drawImage(teleski1.img, teleski1.x, teleski1.y, teleski1.width, teleski1.height, null);
      g.drawImage(teleski2.img, teleski2.x, teleski2.y, teleski2.width, teleski2.height, null);
      g.drawImage(pillar.img, pillar.x, pillar.y, pillar.width, pillar.height,null);
}

Can anyone help me on this issue? Has anyone tried until now a reverse-engineering on SkiFree? :)

Many thanks in advance!

Sammy

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.