def __init__(self,
              default_name,
              short_desc=None,
              long_desc=None,
              pref_id=None):
     Scenery.__init__(self, default_name, short_desc, long_desc, pref_id)
     self.actions.append(Action(self.pour, ['pour'], True))
     self.actions.append(Action(self.drink, ['drink', 'sip', 'taste'],
                                True))
     self.is_liquid = True
示例#2
0
    def __init__(self):
        self.is_game_running = True
        self.fps = 30
        self.clock = pygame.time.Clock()
        self.screen = self.__init_display()
        self.scenery = Scenery(self.screen)
        self.groundobjects = GroundObjects(self.screen)
        self.plane = Plane(self.screen, self.scenery)
        self.scenery.register_plane(self.plane)
        self.groundobjects.register_plane(self.plane)
        self.collision_detection = CollisionDetection(self.screen, self)
        self.collision_detection.register_plane(self.plane)
        self.collision_detection.register_groundobjects(
            self.groundobjects.get_groundobjects())
        self.cloudgenerator = Cloudgenerator(self.screen)
        self.cloudgenerator.register_plane(self.plane)
        self.speedindicator = Speedindicator(self.screen)
        self.heightindicator = Heightindicator(self.screen)
        self.thrustindicator = Thrustindicator(self.screen)
        self.multidisplay = Multidisplay(self.screen, self.plane)
        self.navigationdisplay = Navigation(self.screen)

        self.debug = Debug(self.screen, self.plane, self.cloudgenerator)
示例#3
0
signal.signal(signal.SIGINT, signal_handler)

print("Good Morning Gamer!")
print("Enter your name to play the Mandalorian")
name = input()  # Take name of the player

GameStartTime = time.time()  #Initialise game start time
timeup = 0
scene = GameBoard(34, 200, GameStartTime, 100, 0)  #Initialise Board
scene.play_board()
scene.place_coins()  #Place coins on board
scene.create_magnet()  #Place magnet on board
scene.create_beams()  #Create lazer beams  on board

ground = Scenery()
ground.create_sky(scene)  #Creating Sky and Ground
ground.create_ground(scene)

Hero = Mandalorian(3, 3, 3,
                   scene.retrow() - 5, name,
                   "Hero")  #Creating and Placing Mando in the chamber
Hero.placeHero(3, scene.retrow() - 5, scene)
Drago = Dragon("Shindu",
               scene.retcol() - 34,
               scene.retrow() - 16)  # Creating Boss Dragon

scene.createdragon(Drago)
while (True):
    os.system('clear')
示例#4
0
    def __init__(self, screen_w, screen_h):

        #
        # Initialize Screenworld
        #

        # pygame = Screenworld
        pygame.init()

        # DEBUG SCREEN_INFO
        print("INFO")
        print(pygame.display.Info())
        print("MODES")
        print(pygame.display.list_modes(depth=0))
        print("FULLSCREEN_MODES")
        print(pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN))

        # set display mode and calculate _screen_size
        if screen_w == 0 and screen_h == 0:
            self._screen_size = (pygame.display.Info().current_w,
                                 pygame.display.Info().current_h)
        else:
            self._screen_size = (screen_w, screen_h)
        #self._screen = pygame.display.set_mode(self._screen_size, flags=pygame.FULLSCREEN)
        self._screen = pygame.display.set_mode(self._screen_size)

        # Frame rate
        self._fps = 60.0
        # Number of physics steps per screen frame
        self._physics_steps_per_frame = 1
        # Time steps
        self._dt = 1.0 / self._fps / self._physics_steps_per_frame
        #self._dt = 1. / self._fps

        # pygame frame clock
        self._clock = pygame.time.Clock()

        #
        # Initialize Game World
        #

        # Space = GameWorld
        self._space = pymunk.Space()
        # Gravity in m / s^2
        self._space.gravity = (0.0, -9.81)
        # Phyicsworld damoing in 1-x %
        self._space.damping = 0.8
        ## sleep time theshold
        #self.space.sleep_time_threshold = 0.3
        # zoomfactor from physicsworld to pixelworld. 1 = show 100% of space.width on screen, 2=50%
        self._zoom = 2
        # Physicsworld size in m
        self._space_size = (512, 320)
        # Camera POV in space in m from left,down
        self._space_pov = (256, 160)

        # Scale factor from space to screen. 1 m in space = <scale> pixel in screen
        #self._scale = Vec2d(self._screen_size).get_length() / Vec2d(self._space_size).get_length()
        self._scale = self._screen_size[0] / self._space_size[0]
        #print("SCALE: {0:f}".format(self._scale))

        # viewrect of current cam in space
        self._space_viewrect = (0, 0, 0, 0)
        self._calc_space_viewrect()

        #
        # Initialize Game Options
        #

        # Drawing Option. Setting _is_is_drawing to False enables headless mode
        self._is_drawing = True

        # Use pymunk debug draw. Note: I can't use it because I implement a scroller, scaler and zoom
        # So I use my own drawing routines in the Entity-Subclasses
        #self._draw_options = pymunk.pygame_util.DrawOptions(self._screen)

        # Execution control
        self._is_running = True
        self._is_paused = True
        self._show_menu = True

        #
        # Create Game Entities
        #

        # GUI
        self._font = pygame.font.SysFont("DejaVuSans", 24)
        self._text = self._font.render("Touch the screen.", True,
                                       (255, 255, 255, 255))
        self._text_w, self._text_h = self._text.get_size()
        self._add_hud()

        # Menu
        self.menu = Menu()

        # Static Scenery
        self.scenery = Scenery(self)

        # Player
        #self.player = Player(self._space, Vec2d(self._space_size)/2)
        self.player = Player(self, Vec2d(256, 160))

        # Add Event Dispatcher for user input
        self.ev = EventDispatcher()
示例#5
0
class LanderApp:
    def __init__(self, screen_w, screen_h):

        #
        # Initialize Screenworld
        #

        # pygame = Screenworld
        pygame.init()

        # DEBUG SCREEN_INFO
        print("INFO")
        print(pygame.display.Info())
        print("MODES")
        print(pygame.display.list_modes(depth=0))
        print("FULLSCREEN_MODES")
        print(pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN))

        # set display mode and calculate _screen_size
        if screen_w == 0 and screen_h == 0:
            self._screen_size = (pygame.display.Info().current_w,
                                 pygame.display.Info().current_h)
        else:
            self._screen_size = (screen_w, screen_h)
        #self._screen = pygame.display.set_mode(self._screen_size, flags=pygame.FULLSCREEN)
        self._screen = pygame.display.set_mode(self._screen_size)

        # Frame rate
        self._fps = 60.0
        # Number of physics steps per screen frame
        self._physics_steps_per_frame = 1
        # Time steps
        self._dt = 1.0 / self._fps / self._physics_steps_per_frame
        #self._dt = 1. / self._fps

        # pygame frame clock
        self._clock = pygame.time.Clock()

        #
        # Initialize Game World
        #

        # Space = GameWorld
        self._space = pymunk.Space()
        # Gravity in m / s^2
        self._space.gravity = (0.0, -9.81)
        # Phyicsworld damoing in 1-x %
        self._space.damping = 0.8
        ## sleep time theshold
        #self.space.sleep_time_threshold = 0.3
        # zoomfactor from physicsworld to pixelworld. 1 = show 100% of space.width on screen, 2=50%
        self._zoom = 2
        # Physicsworld size in m
        self._space_size = (512, 320)
        # Camera POV in space in m from left,down
        self._space_pov = (256, 160)

        # Scale factor from space to screen. 1 m in space = <scale> pixel in screen
        #self._scale = Vec2d(self._screen_size).get_length() / Vec2d(self._space_size).get_length()
        self._scale = self._screen_size[0] / self._space_size[0]
        #print("SCALE: {0:f}".format(self._scale))

        # viewrect of current cam in space
        self._space_viewrect = (0, 0, 0, 0)
        self._calc_space_viewrect()

        #
        # Initialize Game Options
        #

        # Drawing Option. Setting _is_is_drawing to False enables headless mode
        self._is_drawing = True

        # Use pymunk debug draw. Note: I can't use it because I implement a scroller, scaler and zoom
        # So I use my own drawing routines in the Entity-Subclasses
        #self._draw_options = pymunk.pygame_util.DrawOptions(self._screen)

        # Execution control
        self._is_running = True
        self._is_paused = True
        self._show_menu = True

        #
        # Create Game Entities
        #

        # GUI
        self._font = pygame.font.SysFont("DejaVuSans", 24)
        self._text = self._font.render("Touch the screen.", True,
                                       (255, 255, 255, 255))
        self._text_w, self._text_h = self._text.get_size()
        self._add_hud()

        # Menu
        self.menu = Menu()

        # Static Scenery
        self.scenery = Scenery(self)

        # Player
        #self.player = Player(self._space, Vec2d(self._space_size)/2)
        self.player = Player(self, Vec2d(256, 160))

        # Add Event Dispatcher for user input
        self.ev = EventDispatcher()

    def run(self):
        """
        The main loop of the game.
        :return: None
        """
        # Main loop
        while self._is_running:

            self._process_events()
            self._clear_screen()

            if not self._is_paused:
                ## Progress time forward
                #self._space.step(self._dt)
                for x in range(self._physics_steps_per_frame):
                    self._space.step(self._dt)

                self.scenery.update()
                self.player.update()
                self._update_hud()

            # Delay fixed time between frames
            self._clock.tick(self._fps)
            #pygame.display.set_caption("fps: " + str(self._clock.get_fps()))

            self._draw_objects()

            ### All done, lets flip the display
            pygame.display.flip()

    def _process_events(self):
        """
        Handle game and events like keyboard input. Call once per frame only.
        :return: None
        """
        # Handle menu
        if self._show_menu:
            menu_choice = self.menu.update(self.menu, self)
            if menu_choice == "Play":
                self._show_menu = False
                self._is_paused = False

#if menu_choice == "Options":
#	self.option_menu =

        if not self._is_paused:
            for event in self.ev.get():
                if event["type"] == self.ev.BTNDN:
                    self.player.input(event["idx"], 1)
                elif event["type"] == self.ev.BTNUP:
                    self.player.input(event["idx"], 0)
                elif event["type"] == self.ev.QUIT or event[
                        "type"] == self.ev.ESCAPE:
                    self._is_running = False
                elif event["type"] == self.ev.DRAW:
                    self._is_drawing = not self._is_drawing
                elif event["type"] == self.ev.ZOOMINC:
                    self.set_zoom(self.get_zoom() * 1.05)
                elif event["type"] == self.ev.ZOOMDEC:
                    self.set_zoom(self.get_zoom() * 0.95)


#                self._text = self._font.render("Finder DOWN: {0:d}, {1:f}, {2:f}".format(f, x, y), True, (255, 255, 255, 255))
#                self._text = self._font.render("Finder DOWN: {0:d}, {1:d}".format(pygame.display.Info().current_w, pygame.display.Info().current_h), True, (255, 255, 255, 255))

    def _clear_screen(self):
        """
        Clears the screen.
        :return: None
        """
        self._screen.fill((0, 0, 0, 255))

    def _draw_objects(self):
        """
        Draw the objects.
        :return: None
        """
        if self._show_menu:
            self.menu.draw(self._screen)

        elif not self._is_paused:
            ### Draw space
            #self._space.debug_draw(self._draw_options)
            self.scenery.draw(self)
            self.player.draw(self)

    def _add_hud(self):
        pass

    def _update_hud(self):
        #fps_str = "fps: " + str(self._clock.get_fps())
        self._screen.blit(self._text,
                          (self._screen_size[0] / 2 - self._text_w / 2,
                           self._screen_size[1] / 2 - self._text_h / 2))

    def to_screen(self, p):
        z = self._scale * self._zoom
        fx = 0.5 * self._space_size[0] / self._zoom
        fy = 0.5 * self._space_size[1] / self._zoom

        #x = (p[0] - self._space_pov[0]) * z + self._screen_size[0]/2
        x = (p[0] - self._space_pov[0] + fx) * z
        #y = (p[1] - self._space_pov[1]) * z + self._screen_size[1]/2
        y = (p[1] - self._space_pov[1] + fy) * z

        #print("s:{0:f}, z:{1:f}, p0:{2:f}, p1:{3:f}, wp0:{4:f}, wp1:{5:f}".format(world._scale, world._zoom, p[0], p[1], world._space_pov[0], world._space_pov[1]))
        return int(x), int(self._screen_size[1] - y)

    #def to_space(self):
    #    pass

    #def get_mouse_in_space(self, surface):
    #    pass
    #    """Get position of the mouse pointer in pymunk coordinates.
    #    p = pygame.mouse.get_pos()
    #    return from_pygame(p, surface)"""

    def set_space_pov(self, pos):
        self._space_pov = pos
        self._calc_space_viewrect()

    def get__space_pov(self):
        return self._space_pov

    def _calc_space_viewrect(self):
        w = self._space_size[0] / self._zoom
        h = self._space_size[1] / self._zoom
        x = self._space_pov[0] - 0.5 * w
        y = self._space_pov[1] - 0.5 * h
        self._space_viewrect = (x, y, w, h)

    def get_space_viewrect(self):
        return self._space_viewrect

    def get_screen_pov(self):
        return self.to_screen(self._space_pov)

    def set_zoom(self, zoom):
        self._zoom = zoom
        self._calc_space_viewrect()

    def get_zoom(self):
        return self._zoom

    def set_scale(self, scale):
        self._scale = scale

    def get_scale(self):
        return self._scale
示例#6
0
from scenery import Scenery
from grid import Grid
from alarmexception import AlarmException
from getch import _getChUnix as getChar
from items import Item, Laser, Coins, SpeedUp, Magnet
from configure import Configure
from enemy import Dragon, IceBall

gridObj = Grid(30, 500)
os.system("aplay -q ./music/Jetpack.wav &")

mandalorianObj = Din(25, 10, 1)
mandalorianObj.placeDin(gridObj.getMatrix(), 25, 10, 1)
shieldObj = Shield(0, 0)

sceneryObj = Scenery()

sceneryObj.createGround(gridObj.getMatrix())
sceneryObj.createSky(gridObj.getMatrix())

laserObj = []
coinObj = []
for i in range(16):
    laserObj.append(Laser(0, 0))
    coinObj.append(Coins(0, 0))

speedupObj = []
speedupObj.append(SpeedUp(0, 0))
speedupObj.append(SpeedUp(0, 0))

magnetObj = Magnet(5, 60)
示例#7
0

# import simpleaudio as sa

# filename = 'audio.mp3'
# wave_obj = sa.WaveObject.from_wave_file(filename)
# play_obj = wave_obj.play()
board = Board(30 + deltaoperator, 500)
board.create_board()

jetpacker = JetPacker(25 + deltaoperator, 0, 1)
D1 = Dragon()
D2 = []
jetpacker.starting_position(board.matrix)

obj_scenery = Scenery()
obj_scenery.create_ground(board.matrix)
bullets = []
obj_scenery.create_sky(board.matrix)
obj_scenery.create_coins_platforms(board)
obj_scenery.create_magnet(board)

enemies = []
listx = []
listy = []

for i in range(0, 40):
    intnum = randint(1, 3)
    intx = randint(10, 450)
    inty = randint(10, 25)
    listx.append(intx)
示例#8
0
from alarmexception import AlarmException
from getch import _getChUnix as getChar
from board import Board
from mario import Mario
from scenery import Scenery
from enemy import Enemy, BossEnemy
from config import Config

obj_board = Board(30, 500)
obj_board.create_board()

obj_mario = Mario(25, 0, 1)
obj_mario.starting_position(obj_board.matrix)

# Making the Background :D
obj_scenery = Scenery()

obj_scenery.create_ground(obj_board.matrix)
obj_scenery.create_sky(obj_board.matrix)
obj_scenery.create_clouds(obj_board.matrix, 2, 11)
obj_scenery.create_tunnels(obj_board.matrix, 23, 19)
obj_scenery.create_bricks(obj_board.matrix, 19, 57)
obj_scenery.create_mountain(obj_board.matrix, 3, 294)
obj_scenery.put_barrier(obj_board.matrix)
obj_scenery.create_springs(obj_board)
obj_scenery.create_holes(obj_board)
obj_scenery.create_coins_platforms(obj_board)

enemy1 = Enemy(26, 70, 1)
enemy2 = Enemy(26, 210, 1)
enemy3 = Enemy(26, 280, 1)
示例#9
0
        is_filled[a][b] = 6
        is_filled[a][b + 1] = 6
        is_filled[a][b + 2] = 6

system('clear')
while True:
    print('\033[0;0H', end='')
    #    system('tput reset')

    if time.time() - last_used_time >= 10:
        flag = 0

    p = Person(mat, x, y, hero_lives, hero_score, time.time(), is_filled,
               initial_time, flag, store_booster_xcoo, booster_ycood,
               transform)
    s = Scenery(mat, is_filled)
    recent_x = p.get_x()
    recent_y = p.get_y()

    for i in range(28):
        s.draw_clouds(clouds_x[i], ((clouds_y[i]) % 4) + 2)

    s.draw_ground(rows - 1, 2900)

    if st_co < 2080:
        p.draw_hero(st_co, last_y2, last_y3, last_y4, last_y5, last_y6,
                    last_y7)
        p.draw_villain(st_co, last_y8)

    if hit_flag == 1:
        for i in range(dr_bullets):
示例#10
0
#region initialise
pygame.init()
size = (640, 640)
screen = pygame.display.set_mode(size)
screen.fill([255, 255, 255])
pygame.display.set_icon(screen)
clock, fps = pygame.time.Clock(), 0

frame_start_time = 0
delta_time = 0
#endregion

trees = 10
bushes = 500

scene = Scenery(screen, trees=trees, bushes=bushes)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            exit(0)
    screen.fill(0)
    frame_start_time = time()
    key = pygame.key.get_pressed()

    if key[pygame.K_SPACE]:
        scene = Scenery(screen, trees=trees, bushes=bushes)

    scene.draw()
示例#11
0
class Flightsim():
    def __init__(self):
        self.is_game_running = True
        self.fps = 30
        self.clock = pygame.time.Clock()
        self.screen = self.__init_display()
        self.scenery = Scenery(self.screen)
        self.groundobjects = GroundObjects(self.screen)
        self.plane = Plane(self.screen, self.scenery)
        self.scenery.register_plane(self.plane)
        self.groundobjects.register_plane(self.plane)
        self.collision_detection = CollisionDetection(self.screen, self)
        self.collision_detection.register_plane(self.plane)
        self.collision_detection.register_groundobjects(
            self.groundobjects.get_groundobjects())
        self.cloudgenerator = Cloudgenerator(self.screen)
        self.cloudgenerator.register_plane(self.plane)
        self.speedindicator = Speedindicator(self.screen)
        self.heightindicator = Heightindicator(self.screen)
        self.thrustindicator = Thrustindicator(self.screen)
        self.multidisplay = Multidisplay(self.screen, self.plane)
        self.navigationdisplay = Navigation(self.screen)

        self.debug = Debug(self.screen, self.plane, self.cloudgenerator)

    def __init_display(self):
        pygame.init()
        self.screen = pygame.display.set_mode((1280, 745))
        self.screen.fill([0, 0, 0])
        icon = pygame.image.load(os.path.join('graphics', 'icon.png'))
        icon = pygame.transform.scale(icon, (32, 32))
        pygame.display.set_icon(icon)
        pygame.display.set_caption('Boring Flightsim')
        return self.screen

    def run_game(self):
        while True:
            self.clock.tick(30)
            self.fps = self.clock.get_fps()
            if self.fps < 1:
                self.fps = 30

            # Draw the self.scenery
            self.scenery.update()

            # Draw the groundobjects
            self.groundobjects.update()

            # Update the cloud-generator
            self.cloudgenerator.update()

            # Draw the speed indicator
            self.speedindicator.update(self.plane.get_speed())

            # Draw the height indicator
            self.heightindicator.update(self.plane.get_feet())

            # Draw the thrust indicator
            self.thrustindicator.update(self.plane.get_thrust(),
                                        self.plane.engine_running)

            # Draw the flight multidisplay
            self.multidisplay.update()

            # Draw the navigation display
            self.navigationdisplay.update(
                self.plane.get_travelled_x_distance())

            # Draw self.debug infos
            self.debug.update()

            # Draw the self.plane
            self.plane.update()

            # Check is a collision occured
            self.collision_detection.update()

            # Check if we fire an event:
            if self.plane.engine_running and self.plane.travelled_x_distance > 3000:
                self.plane.turn_engines_off()

            # Do the final draw operation
            pygame.display.flip()

            # Handle events
            self.__handle_events(pygame.event.get())

    def stop_simulation(self):
        self.is_game_running = False

    def __handle_events(self, events):
        for event in events:
            if event.type == pygame.QUIT:
                sys.exit()
            elif (event.type == pygame.KEYDOWN) and self.is_game_running:
                if event.key == pygame.K_w:
                    # more thrust
                    self.plane.increase_speed()
                if event.key == pygame.K_s:
                    # less thrust
                    self.plane.decrease_speed()
                if event.key == pygame.K_UP:
                    # pull up
                    self.plane.pull_up()
                if event.key == pygame.K_DOWN:
                    # pull up
                    self.plane.push_down()
                if event.key == pygame.K_g:
                    # Toggle gear
                    self.plane.toggle_landing_gear()
                if event.key == pygame.K_a:
                    # Toggle Airbreak
                    self.plane.toggle_airbrake()

                # self.debug code
                if event.key == pygame.K_t:
                    # pull up
                    self.plane.set_speed(200)
示例#12
0
central_fountain.add_exit('north', government_entrences.id)
central_fountain.add_exit('south', south_shopping_one.id)
government_entrences.add_exit('south', central_fountain.id)
south_shopping_one.add_exit('north', central_fountain.id)
restraunt_one.add_exit('out', south_shopping_one.id)

south_shopping_one.add_enter('gathernia', restraunt_one.id)

central_fountain.add_adjectives('busy', 'central')
government_entrences.add_adjectives('dark', 'cobbled')
south_shopping_one.add_adjectives('lively', 'bright', 'busy')

government_entrences.add_names('street')

fountain = Scenery('fountain', 'crystal clear fountain', 'This is studded with gems in the center. All of the water coming out of the fountain is crystal clear.')
fountain.add_adjectives('gem-studded', 'crystal','clear')
fountain.move_to(central_fountain)

silemon = DeepPocketSignUpWizard(government_entrences)
silemon.move_to(government_entrences)

for i in range(1, 6):
    table = Container('table')
    table.set_description("wooden table numbered %s" % i, "This is a slightly battered wooden table at the restraunt. It has a number %s on it." % i)
    table.fix_in_place("The table is too heavy and awkward to move.")
    table.add_adjectives("wooden", "battered", "%s" % i, "table", "numbered")
    table.add_names("%s" % i)
    table.set_prepositions("on", "onto")
    table.set_max_volume_carried(5000)
    table.set_max_weight_carried(150000)