Learning Python in 2 Days - Pygame Community Jam

Share
Embed
  • Loading...
  • Published on:  Tuesday, March 9, 2021
  • I tried to learn Python by making a game with the Pygame graphics library for the Pygame Community New Years Jam. In 2 days, I was able to put together a simple game (Flappy Bird meets Cookie Clicker?), and I learned a lot along the way!

    Check out Flappuccino here: https://polymars.itch.io/flappuccino
    → Source Code: https://github.com/PolyMarsDev/Flappuccino

    Best Height Adjustable Desk Under $300 ($15 discount): https://bit.ly/3sKPkHe

    → Twitter: https://twitter.com/PolyMarsYT
    → Twitch: https://twitch.tv/PolyMars
    → Join the PolySpace Discord: https://discord.gg/sGecnxuwxu

    ---Chapters---

    0:00 Intro
    0:41 Setting Up Python
    1:20 Streaming?
    1:29 Game Idea
    2:25 Implementing Basic Gameplay
    3:15 Adding Sprites
    4:06 Collectible System
    5:18 Basic UI
    6:01 Upgrade System
    7:42 Fancy Background
    8:09 Finishing Touches
    8:47 Conclusion

    ---Music---

    "Nocturnal" - PolarChips (https://youtu.be/-xOd0CoFoTw)
    "Swing" - PolarChips (https://youtu.be/IIVJVwZlPTU)
    "Glider" - INTL CMD (https://soundcloud.com/intlcmd)
    "Breeze" - PolarChips (https://youtu.be/GecPK2wfk_8)
    "EDM Detection Mode" - Kevin Macleod (http://incompetech.com)
    "Sneaky Snitch" - Kevin Macleod (http://incompetech.com)
    "Operatic 3" - Vibe Mountain (https://youtu.be/v8UtWLngE1s)

    ---If you liked this video, here are similar ones you might enjoy!---

    PolyMars - Learning SDL2 in 48 Hours - GMTK Game Jam 2020
    https://www.faceclips.net/video/EAMHQfCGymg/video.html
    PolyMars - Making a Game Using Discord's Bot API
    https://www.faceclips.net/video/0fWdU8JCT6Y/video.html
    CodyCantEatThis - I Made Super Mario Bros but it's 3D
    https://www.faceclips.net/video/a6HKeqWY6T4/video.html
    Dani - He said I Couldn’t Make a 3D Game… So I Made One!
    https://youtu.be/rb0EhmyQ0aM​
    Dani - 6 Months of Learning Game Development in Unity (Progress & Result) https://youtu.be/HPmD9I2b7L8​
    Sam Hogan - I Made a Game with Intentional Bugs
    https://youtu.be/M_iiXaaF5T4​
    Sam Hogan - I Made the Hardest Game Ever
    https://youtu.be/wFJQI5iNjM8​
    Mythic Legion - Remaking My First Game! | Devlog #1
    https://www.faceclips.net/video/OU3B3D-52us/video.html
    Randall - Programming a New Physics Engine for my Game
    https://www.faceclips.net/video/AGnMNor_r-Y/video.html

    ---Descriptive Description---

    I thought it would be fun to try to learn Python by challenging myself to create a video game in under 48 hours (2 days) using the Pygame graphics library. Yes, I know Python probably isn’t the best language for making a real-time game, but it’s definitely fast enough for my simple 2D games, like the one I created with SDL2 in 48 hours for the 2020 GMTK Game Jam.

    For this devlog challenge, I found a week-long game jam: the PyGame Community New Years Jam, but I decided to shorten it to 2 days and give myself only 48 hours to make a game.

    First things first, I had to set everything up, which actually ended up being pretty easy. I ran the Python installer for Windows, added the Python extension to VS Code, and installed Pygame through pip. Now we can get into the actual game-making! I decided to try to make a game similar to Flappy Bird, but vertical—you would collect coffee beans to upgrade stats like flap strength and speed in order to fly as high as possible.

    I found a Pygame example that showed me how to draw a square to the screen. Next was gravity, which is very simple for a game like this. Every frame, I add a fixed value to a y velocity variable, then I add the y velocity to a y position variable, and I draw the square at that y position. Then, I figured out how keyboard input worked in Pygame, and made it so when you press a key, the velocity variable is set to a negative fixed amount, allowing the blue square to flap. I also gave the player an x velocity that flips if its x position is less than 0 or greater than the screen width. Now the core mechanic of the game is done—you can flap and bounce off the walls.

    I created graphics for the player and coffee bean collectibles, and created a “camera” that follows the player—basically I just offset everything on the screen by the player’s y position. For the coffee bean functionality, I made a Collectible class with Vector2 to store its position, and wrote a function for rectangle collisions. I draw a list of beans above the player, and if any bean collides with the player I reset its position to a random range above the player. And with that, the main game is finished.

    I finished off the project by adding UI and other visuals, like a colorful background, and creating a shop (using bean currency) with three upgrades—one that increases your flap strength, one that makes you faster, and one that makes more coffee bean collectibles spawn. And that's where the challenge ended! This was learning Python in 48 hours with Pygame.
  • Source: https://youtu.be/7tXsC8YlCq8
Loading...

Comment