Then, place this file (picture.png) into the ' images' folder (within the source-code-excitebike folder). Screen.blit( "rock1", ((t* 100)+trackOffset -50, 270))ĭo you want to replace your motorbike with a Monster truck, four-wheeler, or another vehicle? Maybe you want to race a unicorn to the finish line?Īll you need to do is draw a 50x50px image (with a transparent background). Once you create a backup copy of the python code, try changing the below numbers to see what happens to the rocks on screen! screen.blit( "crowd1", ((t* 100)+trackOffset -100, 0)) The second and third lines of code, below, work together to simulate the scenery in a tidy fashion. The rock images are displayed on the screen in two parts. Yet, the code, below, tells the computer when to draw the image so that it appears as if there is a simulated crowd behind the motorcycle as it moves. The supplied crowd image is only 100px wide. This code draws image blocks on the screen at certain intervals and particular positions on the screen. The below items in quotes represent an image. Instead of the start time, the time is calculated from when the motorbike passes a predefined track position (mentioned as trackPos < -4800 in the code). Lap time is constantly calculating the difference between the initial right arrow key press (start time) and the current time. You'll also notice calculations for lap time and the last lap (this is represented by the time counter at the bottom of the screen). ![]() The word, " background," refers to the background image (linking the images to the background block is thanks to the imported Pygame Zero modules). ![]() A " blit" refers to a block that is drawn on the screen. The draw function draws the background as the bike image moves.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |