-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kamibababa
committed
Sep 2, 2022
0 parents
commit 1c60327
Showing
187 changed files
with
1,732 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# add | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pygame | ||
|
||
class Bullet(pygame.sprite.Sprite): | ||
def __init__(self, wdrect,bg_size): | ||
super(Bullet, self).__init__() | ||
self.image = pygame.image.load('material/images/Bullet_1.png').convert_alpha() | ||
self.rect = self.image.get_rect() | ||
|
||
#定义子弹的初始化位置 | ||
self.rect.left = wdrect[0] + 45 | ||
self.rect.top = wdrect[1] | ||
self.width = bg_size[0] | ||
self.speed = 5 | ||
|
||
def update(self, *args): | ||
if self.rect.right < self.width: | ||
self.rect.left += self.speed | ||
else: | ||
self.kill() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import random | ||
import pygame | ||
|
||
from Zombie import Zombie | ||
|
||
|
||
class FlagZombie(Zombie): | ||
def __init__(self): | ||
super(FlagZombie,self).__init__() | ||
self.image = pygame.image.load('material/images/FlagZombie_0.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/FlagZombie_{}.png'.format(i)).convert_alpha() for i in range(0,12)] | ||
|
||
# self.rect = self.images[0].get_rect() | ||
# self.rect.top = 25 + random.randrange(0,4)*125 | ||
self.energy = 10 | ||
# self.rect.left = 1000 | ||
self.speed = 4 | ||
|
||
# def update(self, *args): | ||
# if self.energy > 0: | ||
# self.image = self.images[args[0] % len(self.images)] | ||
# if self.rect.left > 250: | ||
# self.rect.left -= self.speed | ||
# else: | ||
# self.kill() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pygame | ||
|
||
class Peashooter(pygame.sprite.Sprite): | ||
def __init__(self): | ||
super(Peashooter,self).__init__() | ||
self.image = pygame.image.load('material/images/Peashooter_00.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/Peashooter_{:02d}.png'.format(i)).convert_alpha() for i in range(0,13)] | ||
|
||
self.rect = self.images[0].get_rect() | ||
self.rect.top = 100 | ||
self.rect.left = 250 | ||
self.energy = 3*15 | ||
self.zombies = set() | ||
|
||
def update(self, *args): | ||
|
||
for zombie in self.zombies: | ||
if zombie.isAlive == False: | ||
continue | ||
|
||
self.energy -= 1 | ||
|
||
if self.energy <= 0: | ||
for zombie in self.zombies: | ||
zombie.isMeetWallNut = False | ||
self.kill() | ||
|
||
self.image = self.images[args[0] % len(self.images)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pygame | ||
import os | ||
|
||
WIDTH = 360 | ||
HEIGHT = 480 | ||
|
||
|
||
game_folder = os.path.dirname(__file__) | ||
img_path = os.path.join(game_folder,'img') | ||
player_img = pygame.image.load(os.path.join(img_path,'a.png')).convert_alpha() | ||
|
||
class Player(pygame.sprite.Sprite): | ||
def __init__(self): | ||
pygame.sprite.Sprite.__init__(self) | ||
self.image = player_img | ||
# self.image.fill((0, 255, 0)) | ||
self.rect = self.image.get_rect() | ||
self.rect.center = (WIDTH / 2, HEIGHT / 2) | ||
|
||
def update(self): | ||
self.rect.x += 5 | ||
if self.rect.left > WIDTH: | ||
self.rect.right = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### 配套教程 | ||
|
||
[B站视频教程](https://www.bilibili.com/video/BV1EK4y187Kf) | ||
[简书图片教程](https://www.jianshu.com/nb/33278365) | ||
|
||
### 下载体验 | ||
|
||
链接:https://pan.baidu.com/s/1Icu2UkkHYfERhVU0USjHmw | ||
提取码:yftf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import random | ||
|
||
import pygame | ||
|
||
class Sun(pygame.sprite.Sprite): | ||
def __init__(self,rect): | ||
super(Sun,self).__init__() | ||
self.image = pygame.image.load('material/images/Sun_1.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/Sun_{}.png'.format(i)).convert_alpha() for i in range(1,18)] | ||
|
||
self.rect = self.images[0].get_rect() | ||
|
||
offsetTop = random.randint(-50,50) | ||
offsetLeft = random.randint(-50,50) | ||
|
||
self.rect.top = rect.top + offsetTop | ||
self.rect.left = rect.left + offsetLeft | ||
|
||
def update(self, *args): | ||
|
||
|
||
self.image = self.images[args[0] % len(self.images)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pygame | ||
|
||
class SunFlower(pygame.sprite.Sprite): | ||
def __init__(self,lasttime): | ||
super(SunFlower, self).__init__() | ||
self.image = pygame.image.load('material/images/SunFlower_00.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/SunFlower_{:02d}.png'.format(i)).convert_alpha() for i in range(0,13)] | ||
|
||
self.rect = self.images[0].get_rect() | ||
self.rect.top = 250 | ||
self.rect.left = 450 | ||
self.lasttime = lasttime | ||
self.energy = 3*15 | ||
self.zombies = set() | ||
|
||
def update(self, *args): | ||
for zombie in self.zombies: | ||
if zombie.isAlive == False: | ||
continue | ||
|
||
self.energy -= 1 | ||
|
||
if self.energy <= 0: | ||
for zombie in self.zombies: | ||
zombie.isMeetWallNut = False | ||
self.kill() | ||
|
||
self.image = self.images[args[0] % len(self.images)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pygame | ||
|
||
class WallNut(pygame.sprite.Sprite): | ||
def __init__(self): | ||
super(WallNut, self).__init__() | ||
self.image = pygame.image.load('material/images/WallNut_00.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/WallNut_{:02d}.png'.format(i)).convert_alpha() for i in range(0,13)] | ||
self.crackedImgs = [ | ||
pygame.transform.smoothscale(pygame.image.load("material/images/Wallnut_body.png").convert_alpha(), | ||
(self.image.get_rect().width, self.image.get_rect().height)), | ||
pygame.transform.smoothscale( | ||
pygame.image.load("material/images/Wallnut_cracked1.png").convert_alpha(), | ||
(self.image.get_rect().width, self.image.get_rect().height)), | ||
pygame.transform.smoothscale( | ||
pygame.image.load("material/images/Wallnut_cracked2.png").convert_alpha(), | ||
(self.image.get_rect().width, self.image.get_rect().height))] | ||
self.rect = self.images[0].get_rect() | ||
self.rect.top = 200 | ||
self.rect.left = 250 | ||
|
||
self.energy = 8*15 | ||
self.zombies = set() | ||
|
||
def update(self, *args): | ||
for zombie in self.zombies: | ||
if zombie.isAlive == False: | ||
continue | ||
|
||
self.energy -= 1 | ||
|
||
if self.energy <= 0: | ||
for zombie in self.zombies: | ||
zombie.isMeetWallNut = False | ||
self.kill() | ||
|
||
|
||
if self.energy == 8*15: | ||
self.image = self.images[args[0] % len(self.images)] | ||
elif 6*15 <= self.energy < 8*15: | ||
self.image = self.crackedImgs[0] | ||
elif 3 * 15 <= self.energy < 6 * 15: | ||
self.image = self.crackedImgs[1] | ||
else: | ||
self.image = self.crackedImgs[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import random | ||
|
||
import pygame | ||
|
||
class Zombie(pygame.sprite.Sprite): | ||
def __init__(self): | ||
super(Zombie,self).__init__() | ||
self.image = pygame.image.load('material/images/Zombie_0.png').convert_alpha() | ||
self.images = [pygame.image.load('material/images/Zombie_{}.png'.format(i)).convert_alpha() for i in range(0,22)] | ||
self.dieimages = [pygame.image.load('material/images/ZombieDie_{}.png'.format(i)).convert_alpha() for i in range(0,10)] | ||
self.attack_images = [pygame.image.load('material/images/ZombieAttack_{}.png'.format(i)).convert_alpha() for i in | ||
range(0, 21)] | ||
self.rect = self.images[0].get_rect() | ||
self.rect.top = 25 + random.randrange(0,4)*125 | ||
self.energy = 6 | ||
self.rect.left = 1000 | ||
self.speed = 5 | ||
self.dietimes = 0 | ||
self.isMeetWallNut = False | ||
self.isAlive = True | ||
|
||
def update(self, *args): | ||
if self.energy > 0: | ||
if self.isMeetWallNut: | ||
self.image = self.attack_images[args[0] % len(self.attack_images)] | ||
else: | ||
self.image = self.images[args[0] % len(self.images)] | ||
if self.rect.left > 250 and not self.isMeetWallNut: | ||
self.rect.left -= self.speed | ||
else: | ||
if self.dietimes < 20: | ||
self.image = self.dieimages[self.dietimes//2] | ||
self.dietimes += 1 | ||
else: | ||
if self.dietimes > 30: | ||
self.isAlive = False | ||
self.kill() | ||
else: | ||
self.dietimes += 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import time | ||
|
||
import pygame | ||
|
||
pygame.init() | ||
|
||
WIDTH = 360 | ||
HEIGHT = 480 | ||
|
||
screen = pygame.display.set_mode((WIDTH,HEIGHT)) | ||
pygame.display.set_caption('plant_vs_zoomie') | ||
|
||
# Colors (R, G, B) | ||
BLACK = (0, 0, 0) | ||
WHITE = (255, 255, 255) | ||
RED = (255, 0, 0) | ||
GREEN = (0, 255, 0) | ||
BLUE = (0, 0, 255) | ||
|
||
myfont = pygame.font.Font(None,60) | ||
# textImgage = myfont.render('pygame',True,WHITE) | ||
|
||
FPS = 60 | ||
clock = pygame.time.Clock() | ||
running = True | ||
count = 0 | ||
start = time.time() | ||
while running: | ||
clock.tick(FPS) | ||
for event in pygame.event.get(): | ||
if event.type == pygame.QUIT: | ||
running = False | ||
|
||
count += 1 | ||
now = time.time() | ||
fps = count / (now -start) | ||
fpsImgage = myfont.render(str(fps), True, WHITE) | ||
|
||
screen.fill(BLACK) | ||
screen.blit(fpsImgage,(100,100)) | ||
pygame.display.flip() |
Oops, something went wrong.