示例#1
0
 def __init__(self, file='../data/sample.json'):
     # random var for now
     self.data = []
     self.file = file
     parser = JsonParser(file)
     self.collection = parser.get_collection()
     self.handler = InputHandler()
示例#2
0
    def instantMessageReceived(self, switchboard, message, contact):
        receivedText = message.getContent()
        #set the switchboard, so that we can send messages
        self.switchboard = switchboard

        #defines how we should handle the commands received from the other end
        input_handler = InputHandler()
        output = input_handler.handleInput(receivedText)
        #send the msg to the buddy
        msnMessage = MsnInstantMessage()
        msnMessage.setContent(output)
        self.sendMessage(msnMessage)
示例#3
0
 def setUp(self):
     pygame.init()  # @UndefinedVariable
     screen = pygame.display.set_mode((PRAM.DISPLAY_WIDTH, PRAM.DISPLAY_HEIGHT))
     buttonMap = ButtonMap()
     actor = SimpleBox()
     musicPlayer, soundPlayer = soundPlayerFactory()
     self.renderer = Renderer(screen)
     player = playerFactory(actor)
     
     self.game = Game(player, musicPlayer, soundPlayer, self.renderer)
     self.inputHandler = InputHandler(self.game, player, buttonMap)
     self.eventHandler = EventHandler(self.game)
     self.game.eventHandler = self.eventHandler
     self.game.inputHandler = self.inputHandler
示例#4
0
    def __init__(self, _meotech):

        print "Game - init >>>"

        # Meotech
        self.meotech = _meotech

        # Load Inputs
        self.inputs = InputHandler(self)

        # Add GameLoop Task
        taskMgr.add(self.gameLoop, "Game_loop")

        # Check the engine if we have a player.
        if self.meotech.engine.GameObjects["player"]:
            if self.meotech.engine.GameObjects["player"].useBasicMovement:
                self.hasPlayer = True

        else:
            self.hasPlayer = False
from game import Game
from input import InputHandler, ButtonMap
from camera import GameCamera
### SETUP ###
pygame.init()  # @UndefinedVariable
screen = pygame.display.set_mode((PRAM.DISPLAY_WIDTH, PRAM.DISPLAY_HEIGHT))
CLOCK = pygame.time.Clock()
DONE = False

### GAME ENGINE ###
musicPlayer, soundPlayer = soundPlayerFactory()
renderer = Renderer(screen)
gameCamera = GameCamera()
player = playerFactory()
game = Game(player, musicPlayer, soundPlayer, renderer, gameCamera)
inputHandler = InputHandler(game, player, ButtonMap())
eventHandler = eventHandlerFactory(game)
game.inputHandler = inputHandler

game.gameStartup()
while not DONE:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:  # @UndefinedVariable
            DONE = True  #TODO make this an input that creates a quit event?
        if event.type == pygame.KEYDOWN:  # @UndefinedVariable
            game.keydownEvents.append(event)
        #TODO can tell pygame to only check fro specific events
    game.keysPressed = pygame.key.get_pressed()

    inputHandler.handleInputs(
    )  #iterates through the keydown and keypressed events
示例#6
0
from input import InputHandler
from player import Player, player_data
from misc import *
from levels import Level, ObjectHandler
from level_data import levels

FPS = 60
clock = time.Clock()
game_input = InputHandler()
GAME_STATES = ['start', 'levels', 'game_over']


class Game:
    def __init__(self, _screen):
        self.screen = _screen
        self.running = True
        self.object_handler = ObjectHandler(self.screen)
        self.score = 0
        self.pt = time.get_ticks()
        self.game_state = GAME_STATES[0]
        self.game_levels = []
        self.current_level = 0
        self.player = None

    def main(self, _screen):
        # Set Up Delta Time
        dt = time.get_ticks() - self.pt
        dt *= FPS
        self.pt = time.get_ticks()

        # Run Game
示例#7
0
    def __init__(self, surface: pygame.Surface) -> None:
        self.notes = {
            0 : Note("G", 0, "./data/Sounds/G1.ogg"),
            1 : Note("G#", 0, "./data/Sounds/G#1.ogg"),
            2 : Note("A", 0.5, "./data/Sounds/A1.ogg"),
            3 : Note("A#", 0.5, "./data/Sounds/A#1.ogg"),
            4 : Note("B", 1, "./data/Sounds/B1.ogg"),
            5 : Note("C", 1.5, "./data/Sounds/C1.ogg"),
            6 : Note("C#", 1.5, "./data/Sounds/C#1.ogg"),

            7 : Note("D", 2, "./data/Sounds/D2.ogg"),
            8 : Note("D#", 2, "./data/Sounds/D#2.ogg"),
            9 : Note("E", 2.5, "./data/Sounds/E2.ogg"),
            10 : Note("F", 3, "./data/Sounds/F2.ogg"),
            11 : Note("F#", 3, "./data/Sounds/F#2.ogg"),
            12 : Note("G", 3.5, "./data/Sounds/G2.ogg"),
            13 : Note("G#", 3.5, "./data/Sounds/G#2.ogg"),

            14 : Note("A", 4, "./data/Sounds/A3.ogg"),
            15 : Note("A#", 4, "./data/Sounds/A#3.ogg"),
            16 : Note("B", 4.5, "./data/Sounds/B3.ogg"),
            17 : Note("C", 5, "./data/Sounds/C3.ogg"),
            18 : Note("C#", 5, "./data/Sounds/C#3.ogg"),
            19 : Note("D", 5.5, "./data/Sounds/D3.ogg"),
            20 : Note("D#", 5.5, "./data/Sounds/D#3.ogg"),

            21 : Note("E", 6, "./data/Sounds/E4.ogg"),
            22 : Note("F", 6.5, "./data/Sounds/F4.ogg"),
            23 : Note("F#", 6.5, "./data/Sounds/F#4.ogg"),
            24 : Note("G", 7, "./data/Sounds/G4.ogg"),
            25 : Note("G#", 7, "./data/Sounds/G#4.ogg"),
            26 : Note("A", 7.5, "./data/Sounds/A4.ogg"),
            27 : Note("A#", 7.5, "./data/Sounds/A#4.ogg"),
            28 : Note("B", 8, "./data/Sounds/B4.ogg"),

            #G string
            29 : Note("D", 2, "./data/Sounds/D1.ogg"),
            #D String
            30 : Note("A", 4, "./data/Sounds/A2.ogg"),
            #A String
            31 : Note("E", 6, "./data/Sounds/E3.ogg"),
        }
        
        self.surface = surface

        self.font = self.font = pgfont.Font(pgfont.get_default_font(), 20)
        
        self.is_running = True
        self.fps = 60

        self.input_handler = InputHandler()

        self.staff = Staff(self.surface)
        self.finger_board = FingerBoard(self.surface, self.input_handler)

        self.deck = NoteDeck()
        self.deck.shuffle()

        self.score = 0
        self.max_score = 0
        self.current_note = self.deck.next_note()
        self.staff.set_note(self.notes[self.current_note])

        self.playing_note = self.notes[0]

        self.success_message = ""
示例#8
0
camera.setup()

model_data = model.StaticModelData()
model_data.setup()  # Everybody do the setup shake!

# I seriously thing something is wrong with me, putting in all these random comments and strings and stuff.
# Oh well

clock = pygame.time.Clock()

pygame.mouse.set_pos(config.window_info.window_size[0] / 2,
                     config.window_info.window_size[1] / 2)

user = User(model.geom_data["spawn"], camera, model_data)

input_handler = InputHandler(user)

hud = hud.HUD(model_data)

scripter = ScriptHolder(model_data, user)
scripter.load("script.txt")

while True:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    user.update_camera()
    camera.apply()
    model_data.draw()
    model_data.setup_price_labels(user)
    hud.apply(user)
    for event in pygame.event.get():
        if event.type == pygame.QUIT: