Home>

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)

Why would someone answer your questions?

Александр2021-07-23 20:33:08

You still do not respond to the answers.

Александр2021-07-23 20:33:08

@ Alexander who said?

Behruz Yuldashev2021-07-23 20:33:08

I answered your previous question, you did not react to it. Although there are already answers to all your questions.

Александр2021-07-23 20:33:08