示例#1
0
文件: MultiPlayer.py 项目: EUmbr/Py
    def __init__(self):
        self.sound = games.load_sound('level.wav')

        self.player1_score = games.Text(value=0,
                                        size=40,
                                        color=color.white,
                                        x=10,
                                        top=5,
                                        is_collideable=False)
        games.screen.add(self.player1_score)

        self.player2_score = games.Text(value=0,
                                        size=40,
                                        color=color.red,
                                        x=games.screen.width - 10,
                                        top=5,
                                        is_collideable=False)
        games.screen.add(self.player2_score)

        self.player1 = Player1(x=games.screen.width / 2 - 100,
                               y=games.screen.height / 2)
        games.screen.add(self.player1)

        self.player2 = Player2(x=games.screen.width / 2 + 100,
                               y=games.screen.height / 2)
        games.screen.add(self.player2)

        self.ball = Ball(game=self,
                         x=games.screen.width / 2,
                         y=games.screen.height / 2)
        games.screen.add(self.ball)
示例#2
0
文件: game.py 项目: felekx/Ship_Game
def main():
    wall_image = games.load_image("tlo.jpg", transparent=False)
    games.screen.background = wall_image

    score1 = games.Text(value='Komputer',
                        size=22,
                        color=color.light_gray,
                        x=45,
                        y=15,
                        is_collideable=False)
    score2 = games.Text(value='Gracz',
                        size=24,
                        color=color.light_gray,
                        x=(games.screen.width - 40),
                        y=15,
                        is_collideable=False)
    games.screen.add(score1)
    games.screen.add(score2)

    statek_gora = Statek_gora(x=350, y=30)
    games.screen.add(statek_gora)

    statek_dol = Statek_dol(x=games.mouse.x, y=games.mouse.y)
    games.screen.add(statek_dol)

    games.mouse.is_visible = False
    games.screen.event_grab = True

    games.screen.mainloop()
示例#3
0
文件: main.py 项目: AntonKAb/Game
    def __init__(self, dx):
        super(Hero, self).__init__(image=Hero.scr,
                                   x=games.screen.width / 2,
                                   bottom=games.screen.height - 90,
                                   dx=dx)
        self.dx = dx

        self.score = games.Text(value=Hero.points,
                                size=32,
                                color=colour.black,
                                top=5,
                                right=games.screen.width - 12)
        self.score_letter = games.Text(value='Score: ',
                                       size=32,
                                       color=colour.black,
                                       top=5,
                                       right=games.screen.width - 20)
        games.screen.add(self.score)
        games.screen.add(self.score_letter)

        self.health = games.Text(value=1,
                                 size=32,
                                 color=colour.black,
                                 top=30,
                                 right=games.screen.width - 12)
        self.health_letter = games.Text(value='Health: ',
                                        size=32,
                                        color=colour.black,
                                        top=30,
                                        right=games.screen.width - 20)
        games.screen.add(self.health)
        games.screen.add(self.health_letter)
示例#4
0
    def __init__(self):
        super(Game, self).__init__(image=Game.image, x=0, y=0)

        # Instructions Labels
        self.instructions = games.Text(value="Shoot as many ducks as possible in 1 minute!", size=35, x=320, y=100, color=color.white)
        self.instructions2 = games.Text(value="Press \"P\" To Pause", size=35, x=320, y=140, color=color.white)
        games.screen.add(self.instructions)
        games.screen.add(self.instructions2)
        
        # Paused Game Sprite
        self.paused = games.Sprite(image=games.load_image("Sprites/paused.png"), x=320, y=240, dx=0, dy=0)
                                      
        # Final Results Labels
        self.results = games.Text(value="", size=35, x=320, y=100, color=color.white) # How many ducks were hit
        self.results2 = games.Text(value="", size=35, x=320, y=140, color=color.white)# Accuracy

        # Counters to delay events
        self.spawnCounter = 0
        self.menuCounter = 0
        
        self.keyDelay = 0
        self.keyDelayStart = False
        
        self.playing = False # Set to true after instructions go away
        
        # Create the timer for the game
        self.gameTimer = Clock()
        games.screen.add(self.gameTimer)
示例#5
0
    def show_menu(self):
        """ restart gry """
        games.screen.clear()
        games.screen.add(self.direct)
        self.direct.state = Director.MENU
        #wyświetlanie instrukcji
        message1 = games.Text(value = "Move with arrows.", 
                             size = 80,
                             color = color.white,
                             x = games.screen.width/2,
                             y = games.screen.height/4,
                             is_collideable = False)
        games.screen.add(message1)

        message2 = games.Text(value = "Shoot with space.",
                             size = 80,
                             color = color.white,
                             x = games.screen.width/2,
                             y = games.screen.height*1/2,
                             is_collideable = False)
        games.screen.add(message2)

        message3 = games.Text(value = "Press enter to start.",
                             size = 80,
                             color = color.white,
                             x = games.screen.width/2,
                             y = games.screen.height*3/4,
                             is_collideable = False)
        games.screen.add(message3)
        self.loaded = 1
 def __init__(self, x, y):
     self.start()
     super(Player,
           self).__init__(left=x * tilesize,
                          top=y * tilesize,
                          image=games.load_image("hidden\\player.png"))
     self.elevc = [[0, 0], [0, 0], [0, 0]]
     level, self.elevc[0] = generate(screen_width // tilesize,
                                     screen_height // tilesize, 1, x, y)
     self.spritelist = []
     self.xc = x
     self.yc = y
     self.default = self.image
     self.movingdir = None
     self.moveleft = 0
     self.full = [(x, y) for x in range(screen_width // tilesize)
                  for y in range(screen_height // tilesize)]
     level2, self.elevc[1] = generate(screen_width // tilesize,
                                      screen_height // tilesize, 2,
                                      self.elevc[0][1], self.elevc[0][0])
     level3, self.elevc[2] = generate(screen_width // tilesize,
                                      screen_height // tilesize, 3,
                                      self.elevc[1][1], self.elevc[1][0])
     back = pygame.Surface((screen_width, screen_height))
     self.val = 4
     shaft = pygame.transform.scale(
         games.load_image("hidden\\shaft.png", transparent=False),
         (screen_width, screen_height))
     a = 255 * .6
     shaft.fill((a, a, a), special_flags=pygame.BLEND_RGB_MULT)
     back.blit(shaft, (0, 0))
     self.nomove = list(filter(lambda x: level[x[1]][x[0]] == 0, self.full))
     self.levels = [level, level2, level3]
     self.levelsp = [1, .6, .6**2]
     self.levelshow(level3, .6**2, back)
     self.levelshow(level2, .6, back)
     self.levelshow(level, 1, back)
     games.screen.set_background(back)
     self.advancing = 0
     self.currlevel = games.Text(value="Level: " + str(self.val - 3),
                                 left=5,
                                 top=5,
                                 color=color.red,
                                 size=25,
                                 is_collideable=False)
     games.screen.add(self.currlevel)
     self.score = 0
     self.coinlist = []
     self.tscore = games.Text(value="Score: " + str(self.score),
                              left=5,
                              top=30,
                              color=color.red,
                              size=25,
                              is_collideable=False)
     games.screen.add(self.tscore)
     self.spritelist.append(self.tscore)
     self.spritelist.append(self.currlevel)
     self.make_coins()
     self.make_enemies()
     self.cooldown = 50
示例#7
0
文件: Pong2.py 项目: rgbvlc/Pong2
    def __init__(self):
        super(Ball, self).__init__(image=Ball.ball_image,
                                   x=games.screen.width / 2,
                                   y=games.screen.height / 2,
                                   dy=self.speed)

        self.score1 = games.Text(value=0,
                                 size=88,
                                 top=20,
                                 right=192.5,
                                 color=(255, 255, 255),
                                 is_collideable=False)
        games.screen.add(self.score1)
        self.score2 = games.Text(value=0,
                                 size=88,
                                 top=20,
                                 left=577,
                                 color=(255, 255, 255),
                                 is_collideable=False)
        games.screen.add(self.score2)

        Paddle.balldirect(self)

        if self.direct:
            self.dx = self.speed
        else:
            self.dx = -self.speed
示例#8
0
 def __init__(self, x = 320 ,y = 240 ):
     super(Pong, self).__init__(image = Pong.image,
                                x = x, y = y, dx = Pong.speed, dy = Pong.speed)
     self.comp_score = games.Text(value = 0, size = 35, color = color.green,
                             top = 240, left = 200, is_collideable = False)
     games.screen.add(self.comp_score)
     
     self.player_score = games.Text(value = 0, size = 35, color = color.green,
                             top = 240, right = games.screen.width - 200, is_collideable = False)
     games.screen.add(self.player_score)
示例#9
0
 def __init__(self):
     """ Initialize Dog object and create Text object for score. """
     super(Dog, self).__init__(image = Dog.image,
                               x = games.mouse.x,
                               bottom = games.screen.height)
     
     self.score = games.Text(value = 0, size = 25, color = color.black,
                             top = 5, right = games.screen.width - 10)
     games.screen.add(self.score)
     self.level = games.Text(value = 0, size = 25, color = color.blue,
                             top = 5, left = games.screen.width - 800)
     games.screen.add(self.level)
示例#10
0
 def __init__(self):
     self.ship = Player()
     games.screen.add(self.ship)
     background = games.load_image("media/background.bmp")
     games.screen.set_background(background)
     self.level = 0
     self.score = 0
     self.score_display = games.Text(value="Score: 0", size = 20, color=color.white, top = 10,\
         right = WIDTH-30, is_collideable=False)
     games.screen.add(self.score_display)
     self.level_display = games.Text(value="Level: 0", size = 20, color=color.white, top = 10,\
         left = 30, is_collideable=False)
     games.screen.add(self.level_display)
示例#11
0
    def __init__(self):
        # создание начального текста таймера
        self.sec = games.Text(value="1:00",
                              size=100,
                              color=color.white,
                              top=20,
                              right=games.screen.width - 40,
                              is_collideable=False)
        self.sec.set_size(72, 'Fonts/Fixedsys.ttf')  # внес изменения в модуль Доусона
        games.screen.add(self.sec)

        # создание указателей координат X и Y
        self.position = games.Text(
            value="X   Y",
            color=color.white,
            size=20,
            y=10,
            x=174,
            is_collideable=False)
        self.position.set_size(26, 'Fonts/Fixedsys.ttf')  # внес изменения в модуль Доусона
        games.screen.add(self.position)

        # создание указателя колличества пробуренных скважин
        self.counter_borehole = games.Text(value="{0}".format(Game.total_borehole),
                                           size=100,
                                           color=color.white,
                                           y=60,
                                           left=342,
                                           is_collideable=False)
        self.counter_borehole.set_size(64, 'Fonts/Fixedsys.ttf')  # внес изменения в модуль Доусона
        games.screen.add(self.counter_borehole)

        # создание анимации инженера
        pill = Pill()
        games.screen.add(pill)
        print(pill.get_right())
        # создание анимации инженера
        engineer = Engineer()
        games.screen.add(engineer)
        # создание анимации рабочего
        worker = Worker()
        games.screen.add(worker)
        # создание анимации флага
        flag = Flag()
        games.screen.add(flag)
        # создание анимации бура
        bore = Bore()
        games.screen.add(bore)
示例#12
0
class Game(object):
    # DELAY = 5
    SCORE = games.Text(value=0,
                       size=40,
                       color=color.red,
                       top=5,
                       right=games.screen.width - 10,
                       is_collideable=False)

    def __init__(self):
        self.level = 0

        games.screen.add(Game.SCORE)

        wall_image = games.load_image("600space.jpg", transparent=False)
        games.screen.background = wall_image

        for i in range(250):
            x = random.randrange(games.screen.width)
            y = random.randrange(games.screen.height)
            size = random.choice([Stars.SMALL, Stars.MEDIUM])
            new_star = Stars(x=x, y=y, size=size)
            games.screen.add(new_star)

        the_ship = Ship("first", 0, False)
        games.screen.add(the_ship)

        enemy_ship = EnemyShip()
        games.screen.add(enemy_ship)

        games.mouse.is_visible = False

        games.screen.event_grab = False

        games.screen.mainloop()
 def __init__(self, x=320, y=450):
     """Init Pan Object and create Text object for score"""  #New for 2.0
     super(Pan, self).__init__(image=Pan.image,
                               x=games.mouse.x,
                               y=games.mouse.y)
     self.score = games.Text(value=0, size=50, color=color.red, x=575, y=20)
     games.screen.add(self.score)
示例#14
0
    def __init__(self, y = 450):
        """ Initialize Pan object and create Text object for score. """
        super(Pan, self).__init__(image = Pan.image, x = games.mouse.x, y = y)

        self.score = games.Text(value = 0, size = 25, color = color.black, x = 575, y = 20)

        games.screen.add(self.score)
示例#15
0
    def __init__(self, x, y):
        NUM_BRICKS = 4
        brick_color = int(random.randrange(NUM_BRICKS))
        if brick_color == 0:
            new_brick = games.load_image("blue_brick.bmp")
        elif brick_color == 1:
            new_brick = games.load_image("green_brick.bmp")
        elif brick_color == 2:
            new_brick = games.load_image("red_brick.bmp")
        elif brick_color == 3:
            new_brick = games.load_image("yellow_brick.bmp")
        brick_image = new_brick
        self._surface = brick_image
        self._rect = self._surface.get_rect()
        self.position = (x, y)
        self._tickable = 0
        self._next = 0
        self._gone = 0

        self.score = games.Text(value=0,
                                size=50,
                                color=color.white,
                                top=750,
                                right=games.screen.width - 60)
        games.screen.add(self.score)
示例#16
0
class Koles(games.Sprite):
    #unikajacy zderzen sprzatacz
    image = games.load_image("Pics/koles.jpg")
    score = games.Text(value=0,
                       size=75,
                       color=color.pink,
                       top=5,
                       right=games.screen.width - 20)

    def __init__(self):
        super(Koles, self).__init__(image=Koles.image,
                                    x=games.mouse.x,
                                    bottom=games.screen.height)
        games.screen.add(self.score)

    def update(self):
        #zmien pozycje na wyznaczona przez wspolrzedna x myszy.
        self.x = games.mouse.x
        if self.left < 0:
            self.left = 0
        if self.right > games.screen.width:
            self.right = games.screen.width
        self.check_crash()

    def check_crash(self):
        #sprawdz, czy nie doszlo do kolizjii z papierem toaletowym
        for paper in self.overlapping_sprites:
            Papier.handle_crash(Papier)
示例#17
0
 def __init__(self, x, y, game):
     super(Player,
           self).__init__(x=x,
                          y=y,
                          image=games.load_image("hidden\\char.png"))
     self.game = game
     self.default_image = self.image
     self.x = x
     self.y = y
     self.y_vel = 0
     self.x_vel = 0
     self.falling = True
     self.xflipped = False
     self.jumped = False
     self.gravity = 1
     self.flop = False
     self.flopdown = 3
     self.spawncoord = []
     self.prevtime = time.time()
     self.paused = False
     self.pautime = 10
     self.oldtime = time.time()
     self.time = time.time()
     self.pausething = games.Sprite(
         x=-10000, y=-10000, image=games.load_image("hidden\\paused.png"))
     games.screen.add(self.pausething)
     if self.game.level != 1:
         self.text = games.Text(x=400,
                                y=50,
                                size=50,
                                color=color.red,
                                value=str(
                                    math.ceil(10 * self.flopdown) / 10))
         games.screen.add(self.text)
示例#18
0
 def __init__(self):
     # Initialise the net object and create text object for the score.
     super(Net, self).__init__( image=Net.image, x=games.mouse.x, \
         bottom=games.screen.height)
     self.score=games.Text(value=0, size=25, color=color.black,
     top=5, right=games.screen.width - 10)
     games.screen.add(self.score)
示例#19
0
 def __init__(self, game):
     self.spritelist = []
     super(Cursor,
           self).__init__(x=100,
                          y=200,
                          image=games.load_image("hidden\\select.png"))
     self.game = game
     self.levels = open("hidden\\levels.txt", "r").read()
     self.positions = {
         1: [100, 350],
         2: [250, 350],
         3: [400, 350],
         4: [550, 350],
         5: [700, 350]
     }
     for i in range(1, int(self.levels) + 1):
         thing = games.Sprite(x=self.positions[i][0],
                              y=self.positions[i][1],
                              image=games.load_image("hidden\\unbut.png"))
         self.spritelist.append(thing)
         games.screen.add(thing)
         text = games.Text(x=self.positions[i][0],
                           y=self.positions[i][1],
                           color=color.black,
                           size=80,
                           value=str(i))
         self.spritelist.append(text)
         games.screen.add(text)
     for i in range(int(self.levels) + 1, 6):
         thing = games.Sprite(x=self.positions[i][0],
                              y=self.positions[i][1],
                              image=games.load_image("hidden\\lobut.png"))
         self.spritelist.append(thing)
         games.screen.add(thing)
         text = games.Text(x=self.positions[i][0],
                           y=self.positions[i][1],
                           color=color.black,
                           size=80,
                           value=str(i))
         self.spritelist.append(text)
         games.screen.add(text)
     self.selected = 1
     self.cooldown = 0
     self.time = time.time()
     self.oldtime = time.time()
     self.levels = int(self.levels)
示例#20
0
 def __init__(self):
     super(Bar, self).__init__(image=Bar.bar, x=games.screen.width / 2, y=games.screen.height)
     self.score = games.Text(value=0,
                             size=60,
                             right=games.screen.width - 60,
                             top=20,
                             color=color.white)
     games.screen.add(self.score)
示例#21
0
 def __init__(self):
     super().__init__(image=Pan.image, x=games.mouse.x, bottom=480)
     self.score = games.Text(value=0,
                             size=25,
                             color=color.black,
                             top=5,
                             right=630)
     games.screen.add(self.score)
 def __init__(self, x, y):
     super(Ship, self).__init__(image=Ship.image, x=x, y=y)
     self.laser_wait = 0
     self.livesShow = games.Text(value=3,
                                 size=30,
                                 color=color.purple,
                                 top=5,
                                 right=games.screen.width - 10)
     games.screen.add(self.livesShow)
示例#23
0
 def __init__(self):
     """ Инициализирует объект Pan и создает объект Text для отображения
     счета. """
     super(Pan, self).__init__(image=Pan.image,
                              x=games.mouse.x,
                              bottom=games.screen.height)
     self.score = games.Text(value=0, size=25, color=color.black,
                             top=5, right=games.screen.width-10)
     games.screen.add(self.score)
示例#24
0
 def __init__(self):
     """ Initialize Pan object and create Text object for score. """
     super(Pan, self).__init__(image = Pan.image,
                               x = games.mouse.x,
                               bottom = games.screen.height - 50)
     
     self.score = games.Text(value = 0, size = 25, color = color.black,
                             top = 5, right = games.screen.width - 10)
     games.screen.add(self.score)
示例#25
0
 def __init__(self, screen, x, y):
     self.init_sprite(screen, x=x, y=y, image=Skillet.image)
     self.score_value = 0
     self.score_text = games.Text(screen=self.screen,
                                  x=650,
                                  y=20,
                                  text="Score: 0",
                                  size=25,
                                  colour=colour.black)
示例#26
0
    def __init__(self):
        super(Dno, self).__init__(image=Dno.image, left=0, bottom=480)

        self.score = games.Text(value=0,
                                size=25,
                                color=color.black,
                                top=5,
                                right=games.screen.width - 10)
        games.screen.add(self.score)
示例#27
0
 def __init__(self):
     
     super(Plant, self).__init__(image = Plant.image,
                               x = games.mouse.x,
                               bottom = games.screen.height)
     
     self.score = games.Text(value = 0, size = 25, color = color.black,
                             top = 5, right = games.screen.width - 10)
     games.screen.add(self.score)
示例#28
0
    def __init__(self):
        super().__init__(image=Paddle.image, x=20, y=games.mouse.y)

        self.score = games.Text(value=0,
                                size=25,
                                color=color.white,
                                top=20,
                                right=games.screen.width - 10)
        games.screen.add(self.score)
示例#29
0
    def __init__(self, duckType):     
        # Colors Available
        colors = [3, "black", "blue", "red"]
        duckColor = colors[duckType]
           
        # Sprites for the Duck
        self.flyRight = [3, games.load_image("Sprites/" + duckColor + "/duck1.png"), games.load_image("Sprites/" + duckColor + "/duck2.png"),
                            games.load_image("Sprites/" + duckColor + "/duck3.png")]
        
        self.flyStraightRight = [3, games.load_image("Sprites/" + duckColor + "/duck4.png"), games.load_image("Sprites/" + duckColor + "/duck5.png"),
                                    games.load_image("Sprites/" + duckColor + "/duck6.png")]

        self.flyLeft = [3, games.load_image("Sprites/" + duckColor + "/duck7.png"), games.load_image("Sprites/" + duckColor + "/duck8.png"),
                           games.load_image("Sprites/" + duckColor + "/duck9.png")]

        self.flyStraightLeft = [3, games.load_image("Sprites/" + duckColor + "/duck10.png"), games.load_image("Sprites/" + duckColor + "/duck11.png"),
                                   games.load_image("Sprites/" + duckColor + "/duck12.png")]

        self.die = [3, games.load_image("Sprites/" + duckColor + "/duckDie1.png"), games.load_image("Sprites/" + duckColor + "/duckDie2.png"),
                       games.load_image("Sprites/" + duckColor + "/duckDie3.png")]

        # Intialize Duck Sprite At Random X-Location
        super(Duck, self).__init__(image=self.flyRight[1], x=randint(10, 470), y=350, dx=0, dy=-1)
        
        # Point Values Based On Duck Color
        pointValues = {"blue": 25, "red": 50, "black": 75}
        
        # Direction Constants
        self.RIGHT = 1
        self.LEFT = 2
        
        # Duck Variables
        self.alive = True
        self.direction = randint(1, 2)
        self.straight = False # True if duck is flying straight
        self.points = pointValues[duckColor]
        
        # Animation Frames
        self.frames = [4, self.flyRight[2], self.flyRight[3], self.flyRight[2], self.flyRight[1]]
        
        # Points above the duck's head when it's shot
        self.deathScore = games.Text(value=str(self.points), size=25, x=self.x, y=self.top - 5, color=color.white)
        
        # Animation Variables
        self.dieDelay = 0 # Delay Duck Falling
        self.continueDeath = False
        self.animationCount = 0
        self.frame = 1 # What frame of the animation?
        self.directionCount = 0
        
        # Set velocity based on direction
        if self.direction == self.RIGHT:
            self.dx = .5
                   
        else:
            self.dx = -.5
示例#30
0
 def update(self):
     global reg, warn, test_var
     self.limitation()
     self.controls()
     self.check_ol()
     #warning of losing live
     if warn == True:
         Enemy_shoot.is_collideable = False
         reg += 1
         if reg == 30:
             self.new_image = games.load_image("media/bgspeedship.png")
             self.image = self.new_image
         elif reg == 60:
             self.new_image = games.load_image("media/temp_ship.bmp")
             self.image = self.new_image
         elif reg == 90:
             self.new_image = games.load_image("media/bgspeedship.png")
             self.image = self.new_image
         elif reg == 120:
             self.new_image = games.load_image("media/temp_ship.bmp")
             self.image = self.new_image
         elif reg == 150:
             self.new_image = games.load_image("media/bgspeedship.png")
             self.image = self.new_image
             warn = False
             reg = 0
             test_var = False
             Enemy_shoot.is_collideable = True
     #check for enemys
     self.list = games.screen.get_all_objects()
     if len(self.list) < 7 and warn == False and test_var == False:
         random_choice_enemys()
     if user_dies == 3 or len(list_of_lives) == 0:
         self.destroy()
         self.animation_main = Explosion(images=boom,
                                         x=self.x,
                                         y=self.y,
                                         repeat_interval=5,
                                         n_repeats=1,
                                         is_collideable=False)
         games.screen.add(self.animation_main)
         games.screen.clear()
         games.music.stop()
         self.game_over = Over(value="Game Over",
                               size=100,
                               color=color.white,
                               x=games.screen.width / 2,
                               y=games.screen.height / 2)
         self.user_total = games.Text(value='Your Score:' + str(score),
                                      size=100,
                                      color=color.white,
                                      x=games.screen.width / 2,
                                      y=(games.screen.height / 2) + 80,
                                      is_collideable=False)
         games.screen.add(self.game_over)
         games.screen.add(self.user_total)