Ejemplo n.º 1
0
    def __init__(self):
        """Initialize the game, create game resources."""
        pygame.init()
        self.settings = Settings()

        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Alien Invasion")

        # Create an instance to store game stats and create a scoreboard
        self.stats = GameStats(self)
        self.sb = Scoreboard(self)

        self.ship = Ship(self)
        self.bullets = pygame.sprite.Group()
        self.aliens = pygame.sprite.Group()

        self._create_fleet()

        # Make the title banner and play button
        self.play_button = Button(self, "START")
        self.title_banner = Banner(self, "Alien Invasion")

        # Make a countdown object for displaying count on game start / new ship
        self.countdown = Countdown(self)

        # Make an object for a banner displaying "GAME OVER" when no ships
        # remain
        self.gameover = GameOver(self)
Ejemplo n.º 2
0
    def __init__(self, modes):
        GPIO.setmode(
            GPIO.BCM)  #set up to use gpio port numbers (instead of pin #s)

        self.buttons = Buttons()
        self.optos = Optos()
        self.lights = Lights()
        self.outlets = Outlets()
        self.sounds = Sounds()
        self.clock = Countdown(12)

        self.modes = modes
        self.last_time = time.localtime()
def main():
    subprocess.Popen(['pixlet', 'serve', 'build/display.star', '--watch'],
        shell=False, stdin=None, stdout=None, stderr=None, close_fds=False)
    print('here')
    disp = [
        Countdown(
            arrow.get('2022-05-15 10:00:00'),
            'AP Physics Exam',
            MAKO_DIR / 'countdown.star.mako',
            BUILD_DIR / 'display.star')
    ]

    while True:
        disp[0].render()

        time.sleep(60)
Ejemplo n.º 4
0
    def levelUp(self):
        #set the current level
        self.levelcnt += 1
        self.curLevel = Level(self.levelcnt)  #create a new level

        self.player.__init__()
        #load level
        self.curLevel.loadLevel()
        self.levelRows, self.levelCols = self.curLevel.levelRows, self.curLevel.levelCols
        self.playerStartRow, self.playerStartCol = self.curLevel.playerStartRow, self.curLevel.playerStartCol
        self.targetRow, self.targetCol = self.curLevel.targetRow, self.curLevel.targetCol
        self.walls = self.curLevel.walls
        self.iceNum = self.curLevel.iceNum
        self.switches = self.curLevel.switches
        self.levelMin, self.levelSec = self.curLevel.levelMin, self.curLevel.levelSec
        self.countdown = Countdown(self.levelMin, self.levelSec)
        self.iceMelted = 0
        self.keyObtained = False

        #level loaded; set player data
        self.player.setPos(self.playerStartRow, self.playerStartCol)
        self.player.setBoundaries(self.walls)
        self.player.setTargetPos(self.targetRow, self.targetCol)
        if self.curLevel.hasKey: self.player.setDoorLock(self.curLevel.lockPos)
Ejemplo n.º 5
0
        s = Stopwatch(w, stopwatch_lap_count, stopwatch_current_time, stopwatch_lap)
    except:
        # Initial the class of Stopwatch
        s = Stopwatch(w)
    
    try:
        # Read the operation history of countdown
        countdown_history = open(os.path.abspath(os.path.dirname(__file__)) + '/save/countdown_save.bin', 'rb')
        countdown_lines = countdown_history.readlines()
        countdown_set_time = countdown_lines[0].decode().strip('\n').split(':')
        countdown_current_time = countdown_lines[1].decode().split(':')
        for i in range(0, len(countdown_set_time)):
            countdown_set_time[i] = int(countdown_set_time[i])
            countdown_current_time[i] = int(countdown_current_time[i])
        # Initial the class of Countdown
        c = Countdown(w, countdown_set_time, countdown_current_time)
    except:
        # Initial the class of Countdown
        c = Countdown(w)

    # Declare timer for stopwatch and countdown
    w.stopwatch_timer = QTimer()
    w.countdown_timer = QTimer()

    # Load beep voice
    w.beep_sound = QSound(os.path.abspath(os.path.dirname(__file__)) + '/sound/Old-clock-ringing-sound-effect.wav')
    w.beep_sound.setLoops(10)

    # Connect to slot function of about widget
    w.actionAbout.triggered.connect(lambda: actionAbout(w_about))
Ejemplo n.º 6
0
    def __init__(self):
        # initialize the pygame module
        pygame.init()

        logo_name = os.path.join('assets', "logo.png")
        logo = pygame.image.load(logo_name)
        pygame.display.set_icon(logo)

        pygame.display.set_caption("Escape")
        self.screen = pygame.display.set_mode(SCREEN_SIZE)
        self.black_surface = self.screen.copy()
        self.black_surface.fill(pygame.Color("black"))

        # default font used for the timer
        self.font = pygame.font.Font(None, 100)
        self.subtext_font = pygame.font.Font(None, 25)
        self.notification_font = pygame.font.Font(None, 25)

        # specifies the middle of the screen
        self.character = Character("avatar/MC-front.png", 0, 0)
        self.camera = Coords(CHARACTER_START[X], CHARACTER_START[Y])

        # saves the camera for when enering the building
        self.camera_save = None
        self.user_input = UserInput()

        # sound
        self.ambient = pygame.mixer.Sound("assets/ambient.wav")
        self.ambient_channel = pygame.mixer.Channel(1)
        self.wind = pygame.mixer.Sound("assets/wind.wav")
        self.wind.play(-1)

        # a shit ton of time related stuff
        self.clock = pygame.time.Clock()
        self.countdown = Countdown()
        self.ticker = Ticker()
        self.fade_in_timer = Timer()
        self.display_timer = Timer()
        self.notification_timer = Timer()
        self.fade_out_timer = Timer()

        # variables for when you're in some building
        self.current_building = None
        self.buildings = create_buildings()
        self.well_area = ScaledRect(208, 354, 60, 51)

        # define a variable to control the main loop
        # where it is really only set to false if the player exits or the X button is pressed
        self.running = True
        self.state = None
        self.fade_into_main_menu()

        self.wins = create_wins()
        self.subtext_value = ""
        self.notification_value = ""

        # self.ended = False
        # self.show_ending = False

        self.end_image = None
        self.begin_image = load_image("beginlol.png",
                                      use_scale=False,
                                      return_rect=False)
        self.begin_image = pygame.transform.scale(self.begin_image,
                                                  SCREEN_SIZE)

        self.default_background = load_image('background.png',
                                             return_rect=False)
        self.building_wall_mask = load_image('background_outline.png',
                                             convert_alpha=True,
                                             return_rect=False)

        # background can change to default background or house background
        self.background = self.default_background

        # creates the start menus
        self.pause_menu = PauseMenu(self.screen)
        self.main_menu = MainMenu(self.screen)

        self.temp = []
Ejemplo n.º 7
0
# Charlie Conneely
# Anagram game

from countdown import Countdown
from score_system import ScoreKeeper
from player import Player

countdown = Countdown()
score_keeper = ScoreKeeper()
"""
Call play_countdown in Countdown class
Keep track of score
Check rankings
"""


def main(name):
    rounds = 3
    player = Player(name, 0)

    print("\nWe're going for best of " + str(rounds) + " rounds!")

    for x in range(rounds):
        points = countdown.play_countdown(player.name)
        player.score += points

    print("Total Score: " + str(player.score) + "\n")
    score_keeper.check_ranking(player)


"""
Ejemplo n.º 8
0
def check_buttons():
    global buttons, optos
    
    x = buttons.all_pressed()
    if x:
        print(x)

    x = optos.all_broken()
    if x:
        print(x)

lights.turn_off_all()
outlets.turn_off_all()

print("Starting countdown")
countdown = Countdown(12)
countdown.start()
time.sleep(3)
countdown.stop()
time.sleep(2)
countdown.reset()
time.sleep(3)
print("Done")

# Sleep time variables
sleeptime = 0.1

# MAIN LOOP =====
# ===============

try: