def __init__(self): """Initialize the game, and create game resources.""" pygame.__init__("Alien Invasion") self.settings = Settings() self.screen = pygame.display.set_mode( (self.settings.screen_width, self.settings.screen_height)) pygame.display.set_caption("Alien Invasion by brkavci") self.ship = Ship(self) self.ship2 = Ship(self) self.ship2.image = pygame.image.load('images/ships/black_hawk.bmp') self.ship2.rect.topleft = self.ship.rect.topright self.ship2.rect.centerx += 20 self.ship3 = Ship(self) self.ship3.image = pygame.image.load('images/ships/blue_rocket.bmp') self.ship3.rect.topleft = self.ship2.rect.topright self.ship3.rect.centerx += 20 self.ship4 = Ship(self) self.ship4.image = pygame.image.load('images/ships/ghost.bmp') self.ship4.rect.topleft = self.ship3.rect.topright self.ship4.rect.centerx += 20 self.ship5 = Ship(self) self.ship5.image = pygame.image.load('images/ships/military.bmp') self.ship5.rect.topleft = self.ship4.rect.topright self.ship5.rect.centerx += 20 self.ship6 = Ship(self) self.ship6.image = pygame.image.load('images/ships/russian.bmp') self.ship6.rect.topleft = self.ship5.rect.topright self.ship6.rect.centerx += 30
def display_init(self): """Set up the Pygame parts of the world object, and the control vars""" # Pygame setup pygame.__init__("world") self.exit = False self.display = pygame.display.set_mode((self.x*10, self.y*10)) pygame.display.set_caption("Alife program") self.clock = pygame.time.Clock()
def main(): pygame.__init__(GAME_NAME) screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) screen.fill(WHITE) villager_images = [] for image in VILLAGER_IMAGES: villager_images.append(pygame.image.load(image)) #message_image = pygame.image.load(MESSAGE_IMAGE) monster_image = None clock = pygame.time.Clock() villager_connections = [] listener = ConnectionListener(villager_connections) listener.start() start_game(screen, villager_images, monster_image, clock, villager_connections) listener.close_socket()
def __init__(self): self.w = 750 self.h = 500 self.reset = True self.active = False self.input_text = '' self.word = '' self.time_start = 0 self.total_time = 0 self.accuracy = '0%' self.results = 'Time:0 Accuracy:0 % Wpm:0 ' self.wpm = 0 self.end = False self.HEAD_C = (255, 213, 102) self.TEXT_C = (240, 240, 240) self.RESULT_C = (255, 70, 70) pygame.__init__() # initialized pygame and load images self.open_img = pygame.image.load('type-speed-open.png') self.open_img = pygame.transform.scale(self.open_img, (self.w, self.h)) self.bg = pygame.image.load('background.jpg') self.bg = pygame.transform.scale(self.bg, (500, 750)) self.screen = pygame.display.set_mode((self.w, self.h)) pygame.display.set_caption('Type Speed test')
def __init__(self, width: int = 7, height: int = 7) -> None: """Construct MiniMap. Args: width: The tile width of the map (default=7). height: The tile height of the map (default=7). """ self.WIDTH = width self.HEIGHT = height self.MWIDTH = TSIZE * self.WIDTH self.MHEIGHT = TSIZE * self.HEIGHT self._pos_x = None # int: The current -x location of the Player. self._pos_y = None # int: The current -y location of the Player. # Setup the necessary pygame modules pygame.__init__("display") pygame.__init__("event") pygame.__init__("draw")
# -*- coding: utf-8 -*- import time import pygame pygame.__init__() screen = pygame.display.set_mode([640, 480]) pygame.display.set_caption('Olá mundo') screen.fill([0, 0, 0]) pygame.display.flip() time.sleep(5)
def __init__(self, serverURL, serverPort, mode): self.server = serverURL self.port = serverPort pygame.__init__("DDD Client") self.screen = pygame.display.set_mode(self.SIZE) pygame.display.toggle_fullscreen()
import pygame, socket import time, pickle """ BLACK = (0, 0, 0) WHITE = (255, 255, 255) SIZE = (1366/2, 768/2) pygame.__init__('This is fun') screen = pygame.display.set_mode(SIZE) startFlag = False while startFlag == False and False: for event in pygame.event.get(): if event.type == pygame.KEYDOWN and event.key == pygame.K_d: print "Detected keydown", event.key, pygame.K_d startFlag = True while True and False: screen.fill(WHITE) pygame.display.flip() time.sleep(0.3) screen.fill(BLACK) pygame.display.flip() time.sleep(0.3) """ class FlashClient(object): BLACK = (0, 0, 0)