首页下载资源游戏开发the second game

ZIPthe second game

ClassInhacker15.21KB需要积分:1

资源文件列表:

the second game.zip 大约有14个文件
  1. the second game/
  2. the second game/the second game 2.0 第10关.py 3.18KB
  3. the second game/the second game 2.0 第11关.py 4.21KB
  4. the second game/the second game 2.0 第12关.py 4.02KB
  5. the second game/the second game 2.0 第13关.py 4.53KB
  6. the second game/the second game 2.0 第1关.py 2.17KB
  7. the second game/the second game 2.0 第2关.py 2.71KB
  8. the second game/the second game 2.0 第3关.py 2.7KB
  9. the second game/the second game 2.0 第4关.py 2.69KB
  10. the second game/the second game 2.0 第5关.py 2.91KB
  11. the second game/the second game 2.0 第6关.py 3.79KB
  12. the second game/the second game 2.0 第7关.py 3.22KB
  13. the second game/the second game 2.0 第8关.py 3.73KB
  14. the second game/the second game 2.0 第9关.py 3.32KB

资源介绍:

使用pygame做的小游戏,跟茶叶蛋差不多!仅供参考!!!对了,此作品是我的原创.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................
import pygame from pygame import * from random import choice,randint import time from sys import exit class Player(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((50,50)) self.image.fill((255,255,255)) self.rect=self.image.get_rect() self.rect.x=50 self.rect.y=550 self.jumped=False self.velY=0 def move(self): xMove=0 yMove=0 keys=key.get_pressed() if keys[K_a]: self.rect.x-=3 if keys[K_d]: self.rect.x+=3 if keys[K_w] and self.jumped==False: self.velY=-15 self.jumped=True if not keys[K_w]: self.jumped=False if self.rect.left<0: self.rect.left=0 if self.rect.right>1250: self.rect.right=1250 self.velY+=1 if self.velY>10: self.velY=10 yMove+=self.velY self.rect.y+=yMove if self.rect.y>550: self.rect.y=550 if self.rect.y<0: self.rect.y=0 def update(self): self.move() class Door(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((50,100)) self.image.fill((255,255,0)) self.rect=self.image.get_rect() self.rect.x=1200 self.rect.y=500 def update(self): global run global doorkey if sprite.collide_rect(player,door) and doorkey==True: print("你赢了!") run=False class DoorKey(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((25,25)) self.image.fill((255,100,0)) self.rect=self.image.get_rect() self.rect.x=600 self.rect.y=500 def update(self): global allSprites global doorkey if sprite.collide_rect(player,doorKey): doorkey=True allSprites.remove(doorKey) class LavaPool1(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((950,50)) self.image.fill((200,50,0)) self.rect=self.image.get_rect() self.rect.x=150 self.rect.y=550 def update(self): global allSprites global run if sprite.collide_rect(player,lavaPool1): print("你输了!") allSprites.remove(player) run=False class LavaPool2(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((950,50)) self.image.fill((200,50,0)) self.rect=self.image.get_rect() self.rect.x=150 self.rect.y=0 def update(self): global allSprites global run if sprite.collide_rect(player,lavaPool2): print("你输了!") allSprites.remove(player) run=False class Laser(sprite.Sprite): def __init__(self): sprite.Sprite.__init__(self) self.image=Surface((5,600)) self.image.fill((255,0,0)) self.rect=self.image.get_rect() self.rect.x=0 self.rect.y=0 def move(self): global allSprites self.rect.x+=1 if self.rect.left>1250: self.rect.left=1250 allSprites.remove(laser) def coll(self): global run global allSprites if sprite.collide_rect(laser,player): print("你输了!") allSprites.remove(player) run=False if sprite.collide_rect(laser,doorKey): allSprites.remove(doorKey) def update(self): self.move() self.coll() init() screen=display.set_mode((1250,600)) display.set_caption("the second game 第13关---第8关 pro max") screen.fill((0,0,0)) display.update() allSprites=sprite.Group() player=Player() door=Door() doorKey=DoorKey() lavaPool1=LavaPool1() lavaPool2=LavaPool2() laser=Laser() allSprites.add(door) allSprites.add(doorKey) allSprites.add(lavaPool1) allSprites.add(lavaPool2) allSprites.add(laser) allSprites.add(player) fc=pygame.time.Clock() run=True doorkey=False while run: screen.fill((0,0,0)) for event in pygame.event.get(): if event.type==QUIT: run=False if event.type==KEYDOWN: if event.key==K_ESCAPE: run=False allSprites.update() allSprites.draw(screen) fc.tick(25) display.update() quit() exit()
100+评论
captcha