Exemple #1
0
 def __init__(self, image_name):
     super().__init__(image=games.load_image(image_name),
                      x=games.screen.width / 2,
                      y=SOURCE_SPRITE["resolution"][1] / 2,
                      dx=sprite_speed() + 2)
     self.time_before_next_sprite = 0
     self.start = int(FPS / 2)
Exemple #2
0
 def __init__(self, x):
     self.name_of_image = random.choice(Bomb.list_of_sprites)
     super().__init__(image=games.load_image(self.name_of_image),
                      x=x,
                      y=int(BOMBS["resolution"][1] / 2 +
                            SOURCE_SPRITE["resolution"][1] / 2))
     self.dy = sprite_speed()
     Bomb.in_game = True
Exemple #3
0
def init_game():
    os.environ['SDL_VIDEO_CENTERED'] = '1'
    games.init(screen_width=RESOLUTION[0],
               screen_height=RESOLUTION[1],
               fps=FPS,
               title="Nuclear Shield",
               icon="assets/sprites/nuclear_mini.png")
    main_theme = games.load_image(background(), transparent=False)
    games.screen.background = main_theme
    main_platform = Platform(PLATFORM["image"])
    games.screen.add(main_platform)
    ufo = UFO(SOURCE_SPRITE["image"])
    games.screen.add(ufo)
    games.mouse.is_visible = False
    games.screen.event_grab = True
    Bomb.in_game = True
    games.screen.mainloop()
    main_platform.main_sound.stop()
Exemple #4
0
 def __init__(self, image_name):
     super().__init__(image=games.load_image(image_name),
                      x=games.screen.width / 2,
                      y=games.screen.height - 200)
     self.text_score = games.Text(value="0" + "$",
                                  size=int(games.screen.width / 17),
                                  color=color.black,
                                  top=5,
                                  right=int(games.screen.width - 10))
     games.screen.add(self.text_score)
     games.screen.add(
         games.Text(value="For quit press q",
                    size=int(games.screen.width / 40),
                    color=color.black,
                    top=5,
                    left=5))
     self.main_sound = games.load_sound(MAIN_SOUND)
     self.main_sound.play()
Exemple #5
0
    return pygame.image.fromstring(data, size, mode)
'''

pygame.init()

FPS = 30  # frames per second setting
fpsClock = pygame.time.Clock()

# set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32)
pygame.display.set_caption('Animation')

WHITE = (255, 255, 255)

#catImg = pygame.image.load('cat.png')
catImg = game_lib.load_image('cat.png')
catx = 10
caty = 10
direction = 'right'

while True:  # the main game loop
    DISPLAYSURF.fill(WHITE)

    if direction == 'right':
        catx += 5
        if catx == 280:
            direction = 'down'
    elif direction == 'down':
        caty += 5
        if caty == 220:
            direction = 'left'
Exemple #6
0
    return pygame.image.fromstring(data, size, mode)
'''

pygame.init()

FPS = 30 # frames per second setting
fpsClock = pygame.time.Clock()

# set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32)
pygame.display.set_caption('Animation')

WHITE = (255, 255, 255)

#catImg = pygame.image.load('cat.png')
catImg = game_lib.load_image('cat.png')
catx = 10
caty = 10
direction = 'right'

while True: # the main game loop
    DISPLAYSURF.fill(WHITE)

    if direction == 'right':
        catx += 5
        if catx == 280:
            direction = 'down'
    elif direction == 'down':
        caty += 5
        if caty == 220:
            direction = 'left'