Computer Science, asked by Anonymous, 1 year ago

Give a Python Code for Game​

Answers

Answered by maisamabbas1122
1

Answer:

COD mobile

Explanation:

Game like pubg includes python gun

Answered by gulshanprasad2812
0

worldx = 960

worldy = 720

fps = 40  # frame rate

ani = 4  # animation cycles

world = pygame.display.set_mode([worldx, worldy])

BLUE = (25, 25, 200)

BLACK = (23, 23, 23)

WHITE = (254, 254, 254)

ALPHA = (0, 255, 0)

'''

Objects

'''

class Player(pygame.sprite.Sprite):

   """

   Spawn a player

   """

   def __init__(self):

       pygame.sprite.Sprite.__init__(self)

       self.images = []

       for i in range(1, 5):

           img = pygame.image.load(os.path.join('images', 'hero' + str(i) + '.png')).convert()

           img.convert_alpha()  # optimise alpha

           img.set_colorkey(ALPHA)  # set alpha

           self.images.append(img)

           self.image = self.images[0]

           self.rect = self.image.get_rect()

'''

Setup

'''

backdrop = pygame.image.load(os.path.join('images', 'stage.png'))

clock = pygame.time.Clock()

pygame.init()

backdropbox = world.get_rect()

main = True

player = Player()  # spawn player

player.rect.x = 0  # go to x

player.rect.y = 0  # go to y

player_list = pygame.sprite.Group()

player_list.add(player)

'''

Main Loop

'''

while main:

   for event in pygame.event.get():

       if event.type == pygame.QUIT:

           pygame.quit()

           try:

               sys.exit()

           finally:

               main = False

       if event.type == pygame.KEYDOWN:

           if event.key == ord('q'):

               pygame.quit()

           try:

               sys.exit()

           finally:

               main = False

   world.blit(backdrop, backdropbox)

   player_list.draw(world)

   pygame.display.flip()

   clock.tick(fps)

Similar questions