Example #1
0
    def __init__(self):
        self.window = sf.RenderWindow(sf.VideoMode(WIDHT, HEIGHT), TITLE,
                                      sf.Style.DEFAULT, settings)
        self.circle = sf.CircleShape(50)
        self.rectangle = sf.RectangleShape((150, 200))
        self.rectangle.position = 200, 100

        self.view = sf.View()
        self.view.reset(sf.Rectangle((0, 0), self.window.size))
        self.window.view = self.view
Example #2
0
def Init():
    """This will setup the window and whatever needs setup (just once) at the start of the program."""
    wind = sf.RenderWindow(
        sf.VideoMode(config.WINDOW_WIDTH, config.WINDOW_HEIGHT),
        "CS CLUB PROJECT!")

    #This makes the background of the screen Black.
    wind.clear(sf.Color.BLACK)

    wind.framerate_limit = 50

    windView = sf.View()

    return wind, windView
Example #3
0
    def create_window(self):
        # create a new window
        size, bpp = sf.VideoMode.get_desktop_mode()  # get bits per pixel
        w = sf.RenderWindow(sf.VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, bpp),
                            "Tank Commander Panic")

        # set the window view
        v = sf.View(sf.Rect((0, 0), (VIEW_WIDTH, VIEW_HEIGHT)))
        v.viewport = (0.0, 0.0, 1.0,
                      (WINDOW_HEIGHT - HUD_HEIGHT) / WINDOW_HEIGHT)
        w.view = v

        # limit the framerate to 60 fps
        w.framerate_limit = 60

        return w
Example #4
0
    def __init__(self):
        # Window
        self.window = sf.RenderWindow(sf.VideoMode(WWIDTH, WHEIGHT), WTITLE,
                                      sf.Style.CLOSE | sf.Style.TITLEBAR,
                                      SETTINGS)
        self.window.framerate_limit = 60

        # Clock
        self.clock = sf.Clock()

        # View
        self.view = sf.View(sf.Rectangle((0, 0), (WWIDTH, WHEIGHT)))
        self.window.view = self.view

        # Loading assets
        self.load_assets()

        self.backgrounds = [sf.Sprite(self.bg_texture) for i in xrange(2)]
        self.grounds = [sf.Sprite(self.ground_texture) for i in xrange(2)]

        self.grounds[0].position = 0, 409
        self.grounds[1].position = 0, 409

        # Plane
        fly_anim = Animation()
        fly_anim.texture = self.plane_sheet
        fly_anim.add_frame(sf.Rectangle((0, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((176, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))

        self.plane = AnimatedSprite(sf.seconds(0.2), False, True)
        self.plane.play(fly_anim)
        self.plane.origin = self.plane.global_bounds.width / 2.0, self.plane.global_bounds.height / 2.0

        self.plane.position = sf.Vector2(150, 200)

        self.plane_speed = sf.Vector2(0.0, 0.0)

        self.jump_time = None

        self.plane_jumped = False

        # Rocks
        self.rocks = []
        self.spawn_rocks()
Example #5
0
    def __init__(self, window):
        State.__init__(self, window)

        #self.debug = []

        self.busses = []
        self.creatures = []
        self.lives = []

        self.player = Player(WIDTH / 2, HEIGHT / 2)

        for i in range(0, random.randint(MIN_GRUES, MAX_GRUES)):
            creature = Grue(*random_point_not_near(self.player.position))
            #print("New Grue at (%s)" % (creature.position))
            self.creatures.append(creature)

        for i in range(0, random.randint(MIN_HEALS, MAX_HEALS)):
            heal = Lives(random.randrange(0, MAP_WIDTH),
                         random.randrange(0, MAP_HEIGHT))
            self.lives.append(heal)

        self.background = sf.Sprite(sf.Texture.from_file("map2.png"))
        self.view = sf.View()
        self.view.reset(sf.Rectangle((0, 0), (WIDTH, HEIGHT)))
        self.window.view = self.view

        self.overlay = Overlay(self.player)
        self.dark_overlay = Overlay(self.player, dark=True)

        self.life_point_display = PointDisplay(
            sf.Rectangle((10, 10), (100, 10)), self.player.health,
            sf.Color.RED)
        self.stamina_display = PointDisplay(
            sf.Rectangle((WIDTH - 60 - 10, 10), (60, 10)),
            self.player.max_stamina, sf.Color.GREEN)

        self.boss_time = sf.Clock()
        self.run_timer = sf.Clock()
        self.treasure_time = sf.Clock()
        self.stamina_regeneration_timer = sf.Clock()

        self.is_running = False
        self.is_dark = False
        self.has_boss = False
        self.has_treasure = False
Example #6
0
    def main(self):

        # load big resources first
        cardPath = os.path.join(os.getcwd(), "res", "cardData.json")
        allCardData = None
        with open(cardPath, 'r', encoding="utf-8") as f:
            allCardData = json.load(f)

        # SET UP THE GRAPHICS WINDOW
        window = sf.RenderWindow(sf.VideoMode(1100, 800), 'Mana Burn')
        window.framerate_limit = 60
        window.clear()
        view = sf.View()
        view.reset(sf.Rectangle((0, 0), (1100, 850)))
        window.view = view
        window.display()

        # figure out the save game situation
        currentSavedGame = SavedGame()
        currentScreen = MainScreen(window, view, currentSavedGame, allCardData)

        # A clock runs and cleans up dead objects periodically
        cleanupClock = sf.Clock()

        # THE UPDATE AND GAME LOOP
        while window.is_open:
            for event in window.events:
                if type(event) is sf.CloseEvent:
                    window.close()
                if type(event
                        ) is sf.KeyEvent and event.code is sf.Keyboard.ESCAPE:
                    window.close()
                if type(currentScreen) is MainScreen:
                    if type(event) is sf.MouseButtonEvent:
                        currentScreen.checkClicks(window, event)
                    if type(event) is sf.MouseWheelEvent:
                        currentScreen.checkScroll(window, event)

            window.clear()
            currentScreen.update()
            window.display()

            if cleanupClock.elapsed_time.seconds >= .5:
                currentScreen.cleanUp()
                cleanupClock.restart()
Example #7
0
def Init():
    """This will setup the window and whatever needs setup (just once) at the start of the program."""

    config.window = sf.RenderWindow(
        sf.VideoMode(config.WINDOW_WIDTH, config.WINDOW_HEIGHT), "TileGame")

    #This makes the background of the screen Black.
    config.window.clear(sf.Color.BLACK)

    config.windowView = sf.View()

    config.windowView.reset(
        sf.FloatRect(0, 0, config.WINDOW_WIDTH, config.WINDOW_HEIGHT))

    #This is required for allowing importlib to import modules within these directories.
    sys.path.append(os.getcwd() + '\\Components\\')
    sys.path.append(os.getcwd() + '\\Systems\\')
    sys.path.append(os.getcwd() + '\\Entities\\')
Example #8
0
def init():
    global window_View, window_Width, window_Height

    #Convert the #of chunks into pixel lengths and use that as the window dimensions
    window = sf.RenderWindow(
        sf.VideoMode(config.WINDOW_WIDTH, config.WINDOW_HEIGHT),
        "CS CLUB MAP EDITOR!")
    window.clear(sf.Color(0, 0, 0))  #Make background black

    window.framerate_limit = 50  #Just doubled the game update rate

    window_View = sf.View()

    window_View.reset( (0, \
                0, \
                config.WINDOW_WIDTH, \
                config.WINDOW_HEIGHT) )
    return window
Example #9
0
    def __init__(self):
        # Window
        self.window = sf.RenderWindow(sf.VideoMode(WWIDTH, WHEIGHT), WTITLE,
                                      sf.Style.CLOSE | sf.Style.TITLEBAR,
                                      SETTINGS)
        self.window.framerate_limit = 60

        SoundManager.play_background_music()

        # Clock
        self.clock = sf.Clock()

        # View
        self.view = sf.View(sf.Rectangle((0, 0), (WWIDTH, WHEIGHT)))
        self.window.view = self.view

        # Loading assets
        self.textures = self.load_assets()
        self.bg = create_sprite(self.textures['bg'], WWIDTH, WHEIGHT, (0, 0))

        self.collision_manager = CollisionManager()
        self.bonus_manager = BonusManager(
            self.window, {
                'life': sf.Texture.from_file("assets/images/red03.png"),
                'bullet':
                sf.Texture.from_file("assets/images/bulletBonus.png"),
                'immortality': sf.Texture.from_file("assets/images/heart.png")
            }, self.collision_manager)

        self.obstacles = self.create_obstacles()
        self.bases = self.create_bases()
        self.player_manager = PlayerManager(self.window.size, DIST_FROM_BASE,
                                            self.textures['plane'],
                                            self.textures['human'], SPEED)

        self.obstacles = list(self.create_obstacles())
        self.stopped = False
        self.gameover = create_sprite(self.textures['aliens_win'],
                                      self.window.width, self.window.height,
                                      (0, 0))
Example #10
0
 def __init__(self, window):
     State.__init__(self, window)
     self.sprite = sf.Sprite(sf.Texture.from_file("endtext.png"))
     self.view = sf.View()
     self.view.reset(sf.Rectangle((0, 0), (WIDTH, HEIGHT)))
Example #11
0
globalTime = 0

winner = None

extinct = False

array = np.zeros((50,50))

foodList = []

antList = []

window = sf.RenderWindow(sf.VideoMode(500, 500), "anthill")

window.view = sf.View(sf.Rectangle((0, 0), (500, -500)))

window.view.center = (250, 250)

running = True

arraysize = int(array.size ** 0.5)

shape = sf.RectangleShape((10, 10))

startup()

show = input("Display? ")

while running:
Example #12
0
MAX_ZOOM = 15
MAP_SIZE_X = 130
MAP_SIZE_Y = 9

SIZE_X_SCALE = int(SIZE_X * 0.75)
SIZE_Y_SCALE = int(SIZE_Y * 0.75)

DEFAULT_ZOOM = 3
START_LEVEL = "00"
LEVEL_INT = 0

w = sf.RenderWindow(sf.VideoMode(SIZE_X, SIZE_Y), "Magic Wizard level editor")

#default_view = w.defaultView;

view = sf.View()
view.reset(sf.Rectangle((0, 0), (SIZE_X_SCALE, SIZE_Y_SCALE)))
view.viewport = (0, 0, 0.75, 0.75)
view.move(0, TILE_SIZE * 2)

edit_rectangle = sf.RectangleShape((SIZE_X_SCALE, SIZE_Y_SCALE))
edit_rectangle.fill_color = sf.Color(255, 0, 0, 200)

mouse_select = -1

hud_view = sf.View()
hud_view.reset(sf.Rectangle((0, 0), (SIZE_X, SIZE_Y)))
hud_view.viewport = (0.75, 0, 1, 1)

hud_rectangle = sf.RectangleShape((SIZE_X - SIZE_X_SCALE, SIZE_Y))
hud_rectangle.fill_color = sf.Color(25, 20, 250, 120)