Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Make a Battle City Clone, using Python, Pygame and OOP!
Rating: 4.5 out of 5(19 ratings)
204 students

Make a Battle City Clone, using Python, Pygame and OOP!

Object Oriented Programming, Game, Development, Python, Pygame,
Last updated 7/2023
English

What you'll learn

  • Expand your understanding and use of variables, lists, dictionaries, for loops and while loops.
  • Expand your understanding and use of object oriented programming
  • Conceptualize programming challenges and discover solutions and methods for implementing these solutions to those challenges
  • Progress your python learning beyond learning the basics to a more advanced beginner project, gain confidence in tackling bigger projects.
  • Work on importing various modules into your program, as well as importing data between various python files
  • Sharing and updating data between the various objects within your program, updating the different objects when required, also updating the game stage
  • Implementing various solutions to typical game development challenges, such as collision detection, animations, power-ups etc.
  • Creating a Start Screen, a Menu Screen, a Game Screen, A Level Editor screen, allowing for user level development.

Course content

13 sections55 lectures18h 6m total length
  • Creating the "Main" object class14:20
    • Create the main.py file

    • Create the Main Class

      1. Initialize the class with the init() method

      2. Initialize the pygame module

    • Create the gameconfig file

    • Back in the Main class

      1. Create the game window

      2. Create the input() method

      3. Create the update() method

      4. Create the draw() method

      5. Create the run_game() method

    • Insert the if Name = Main check to instantiate the main object

    • Run the game

  • Creating the "Game Assets" object class - Part 1 - Loading individual images22:49
    • Create the "game_assets.py" file

    • Create the "GameAssets" Class

      1. Create the init() method

      2. Use pygame.image.load() to load in game images

      3. Use pygame.transform.scale() to change the size of an image

      4. Create a method to combine the two functions above into one smooth process

      5. Make use of default arguments in methods, in order to minimize the amount of typing/coding required.

      6. Create a dictionary attribute, and fill that dicitionary with images, using a "for loop" and the newly created method

    • Import the game_assets.py file into the main.py file, in order to allow the Main class to create an instance of the GameAssets() object.

    • Run the game, ensuring no errors pop up.

  • Creating the "Game Assets" object class - Part 2 - Sprite sheet Images - Tanks34:32

    Loading in of the 256 Tank images

    • Create the load_all_tank_images() method

      • Generate the Tank Images Dictionary

      • Populate the Tank Images Dictionary template using nested for loops

    • Create the scale_image() method

    • Create the sort_tanks_into_levels() method

    • Create the sort_tanks_into_groups() method

    • Create the sort_tanks_by_directions() method

    Check the game for error messages, and draw a tank image to screen for testing

  • Creating the "Game Assets" object class - Part 3 - Sprite sheet Images - other40:40

    Input the various spritesheet coordinates for the various images.

    • Create a method to generate the image dictionaries, complete with various images

    • Create a method to get the required image from the sprite sheet.

    • Update the scale_image() method

    • Load in all of the image dictionaries with image files

  • Creating the "Game" object class11:55

    Finally we at the point now where we can start coding the game into existence. The first thing we are going to create is the game object. The game object, and many of the other objects we will create will follow the same structure in terms of operation.

    • input()

    • update()

    • draw()

    Many of the other methods we will create, will be called from within these three methods.

    in the game class we create:

    • init()

    • input()

    • update()

    • draw()

    Many more items will be created within these methods, but for now the base game is created.


    As an aside, the reason why we are running the game in a class separate to the main class, is because the game moves through phases. We have a start screen, a game screen, and a level editor screen. So it will be easier to switch between the different phases in the main class.

Requirements

  • Basic understanding of Python Programming, ie- variables, lists, dictionaries, classes.
  • Basic understanding of importing modules, such as the pygame module
  • Already have the pygame module installed

Description

I have done so many of the regular projects out there, such as a tic tac toe, chess, hangman, asteroids, connect 4, but all of these projects felt small and I found there to not be much variety when it comes to game tutorials.

Most tutorials all cover the same games, with only variations in how they are coded. I also found that most tutorials, do not go through every element of a game, such as the start screen, all of the power ups, the score screens, etc.

They usually only take you as far as the basic building blocks, and then leave you to create the rest, should you wish to continue.
Most of these tutorials, have left me with a directory filled with what would be deemed as unfinished games.
Hence I thought it would be great to put together a course on creating a game, with all of the game elements created and implemented in a step by step process, that leaves you at the end of the course, with a fully functional, and complete game.

My hope is that you are able to understand how each element of this game is created and implemented, so that you gain further insight when deciding to tackle a challenge of your own.

I also find the old games from the 80's and 90's as fantastic coding challenges, in particular when it comes to trying to understand how something may have been implemented.

Who this course is for:

  • Python Programmers who have an understanding of python basics, but are looking to tackle projects bigger than tictactoe and hangman.