diff --git a/README.md b/README.md index 1aca2d3..9afe796 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,33 @@ -PythonShootGame -=============== +# PythonShootGame -A simple shoot game by python +A simple shoot game written in Python. +# Introduction This project only include two simple .py files: - mainGame.py:the initialization and main loop of the game - - gameRole.py: class of the game role +1. mainGame.py: The initialization and main loop of the game. +2. gameRole.py: Class of the game role. + +# Requirement + +1. Python 2.7 +2. Python-Pygame +# How To Start Game -To run this game, first install python 2.7, then install the corresponding version of pygame. -After that, double click the mainGame.py, you can play it. +```bash +$ python mainGame.py +``` + +# License +GPL + +# Screeshot + +![](http://s2.postimg.org/728c1wy4p/Screenshot_5.png) + +![](http://s30.postimg.org/fflxcv9ld/Screenshot_6.png) + +# Doc +[使用Pygame制作微信打飞机游戏PC版](https://www.cnblogs.com/dukeleo/p/3339780.html) (a Chinese startup) diff --git a/mainGame.py b/mainGame.py index 17427df..91df38f 100644 --- a/mainGame.py +++ b/mainGame.py @@ -77,7 +77,7 @@ while running: # 控制游戏最大帧率为60 - clock.tick(60) + clock.tick(45) # 控制发射子弹频率,并发射子弹 if not player.is_hit: @@ -113,7 +113,7 @@ player.is_hit = True game_over_sound.play() break - if enemy.rect.top < 0: + if enemy.rect.top > SCREEN_HEIGHT: enemies1.remove(enemy) # 将被击中的敌机对象添加到击毁敌机Group中,用来渲染击毁动画 @@ -129,9 +129,9 @@ if not player.is_hit: screen.blit(player.image[player.img_index], player.rect) # 更换图片索引使飞机有动画效果 - player.img_index = shoot_frequency / 8 + player.img_index = shoot_frequency // 8 else: - player.img_index = player_down_index / 8 + player.img_index = player_down_index // 8 screen.blit(player.image[player.img_index], player.rect) player_down_index += 1 if player_down_index > 47: @@ -145,7 +145,7 @@ enemies_down.remove(enemy_down) score += 1000 continue - screen.blit(enemy_down.down_imgs[enemy_down.down_index / 2], enemy_down.rect) + screen.blit(enemy_down.down_imgs[enemy_down.down_index // 2], enemy_down.rect) enemy_down.down_index += 1 # 绘制子弹和敌机 @@ -194,4 +194,4 @@ if event.type == pygame.QUIT: pygame.quit() exit() - pygame.display.update() \ No newline at end of file + pygame.display.update()