Making a game in python after my first sem of basic python programing course

karthik52

Karthik PM

Posted on February 27, 2022

Making a game in python after my first sem of basic python programing course

code of the project: https://github.com/Karthik-PM/MyProjects/tree/main/Blasteroids

well this project was my first python project and I made this game at the end of my first year of college with the basic knowledge I gained from a basic intro python class in my first semester of university , now this a simple 2D game where there is a rocket and some objects and the rocket shoots those objects and if I have enough points then I can move to the next round.
Image description
now how did I make this .
first of all I got to know about a library know as pygame through my professor at university.

step by step process of how I made this game:

first of all as a beginner in coding I was intimidated by coding it self lol (crying in pain TvT)

so first I learned how to create a game loop , now as we know that our game must play until it game over , so you need to use a continuous while loop where the loop only breaks if you press the close button or exit.

now after I created a game loop I got to know about various functions in the library , like how to store pictures in variables (its know also known assets).

then Imported lot of images like space ship, meteoroids and a bomb which when hit will be game over.
then I found about a file in pygame library where I can import music and I added that.
after thats done it looked like a decent game I played and I showed it to my mom (and she was like its so dull , give it more levels and stuff)

so I made my first progress as level one
Image description

then I decided to make level to so i set a Hight score system in the game using the file I/O concept in python (which i didn't learn in my python course , got it through googling stuff like how to store permanent values in python or something lol .
so i store the value of the current score in a notepad and then retrieve it and convert it to an integer and put a comparison that if the score reaches above a highscore it will make a sound saying high score and if the point moves about a certain value that means it has leveled up and then i change its backround image and then slowly build up my game and this is my end result
https://twitter.com/Karthik36906306/status/1438865061590700043

so if you are a fresher like me and have some gotten some basic idea of python i recommend you to do this project.

so first before you start you need to have the pygame library so
first of all you need to download pip (use this link https://pypi.org/project/pip/)
and then use that to download your python libraries in your terminal type

Image description

basic things to learn after you have everthing to start using pygame:
1) learn to make a game loop
2) learn to store sprites in variables
3) learn to play music in the game
4) how to set backround
5) how to make multiple frames
if you guys learn this you will have something to start with and rest you guys have google , search for every doubts its very usefull.

💖 💪 🙅 🚩
karthik52
Karthik PM

Posted on February 27, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related