Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make emoji games in python

Shulou Source: shulou.com Published: 2022-06-03 10:08:03 10月04日 Update

This article mainly shows you "python how to make emoji games", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python how to make emoji games" this article.

Text

Rules of the game: ow big meow run this game design, mainly to avoid behind the dragon, the front of the flame.

Environment installation: mainly based on the game module pygame. The basic environment such as python can be installed directly by itself.

First of all, the prepared game picture material:

Create a game interface:

Button = Button (upImageFilename,downImageFilename, (400500)) interface = pygame.image.load ("interface.png")

As follows:

As soon as you enter the game interface, you need some music.

Def audio_init (): global hit_au,btn_au,bg_au,bullent_au pygame.mixer.init () hit_au = pygame.mixer.Sound ("exlposion.wav") btn_au = pygame.mixer.Sound ("button.wav") bg_au = pygame.mixer.Sound ("background.ogg") bullent_au = pygame.mixer.Sound ("bullet.wav")

Create elves such as dragons and bullets.

Bg1 = MyMap (0jue 0) bg2 = MyMap (600je 0) group = pygame.sprite.Group () group_exp = pygame.sprite.Group () group_fruit = pygame.sprite.Group () dragon = MySprite () dragon.load ("dragon.png", 260,150,3) dragon.position = 100, 230group.add (dragon) explosion = MySprite () explosion.load ("explosion.png", 128 prime128) player = MySprite () player.load ("sprite.png", 100,100,4) player.position = 400 270group.add (player) arrow = MySprite () arrow.load ("flame.png", 40,16,1) arrow.position = 800320group.add (arrow)

Since it is a running game, the natural map needs to keep moving forward and scrolling.

Class MyMap (pygame.sprite.Sprite): def _ init__ (self,x,y): self.x = x self.y = y self.bg = pygame.image.load ("background.png"). Convert_alpha () def map_rolling (self): if self.x

< -600: self.x = 600 else: self.x -=5 def map_update(self): screen.blit(self.bg, (self.x,self.y)) def set_pos(x,y): self.x =x self.y =y .................................................................... 等等等......代码很多撒,展示部分代码先。 ....................................................................

Effect picture:

The above is all the contents of the article "how to make emoji games in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Production expressions content articles code game interface environment interface learning help pictures picture materials maps bullets effects effect drawings easy to understand more organization modules Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Microsoft Shulou Tech Info MySQL