Hey what we do whenever our internet connection goes down while surfing websites on chrome. Our little buddy comes out from now where and we help him to dodge the obstacles in his journey. so in this post, we will gonna create our own dino run game with python.
And the interesting part is we will not gonna use pygame or any other python game library. Just with help of a turtle(A python library used to draw graphics and shapes on python.)n so without wasting any time lets get into it.
- Python installed on your computer.
- Basic knowledge of python.
- Requried python Modules
- and a Brain
So installing python on your computer is a easy process. just visit official python site and navigate to download python setup file which ever suitable for your platform.
Turtle : A Python used to draw graphics on screen. Which will be used to graphically dawing in the game.
keyboard : python module Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more. which will be used to control dino.
random : for radom spawing of object and other thing in the game.
mouse : python module Take full control of your keyboard with this small Python library
time : used to mange time and sleep in our dino chrome game.
pip install keyboard pip install mouse
Use this command in your terminal or command prompt to install the python keyboard module and the mouse module which is necessary in our game. these two module does not come pre installed in python so we have to install manually using the above code.
The rest other modules are built-in modules in python so you don’t have to install them manually.
Source code and resources
make sure you have to download the resources. Click here To Download (if you face an error while downloading make sure you singed in with google drive or open it on google drive app while downloading from google drive )
once the zip file has been downloaded extract it and run the dinogame.py file
Here is the complete code and make sure you have downloaded the resources which is important otherwise the game will not work properly and show error.
Make sure you also read our articles on Space Shooter Game Using Python – python project
Credit : Ankit404butfound on github