def __init__(self): self.window = Window(globais.WIDTH, globais.HEIGHT) self.mouse = Mouse() self.teclado = Keyboard() self.tela = Tela(window)
from menu import Menu from play import Play from dificuldade import Dificuldade from PPlay.window import Window import globais janela = Window(globais.WIDTH, globais.HEIGHT) janela.set_title("Space Invadors") janela.set_background_color((0, 0, 0)) menu = Menu(janela) play = Play(janela) dificuldade = Dificuldade(janela) while globais.JOGO_RODANDO: janela.set_background_color((0, 0, 0)) if (globais.PAGINA_ATUAL == 0): menu.setMenu() elif (globais.PAGINA_ATUAL == 1): play.setPlay() elif (globais.PAGINA_ATUAL == 2): dificuldade.setDificuldade() janela.update()
from PPlay.window import Window import binary_break.globals as globals from binary_break.screens.menu import Menu window = Window(842, 700) keyboard = window.get_keyboard() globals.window = window globals.difficulty = 1 globals.backgroundColor = (10, 11, 56) globals.game_speed = 1 globals.currentContainer = Menu() while True: globals.delta_time = window.delta_time() globals.currentContainer.render() window.update()
import os # --------------- Global variables ------------------------------- game_state = 2 # Game starts showing menu # Set display background = GameImage('sprite/scenario/scenarionew.png') menu_bg = GameImage('sprite/scenario/start1.png') game_over = GameImage('sprite/scenario/GameOver1.png') button = GameImage('sprite/scenario/button1.png', 0, -140) # Define screen variables sWidth = 512 # screen width sHeight = 512 # screen height window = Window(sWidth, sHeight) window.set_title('Snowie Game') # Managing points and health score_manager = ScoreManager() # Stores high score and last score scorer = Scorer(window) # Calculates points and health record_checked = False # Define branch variables branchHeight = 64 treeHeight = GameImage('sprite/branches/middle.png').get_height() # Define snowman variables snowmanDist = 45 # Changes distance from tree snowmanY = sHeight - 80 # Distance from bottom of screen flakeDist = 50 # Flake distance from tree
def main(): HEIGHT = 600 WIDTH = 800 VEL_X = 200 VEL_Y = 200 window = Window(WIDTH, HEIGHT) keyboard = Keyboard() ball = Sprite("./assets/ball.png") ball.set_position((window.width / 2 - ball.width / 2), (window.height / 2 - ball.height / 2)) bat_player = Sprite("./assets/bat.png") bat_player.set_position(15, (window.height / 2 - bat_player.height / 2)) bat_npc = Sprite("./assets/bat.png") bat_npc.set_position((window.width - 15) - bat_npc.width, (window.height / 2 - bat_npc.height / 2)) game_started = False player_score = 0 npc_score = 0 window.set_background_color((0, 0, 0)) window.draw_text("{} {}".format(player_score, npc_score), window.width / 2, 15, 25, (255, 255, 255)) ball.draw() bat_player.draw() bat_npc.draw() while True: # to start the game if keyboard.key_pressed("space") or game_started: ball.x += (VEL_X * window.delta_time()) ball.y += (VEL_Y * window.delta_time()) game_started = True # scoring and reset after left and right window collision if (ball.x < 0) or (ball.x + ball.width > window.width): if ball.x < 0: npc_score += 1 elif ball.x + ball.width > window.width: player_score += 1 ball.set_position((window.width / 2 - ball.width / 2), (window.height / 2 - ball.height / 2)) bat_player.set_position( 15, (window.height / 2 - bat_player.height / 2)) bat_npc.set_position((window.width - 15) - bat_npc.width, (window.height / 2 - bat_npc.height / 2)) game_started = False window.set_background_color((0, 0, 0)) window.draw_text("{} {}".format(player_score, npc_score), window.width / 2, 15, 25, (255, 255, 255)) ball.draw() bat_player.draw() bat_npc.draw() window.update() continue # bottom and top window collision if ball.y < 0: VEL_Y *= -1 ball.set_position(ball.x, ball.y + 1) elif ball.y + ball.height > window.height: VEL_Y *= -1 ball.set_position(ball.x, ball.y - 1) # bat collision if bat_player.collided(ball): VEL_X *= -1 ball.set_position(ball.x + 1, ball.y) elif bat_npc.collided(ball): VEL_X *= -1 ball.set_position(ball.x - 1, ball.y) # controls if keyboard.key_pressed("up") and bat_player.y > 15: bat_player.y -= 0.5 if (keyboard.key_pressed("down") and (bat_player.y + bat_player.height < window.height - 15)): bat_player.y += 0.5 # AI if (ball.y < window.height / 2 and bat_npc.y > 15 and game_started): bat_npc.y -= 0.5 elif (ball.y > window.height / 2 and bat_npc.y + bat_npc.height < window.height - 15 and game_started): bat_npc.y += 0.5 # reset window.set_background_color((0, 0, 0)) window.draw_text("{} {}".format(player_score, npc_score), window.width / 2, 15, 25, (255, 255, 255)) ball.draw() bat_player.draw() bat_npc.draw() window.update()
from PPlay.sprite import Sprite from PPlay.animation import Animation from PPlay.window import Window from posicoesTeste import Posicoes from PPlay.keyboard import Keyboard import globais janela = Window(800, 600) janela.set_title('teste') janela.set_background_color((0, 0, 0)) posicoes = Posicoes(janela) teclado = Keyboard() posicoes.setUpdate() while (True): janela.set_background_color((0, 0, 0)) if (teclado.key_pressed("UP")): globais.STATUS_PERSONAGEM = 4 posicoes.getUpdate() janela.update()
from PPlay.window import Window from PPlay.gameimage import GameImage from arvore import Arvore from bodybuilder import BodyBuilder from pontuador import Pontuador from highscoremanager import ScoreManager janela = Window(512, 512) janela.set_title('TimberBAM') background = GameImage('sprite/cenario/cenarionew.png') menu_bg = GameImage('sprite/cenario/start.png') botao_inicial = GameImage('sprite/cenario/botao.png') tela_final = GameImage('sprite/cenario/GAMEOVER.png') score_manager = ScoreManager() teclado = janela.get_keyboard() arvore = Arvore(janela) bambam = BodyBuilder(janela, 'esquerda') pontuador = Pontuador(janela) teclado_pressionado = False record_checked = False game_state = 2 # 0 - JOGANDO 1 - GAME-OVER 2- IN-MENU while True: if game_state == 0: if teclado.key_pressed('left') or teclado.key_pressed('right'): if not teclado_pressionado:
from invaders.screens.menu import Menu from PPlay.window import Window import invaders.settings as settings window = Window(800, 600) keyboard = window.get_keyboard() settings.current_container = Menu(window) settings.difficulty = 1 settings.backgroundColor = (33, 33, 33) settings.game_speed = 3 while True: settings.delta_time = window.delta_time() settings.current_container.render() window.update()