def main():
    utility.set_config_file(CONFIG_DIRECTORY)
    
    width = int(utility.get_config_value('width', DEF_WINDOW_W))
    height = int(utility.get_config_value('height', DEF_WINDOW_H))
    title = utility.get_config_value('title', DEF_TITLE)
    depth = int(utility.get_config_value('depth', DEF_DEPTH))
    mode = int(utility.get_config_value('mode', DEF_MODE))
           
    if not pygame.display.get_init():
        print 'Could not initialize display screen'
        sys.exit()

    depth = pygame.display.mode_ok((width, height), mode, depth)   
    
    # Create our screen window
    screen = pygame.display.set_mode((width, height), mode, depth)    
    pygame.display.set_caption(title)


    # Create Stages
    stageOne = stages.StageOne(screen)

    
    # Create game objects
    shipSprite = ship.MiGX3(screen)
    
    


        
    clock = pygame.time.Clock()
    keepGoing = True
    while keepGoing:
        clock.tick(30)
        pygame.mouse.set_visible(False)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                keepGoing = False

        stageOne.update()
        stageOne.draw(screen)
            
        pygame.display.flip()
def init():
    """
        Initialize pygame, utility, and the game (slot machine). The game is installed by grabbing
        config values from the configuration file. All buttons images are loaded into the Resource class
        and the event handler functions are set.
    """
    pygame.init()    
    utility.init()    

    # Load Settings via Configuration File 
    utility.set_config_file('config/config.cfg')
    
    width = int(utility.get_config_value('width', 640))
    height = int(utility.get_config_value('height', 480))
    depth = int(utility.get_config_value('depth', 0))
    mode = int(utility.get_config_value('mode', 0))
    title = utility.get_config_value('title', '')
    fps = float(utility.get_config_value('fps', 30.0))
    
    screen = pygame.display.set_mode([width, height], mode, depth)
    pygame.display.set_caption(title)

    Resource.normalReel = pygame.image.load('imgs/reel_normal.png')
    Resource.blurReel = pygame.image.load('imgs/reel_blur.png')
    Resource.slotMachine = pygame.image.load('imgs/slot_machine.png')
    
    Resource.redButton = pygame.image.load('imgs/red_button.png')
    Resource.blueButton = pygame.image.load('imgs/blue_button.png')
    Resource.greenButton = pygame.image.load('imgs/green_button.png')
    Resource.purpleButton = pygame.image.load('imgs/purple_button.png')
    Resource.blackButton = pygame.image.load('imgs/black_button.png')
    
    # Initialize the Slot Machine
    slotmachine = SlotMachine(Resource.slotMachine)
    quitButton = Button(630, 50, 60, 60, 'Quit', Resource.redButton)
    quitButton.setOnHoverListener(ExEventHandler.quit_button_hover_listener)
    quitButton.setOnPressListener(ExEventHandler.quit_button_press_listener)
    quitButton.setOnReleaseListener(ExEventHandler.quit_button_release_listener)
    slotmachine.addComponent(quitButton)
    
    resetButton = Button(731, 52, 60, 60, 'Reset', Resource.redButton)
    resetButton.setOnHoverListener(ExEventHandler.reset_button_hover_listener)
    resetButton.setOnPressListener(ExEventHandler.reset_button_press_listener)
    resetButton.setOnReleaseListener(ExEventHandler.reset_button_release_listener)
    slotmachine.addComponent(resetButton)
       
    spinButton = Button(420, 495, 60, 60, 'Spin', Resource.greenButton)
    spinButton.setOnHoverListener(ExEventHandler.spin_button_hover_listener)
    spinButton.setOnPressListener(ExEventHandler.spin_button_press_listener)
    spinButton.setOnReleaseListener(ExEventHandler.spin_button_release_listener)
    slotmachine.addComponent(spinButton)

    betButton = Button(320, 495, 60, 60, 'Bet', Resource.blueButton)
    betButton.setOnHoverListener(ExEventHandler.bet_button_hover_listener)
    betButton.setOnPressListener(ExEventHandler.bet_button_press_listener)
    betButton.setOnReleaseListener(ExEventHandler.bet_button_release_listener)
    slotmachine.addComponent(betButton)
    
    return slotmachine, screen, fps
    
"""

""" Import and Initialize """
import pygame, utility, sys, random, resource
from resource import *


pygame.init()
utility.init()
resource.init()

""" Read configuration file """
utility.set_config_file(CONFIG_DIRECTORY)
    
width = int(utility.get_config_value('width', 800))
height = int(utility.get_config_value('height', 600))
title = utility.get_config_value('title', 'War Thunder by Justin Hellsten')
depth = int(utility.get_config_value('depth', 32))
mode = int(utility.get_config_value('mode', 0))

if not pygame.display.get_init():
    print 'Could not initialize display screen'
    sys.exit()

#Check if depth is okay for display mode
depth = pygame.display.mode_ok((width, height), mode, depth)  
    
# Create our screen window
screen = pygame.display.set_mode((width, height), mode, depth)    
pygame.display.set_caption(title)
Exemple #4
0
def init():
    """
        Initialize pygame, utility, and the game (slot machine). The game is installed by grabbing
        config values from the configuration file. All buttons images are loaded into the Resource class
        and the event handler functions are set.
    """
    pygame.init()
    utility.init()

    # Load Settings via Configuration File
    utility.set_config_file('config/config.cfg')

    width = int(utility.get_config_value('width', 640))
    height = int(utility.get_config_value('height', 480))
    depth = int(utility.get_config_value('depth', 0))
    mode = int(utility.get_config_value('mode', 0))
    title = utility.get_config_value('title', '')
    fps = float(utility.get_config_value('fps', 30.0))

    screen = pygame.display.set_mode([width, height], mode, depth)
    pygame.display.set_caption(title)

    Resource.normalReel = pygame.image.load('imgs/reel_normal.png')
    Resource.blurReel = pygame.image.load('imgs/reel_blur.png')
    Resource.slotMachine = pygame.image.load('imgs/slot_machine.png')

    Resource.redButton = pygame.image.load('imgs/red_button.png')
    Resource.blueButton = pygame.image.load('imgs/blue_button.png')
    Resource.greenButton = pygame.image.load('imgs/green_button.png')
    Resource.purpleButton = pygame.image.load('imgs/purple_button.png')
    Resource.blackButton = pygame.image.load('imgs/black_button.png')

    # Initialize the Slot Machine
    slotmachine = SlotMachine(Resource.slotMachine)
    quitButton = Button(630, 50, 60, 60, 'Quit', Resource.redButton)
    quitButton.setOnHoverListener(ExEventHandler.quit_button_hover_listener)
    quitButton.setOnPressListener(ExEventHandler.quit_button_press_listener)
    quitButton.setOnReleaseListener(
        ExEventHandler.quit_button_release_listener)
    slotmachine.addComponent(quitButton)

    resetButton = Button(731, 52, 60, 60, 'Reset', Resource.redButton)
    resetButton.setOnHoverListener(ExEventHandler.reset_button_hover_listener)
    resetButton.setOnPressListener(ExEventHandler.reset_button_press_listener)
    resetButton.setOnReleaseListener(
        ExEventHandler.reset_button_release_listener)
    slotmachine.addComponent(resetButton)

    spinButton = Button(420, 495, 60, 60, 'Spin', Resource.greenButton)
    spinButton.setOnHoverListener(ExEventHandler.spin_button_hover_listener)
    spinButton.setOnPressListener(ExEventHandler.spin_button_press_listener)
    spinButton.setOnReleaseListener(
        ExEventHandler.spin_button_release_listener)
    slotmachine.addComponent(spinButton)

    betButton = Button(320, 495, 60, 60, 'Bet', Resource.blueButton)
    betButton.setOnHoverListener(ExEventHandler.bet_button_hover_listener)
    betButton.setOnPressListener(ExEventHandler.bet_button_press_listener)
    betButton.setOnReleaseListener(ExEventHandler.bet_button_release_listener)
    slotmachine.addComponent(betButton)

    return slotmachine, screen, fps
    
"""

""" Import and Initialize """
import pygame, utility, sys, random, resource
from resource import *


pygame.init()
utility.init()
resource.init()

""" Read configuration file """
utility.set_config_file(CONFIG_DIRECTORY)

width = int(utility.get_config_value("width", 800))
height = int(utility.get_config_value("height", 600))
title = utility.get_config_value("title", "War Thunder by Justin Hellsten")
depth = int(utility.get_config_value("depth", 32))
mode = int(utility.get_config_value("mode", 0))

if not pygame.display.get_init():
    print "Could not initialize display screen"
    sys.exit()

# Check if depth is okay for display mode
depth = pygame.display.mode_ok((width, height), mode, depth)

# Create our screen window
screen = pygame.display.set_mode((width, height), mode, depth)
pygame.display.set_caption(title)