Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make emoji games in python

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report