Christmas Pygame Animation

by MistyPearl in Living > Video Games

54 Views, 0 Favorites, 0 Comments

Christmas Pygame Animation

Thumbnail.JPG
Video (2).gif

You better watch out,

You better not cry,

You better not pout,

I'm telling you why...

Santa Claus is coming to town!

At the time of writing, it is Christmas Eve. Santa is soaring in his sleigh, delivering stockings of festive fun, waiting to be discovered by excited children tomorrow morning. Let's create a fun animation to celebrate!

CLICK TO VIEW VIDEO!

❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄

Because this is my first animation using Pygame (I have previously stuck to simple games with little graphics!), I split the design process into 3 main steps:

  1. Part 1 = set up libraries and program fundamentals, import music and background, set up animation loop and QUIT option.
  2. Part 2 = scrolling background, falling snow.
  3. Part 3 = scrolling foreground, bobbing Santa's sleigh.

Each part (named Code v1.py, Code v2.py, Code v3.py respectively) implements another layer of complexity, building up to the final animation. View them in turn, to see how new parts are explained using comments. This way you will develop an understanding of how the code works!

Supplies

Background.jpg
Sleigh.png
Reindeer.png
Foreground.png
  1. Python editor- I use Visual Studio Code.
  2. No knowledge of Pygame or Python programming required (I explain everything as best I can in the code!).
  3. Download the attached files (images above, and other files below), and put them all in the same folder.

The Basics.

View Code v1.py

Aims: set up libraries and program fundamentals, import music and background, set up animation loop and QUIT option.

The main purpose of this version of the program is to set out the basics I would need to create the animation. E.g. every good program should terminate at some point, make use of selection and iteration.

I also designed the graphics elements I would need: the background, foreground, reindeer, and sleigh. Christmas is a traditional time of year, hence I decided to use a pixelated effect on everything. I used mysterious, dark colours for the sky, and shades of black/dark grey for the buildings/trees below, setting a magical and intriguing mood.

Advancing Steps.

View Code v2.py

Aims: scrolling background, falling snow.

The main purpose of this version of the program is to bring to life the night-time scene with a moving background; this way the sleigh itself doesn't need to move horizontally to make it look like it is flying, therefore I can make the animation into a loop.

Originally the snow only fell vertically, but I later decided that it would be more realistic for it to fall slightly diagonally, as if being blown by the wild winter wind! I also made snowballs of different sizes, that fell at different speeds. Both of these are generated randomly in the program.

Finishing Touches.

View Code v3.py

Aims: scrolling foreground, bobbing Santa's sleigh.

The main purpose of this version of the program is to emphasise the Christmas theme, by introducing an iconic symbol of the season- Santa's magical sleigh!

I particularly like how the sleigh and reindeer bob up and down, with the first reindeer leading the way. When the first reindeer glides upwards, the second one follows, and then the sleigh. When it floats gracefully back down vice versa occurs.

Conclusion.

...Ho, ho, ho, ho-ray! 🎅

And that's it! Now use this project as a basis to build games and more complex animations...

❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄

My creation has turned out well. I achieved what I set out to, like a magical Christmas miracle, and in time for the big day tomorrow! Considering I am inexperienced with Pygame, its been a jolly little project to sharpen up my skills!

Thanks for sticking with me on this adventure!

CLICK TO VIEW VIDEO!