1. Sami Loone
  2. Fat x Fast

Source

Fat x Fast / FatxFast / modes / mapmode.py

# This file is part of FatxFast.
#
#    FatxFast is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FatxFast is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.

# Versioning based on: 
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
__author__ = "dryatu (c) 2013"
__version__ = "1.2.5"


from FatxFast.modes import mode
from FatxFast.objects.player import Player
import pygame
from FatxFast import camera
from FatxFast.graphics import SCREENSIZE

class MapMode(mode.GameMode):

    def __init__(self, scene, **kwargs):
        self.scene = scene 
        self.minimap = self.scene.get_widget("minimap")
        self.camera = self.minimap.camera
        self.create_players()    
        self.hotkeys = scene.manager.game.config.hotkeys
        self.scene.playing = True
#        self._camera_sizes = [SCREENSIZE, 
#            (SCREENSIZE[0]*1.5, SCREENSIZE[1]*1.5)]
#        self._cam_size_index = 0

#    # Returns (W,H)
#    @property
#    def _camera_size(self):
#        return self._camera_sizes[self._cam_size_index]
#
#    def _set_cam_zoom_level(self, value):
#        if (value >= 0 and value < len(self._camera_sizes)):
#            self._cam_size_index = value
#            self.camera.rect.size = self._camera_size
#
    def create_players(self):
        x = self.scene.tilemap.properties.get("start_x", 64)
        y = self.scene.tilemap.properties.get("start_y", 64)
        self.player1 = self.scene.create_character(
            Player, pos=(x,y), add_to_world=False)
#        self.camera.follow_target(self.player1)
        self.player1.physics.collides = False
        pass

    def key_pressed(self, key, utf, mod):
        if key == self.hotkeys["map"]: 
            self.scene.close_map()
#        elif key == self.hotkeys["map-zoom-in"]:
#                self._set_cam_zoom_level(self._cam_size_index-1)
#        elif key == self.hotkeys["map-zoom-out"]:
#            self._set_cam_zoom_level(self._cam_size_index+1)

    def mouse_moved(self, pos, rel):
        player1 = self.player1
        pos = player1.get_position()
        player1.set_position((rel[0]+pos[0], rel[1]+pos[1]))

    def pause(self):
        super(MapMode, self).pause()

    def resume(self):
        super(MapMode, self).resume()
#        self.player1.rect.topleft = self.scene.gamemode.player1.rect.topleft
    
    def start(self):
        super(MapMode, self).start()
#        self.player1.rect.topleft = self.scene.gamemode.player1.rect.topleft

    def update(self, dt):
        self.keys_held()
#        self.player1.update(dt)
#        self.camera.update()