I created a game in which the machine should evade obstacles. You need to create a rim who will be invisible on the screen. Throw objects should be from top to bottom. Here is the code for a randomous spawn obstacles, in the list is only one obstacle, but I will add yet. It is necessary that the charter "threw" one obstacle, then after 3 seconds you threw a new one:
Class Obtacles (Games.Sprite): Speed = 2. OBTCLS= ("port.png") RndmobtCl= Choice (ObtCls) OBTCl= Games.Load_Image (RNDMOBTCL) X= RANDINT (66, 450) Def __init __ (Self, Y= -100): Super (Obtacles, Self) .__ init __ (x= x, y= y, dy= obtacles.speed) DEF UPDATE (SELF): if self.bottom > Games.Screen.Height: self.destroy () DEF HANDLE_CAUGHT (SELF): self.destroyed () DEF DESTROYED (SELF): END_MESSAGE= Games.Message (Value= "The game is over!", Size= 90, Color= Color.Red, X= Games.screen.width /2, Y= Games.Screen.Height /2, lifetime= 120, After_death= Games.screen.quit) games.screen.add (end_message)
- python : Pygame Window does not answer
- python : Is it possible to quickly bring all class arguments to Self.
In the function __init __ (Self)?
- python : Unable to install PyGame in Termux
- python : Help with 2D game
- python : Implementation of multithreading in Pygame
- python : How to change color using a variable from the outside?
- python : How to smoothly move the circle in an arbitrary direction, for example, 110 degrees
- python : Breaking a big game in one file to separate files