コード例 #1
0
from player import Player
from Bullet import Bullet
from mob import Mob
from Mob2 import Mob2
from Mob3 import Mob3
from Rasengan import Rasengan, Power
from screen import init_screen
from game import game_screen

# Inicialização do Pygame.
pygame.init()
pygame.mixer.init()

# Tamanho da tela.
screen = pygame.display.set_mode((WIDTH, HEIGHT))

# Nome do jogo
pygame.display.set_caption("Naruto Run")

# Comando para evitar travamentos.
try:
    state = INIT
    while state != QUIT:
        if state == INIT:
            state = init_screen(screen)
        elif state == GAME:
            state = game_screen(screen)
        else:
            state = QUIT
finally:
    pygame.quit()
コード例 #2
0
ファイル: main.py プロジェクト: henrik645/overworld
"""
This file contains the main loop of the program
"""

import time
import curses

import screen
import world
import player

stdscr = screen.init_screen()

screen_width = 40
screen_height = 20

level = world.Level(screen_width, screen_height)
player = player.Player(10, 10, 5, 5)

while True: #Main loop
    screen.update_screen(stdscr, level, player)
    key = stdscr.getch()
    if key == curses.KEY_UP:
        if player.y_pos > 0:
            player.y_pos -= 1
    elif key == curses.KEY_DOWN:
        if player.y_pos < screen_height - 1: #Minus once since coordinates start at 0 instead of 1
            player.y_pos += 1
    elif key == curses.KEY_LEFT:
        if player.x_pos > 0:
            player.x_pos -= 1