示例#1
0
文件: view.py 项目: sabren/blaze
 def __init__(self,screen,config):
     State.__init__(self,screen)
     self.config = config
     self.object = None
     self.rect = pygame.Rect(100,0,700,600)
     width,height = map(int,self.config['screen_size'].split('x'))
     tile_size = int(config['tile_size'])
     self.screen.fill((255,255,255),self.rect)
     self.grid = Grid(width,height,tile_size,(700,600),screen)
示例#2
0
文件: view.py 项目: sabren/blaze
 def __init__(self,screen,config,objects):
     State.__init__(self,screen)
     self.config = config
     self.objects = objects
     self.object_positions = []
     self.selected = None
     self.rect = pygame.Rect(0,0,100,600)
     self.title_font = pygame.font.SysFont('Arial', 15)
     self.save_location = []
     self.draw_items()
示例#3
0
 def __init__(self, key, manager):
     State.__init__(self,key,manager)
     self.psurf = pygame.surface.Surface((1024,768))
     self.psurf.fill((0,0,0))
     self.psurf.set_alpha(200)
     self.paused = False
     self.prepared = False
     self.bullet_group = pygame.sprite.Group()
     self.creeps = pygame.sprite.LayeredUpdates()
     self.cursor = self.manager.cursor
     self.towers = pygame.sprite.OrderedUpdates()
     self.bgt = pygame.sprite.OrderedUpdates()
     self.needed_tiles = pygame.sprite.Group()
     self.needed_tiles1 = pygame.sprite.Group()
     self.banned_tiles = pygame.sprite.OrderedUpdates()
     self.banned_tiles1 = pygame.sprite.OrderedUpdates()
     self.player = self.manager.player
     self.weatherbg = pygame.surface.Surface((1024,640))
     self.weatherbg.fill((0,0,0))
     self.weatherbg.set_alpha(0)
     self.magic = pygame.sprite.Group()
     self.d = pygame.sprite.Group()
     self.buoyant = pygame.sprite.Group()
     self.default_text = ''
     self.before_mag = self.before_g = 0
     self.tpassed = 0
     self.tbot = None
     self.previous = 0
     self.ingame_menu = Master([0,596],1024,172,self.screen,self.cursor, \
     "./data/font/carolingia.ttf")
     self.ingame_menu_bg = load_image("./data/image/menu/ingame_menu.png")
     self.ship_menu = SHIMENU.get_at((0,0,157,61), True)
     self.ship_hp = SHIMENU.get_at((159,6,47,43), True)
     self.bonus_menu = load_image("./data/image/menu/bns_menu.png")
     self.particle_emitter = pygame.sprite.Group()
     self.spells = pygame.sprite.Group()
     self.wave = 0
     self.total = 0
     self.bars = pygame.surface.Surface((1024,768))
     self.bars.fill((0,0,0))
     self.bars.set_colorkey((0,0,0))
     self.wave_t = 0
     self.countdown = False
     self.moded = False
     self.totalc = 0
     self.unlock = ['Nothing','']
     self.map = None
     self.lname = None
     self.cid = None
示例#4
0
 def __init__(self,
              driver,
              location,
              options,
              header=None,
              slave=None,
              default=0):
     State.__init__(self, driver)
     if default >= len(options): default = 0
     self._header = header
     self._options = options
     self._current = default
     self._chosen = options[default]
     self._slave = slave
     self._location = location
     self._font = pygame.font.Font(None, 20)
     self.setupImages()
示例#5
0
    def __init__(self, key, manager):
        State.__init__(self,key,manager)
        self.cursor = self.manager.cursor
        self.player = self.manager.player
        self.menu = Master([0,0],1024,768,self.screen,self.cursor,"./data/font/carolingia.ttf")
        self.menu_background = load_image("./data/image/menu/map.PNG")
        self.levels = [[Level("lv01.mkm"), [195, 542]],[Level("lv02.mkm"), [215,469]], \
[Level("lv03.mkm"), [177,402]], [Level("lv04.mkm"), [165, 331]], \
[Level("lv05.mkm"), [209, 281]], [Level("lv06.mkm"), [268, 210]], \
[Level("lv07.mkm"),[255,125]], [Level("lv08.mkm"),[372,199]], \
[Level("lv09.mkm"),[481,234]], [Level("lv10.mkm"),[547,266]], \
[Level("lv11.mkm"),[687,261]], [Level("lv12.mkm"),[720,149]], \
[Level("lv13.mkm"),[875,125]], [Level("lv14.mkm"),[871,201]], \
[Level("lv15.mkm"),[840,252]], [Level("lv16.mkm"),[818,291]], \
[Level("lv17.mkm"),[761,382]], [Level("lv18.mkm"),[631,429]], \
[Level("lv19.mkm"),[616,477]], [Level("lv20.mkm"),[579,519]], \
[Level("indian1.mkm"),[149,154]], [Level("indian2.mkm"),[152,106]], \
[Level("warrior1.mkm"),[356,235]]]
        self.prepared = False
示例#6
0
    def __init__(self,key,manager):
        State.__init__(self,key,manager)
        self.cursor = self.manager.cursor
        self.menu = Master([0,0],1024,768,self.screen,self.cursor,"./data/font/carolingia.ttf")
        self.menu_background = load_image("./data/image/menu/menu.PNG")
        self.temp = Label(self.menu,[273,638],(0,0,0),None,19,"v. 0.9")
        self.boxes = []
        icons = Sheet("./data/image/menu/status_icons.png")
        try:
            version = float(urllib.urlopen("http://mkm.limun.org/vs/version.txt").read())

            if version==0.9:
                self.boxes.append(MessageBox([300,300],[400,100],self.screen,self.cursor,"You have the most recent version installed.",[self.menu]))
                temp_image = icons.get_at((0,0,19,19),False)
            elif version<0.9:
		self.boxes.append(MessageBox([300,300],[400,100],self.screen,self.cursor,"Damn, you must be Chuck Norris! How did you...?",[self.menu]))
		temp_image = icons.get_at((0,0,19,19),False)
            else:
                self.boxes.append(MessageBox([300,300],[400,100],self.screen,self.cursor,"A new version is available on the official site!",[self.menu]))
                temp_image = icons.get_at((38,0,19,19),False)

        except:
            self.boxes.append(MessageBox([300,300],[400,100],self.screen,self.cursor,"Can't connect! Please check connection and restart.",[self.menu]))
            temp_image = icons.get_at((19,0,19,19),False)

        def x(something):
            print something,"x!"

        self.temp = ImageButton(self.menu,[318,638],temp_image,self.boxes[0].wake)
        self.temp = Button(self.menu,[395,155],(0,0,0),None,62,"New Game",self.manager.set_state,"game")
	self.temp = Button(self.menu,[395,222],(0,0,0),None,62,"Continue",x,"aa")
        self.temp = Button(self.menu,[395,294],(0,0,0),None,62,"Profile",x,"aa")
        self.temp = Button(self.menu,[395,366],(0,0,0),None,62,"Options",self.menu.switch,"options")
        self.temp = Button(self.menu,[395,438],(0,0,0),None,62,"Credits",self.menu.switch,"credits")
        self.temp = Button(self.menu,[395,510],(0,0,0),None,62,"Quit",exit,None)
        self.temp = Button(self.menu,[273,630],(0,0,0),None,20,"Back",self.menu.switch,"default",["credits"])
        self.temp = Button(self.menu,[273,630],(0,0,0),None,20,"Back",self.menu.switch,"default",["options"])
	self.temp = Button(self.menu,[323,630],(0,0,0),None,20,"Apply",x,"aa",["options"])
        self.temp = Textbox(self.menu, [300,155],(0,0,0),None,28,"Created by: Marko Pranjic\nPowered by: PyGame\nBackground music: Celestial Aeon Project\nSound effects: freesounds.org\nSpecial thanks to my friends\nand forumers who supported me!",3,["credits"])
        self.temp = Checkbox(self.menu,[395,154],(0,0,0),None,19,"Fullscreen",(0,1),["options"])
	self.temp = Label(self.menu,[395,179],(0,0,0),None,19,"Background sound:",["options"])
        self.temp = Scroll(self.menu, [560,179],(0,0,0),None,19,["options"])
示例#7
0
    def __init__(self,key,manager):
        State.__init__(self,key,manager)	
	self.bullet_group = pygame.sprite.Group()
	self.creeps = pygame.sprite.OrderedUpdates()
        self.cursor = self.manager.cursor
	self.tiles_dict, self.path_tiles = tiles_dictionary()
	self.towers = pygame.sprite.OrderedUpdates()
	self.needed_tiles = pygame.sprite.Group()
	self.banned_tiles = pygame.sprite.OrderedUpdates()
	self.banned_tiles2 = pygame.sprite.OrderedUpdates()
	self.ingame_menu = Master([0,19*32],1024,160,self.screen,self.cursor,"./data/font/viking.ttf")
	self.ingame_menu_bg = load_image("./data/image/menu/ingame_menu.png")
	self.levels = {}
	temp = Level("lv01.mkm")
	self.levels[temp["name"]]=temp
	self.player = self.manager.player
	self.gold_label = Label(self.ingame_menu,[285,10],(255,255,255),None,15,str(self.player["gold"]))
        self.magicka_label = Label(self.ingame_menu,[372,10],(255,255,255),None,15,str(self.player["magicka"]))
	self.particle_emitter = pygame.sprite.Group()
        self.spells = pygame.sprite.Group()

        def spawn():
            if not self.player.buying:
                self.player.buying = True
	        temp = (ArrowTower(len(self.towers),[0,0],80,self.screen, \
                        self.bullet_group,self.creeps,[self.needed_tiles, \
                        self.towers],[self.banned_tiles,self.banned_tiles2], \
                        self.player, self.particle_emitter))
	        self.towers.add(temp)

        def spawn2():
            if not self.player.buying:
                self.player.buying = True
                temp = FireArrows([0, 0], self.player, self.particle_emitter, \
                                  self.screen, self.towers)
                self.spells.add(temp)

        buttons = Sheet("./data/image/menu/buttons.png")       
        ImageButton(self.ingame_menu,[33,47],buttons.get_at((33,0,32,32),False),spawn)
        ImageButton(self.ingame_menu,[806,47],buttons.get_at((66,0,32,32),True),spawn2)
示例#8
0
 def __init__(self, key, manager):
     State.__init__(self,key,manager)
     self.cursor = self.manager.cursor
     self.player = self.manager.player
     self.menu = Master([0,0],1024,768,self.screen,self.cursor,"./data/font/carolingia.ttf")
     self.menu_background = load_image("./data/image/menu/shop.png")
     self.shopl = load_image("./data/image/menu/shoplayer.png")
     self.blargh = False
     self.effects = pygame.sprite.Group()
     p1 = [[64, 640], [96, 640], [128, 640], [160, 640], [192, 640], \
            [96, 672], [128, 672], [160, 672], [192, 672], [256, 640], \
            [298, 640], [320, 640], [256, 672], [290, 672], [320, 672], \
            [352, 672]]
     p2 = [[672, 160], [704, 160], [736, 160], [758, 160], [640, 192], \
           [672, 192], [704, 192], [736, 192]]
     pat = [p1, p2]
     for i in range(12):
         self.effects.add(Butterfly(random.choice(pat)))
     self.effects.add(ABoat())
     self.rects = []
     for i in range(6):
         self.rects.append(pygame.Rect(58+74*i+288, 23+64, 59, 58))
     self.cid = None
     self.mix()
示例#9
0
    def __init__(self, key, manager):
        State.__init__(self,key,manager)
        self.cursor = self.manager.cursor
        self.pon = 0
        self.menu = Master([0,0],1024,768,self.screen,self.cursor,"./data/font/carolingia.ttf")
        self.menu_background = load_image("./data/image/menu/menu.PNG")
        self.sbg = load_image("./data/image/menu/storyBG.PNG")
        self.boxes = []
        self.page = 0
        icons = Sheet("./data/image/menu/status_icons.png")
        credit_text = "Programming, design and graphics\nby Marko Pranjic a.k.a mkmgames.\n \
                       \nMusic is from Celestial Aeon Project;\nYou can find it and download \
it from\nhttp://www.mattipaalanen.com/\n \nFor more info or contact, \
please visit\nhttp//vikingsstory.sourceforge.net"
        Button(self.menu,[395,155],(0,0,0),None,62,"New Game",self.menu.switch,"diff")
        Button(self.menu,[395,222],(0,0,0),None,62,"Continue",self.manager.set_state,"map")
        Button(self.menu,[395,294],(0,0,0),None,62,"Achievements",self.menu.switch,"achievements")
        Button(self.menu,[294,110],(0,0,0),None,52,"Easy",self.difficulty,4, \
               ["diff", "inf1"], hovfun=self.hovinfo, hovarg=A3)
        Button(self.menu,[294,177],(0,0,0),None,52,"Normal",self.difficulty,2, \
               ["diff", "inf1"], hovfun=self.hovinfo, hovarg=A2)
        Button(self.menu,[294,244],(0,0,0),None,52,"Ragnarok",self.difficulty,0, \
               ["diff", "inf1"], hovfun=self.hovinfo, hovarg=A1)
        Button(self.menu,[395,366],(0,0,0),None,62,"Options",self.menu.switch,"options")
        Button(self.menu,[395,438],(0,0,0),None,62,"Credits",self.menu.switch,"credits")
        Button(self.menu,[395,510],(0,0,0),None,62,"Quit",exit,None)
        Button(self.menu,[273,630],(0,0,0),None,32,"Back",self.menu.switch,"default",["credits"])
        Button(self.menu,[273,630],(0,0,0),None,32,"Back",self.menu.switch,"default",["diff", "inf1"])
        Button(self.menu,[273,630],(0,0,0),None,32,"Back",self.menu.switch,"default",["options","okbox"])
        Button(self.menu,[273,630],(0,0,0),None,32,"Back",self.menu.switch,"default",["achievements", "inf"])
        Button(self.menu,[343,630],(0,0,0),None,32,"Apply",self.change_settings,None,["options","okbox"])
        self.pic = Image(self.menu,[523,112],TALE[0],["intro","intro1"])
        ImageButton(self.menu,[230,613],SIC.get_at((0,19,38,53),False),self.flip, -1, ["intro1"])
        ImageButton(self.menu,[790,613],SIC.get_at((38,19,38,53),False),self.flip, 1, ["intro","intro1"])
        Textbox(self.menu,[300,155],(0,0,0),None,28,credit_text,3,["credits"])
        self.story = Textbox(self.menu,[224,120],(0,0,0),None,28,TXT[0],3,["intro","intro1"])
        self.dt = Textbox(self.menu,[392,484],(0,0,0),None,24,"",3, \
                          ["inf"])
        self.achievements = {
        "TUT":ImageButton(self.menu,[392,211], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="TUT"),
        "WIZ":ImageButton(self.menu,[492,211], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="WIZ"),
        "SAI":ImageButton(self.menu,[592,211], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="SAI"),
        "LUC":ImageButton(self.menu,[392,290], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="LUC"),
        "SHI":ImageButton(self.menu,[492,290], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="SHI"),
        "BUI":ImageButton(self.menu,[592,290], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="BUI"),
        "PER":ImageButton(self.menu,[392,370], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="PER"),
        "INV":ImageButton(self.menu,[492,370], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="INV"),
        "UNL":ImageButton(self.menu,[592,370], ACH.get_at((0,177,59,58),True), self.potatoes, \
                    None, ["achievements", "inf"], hovfun=self.desc, hovarg="UNL")
        }
        self.fs = Checkbox(self.menu,[395,154],(0,0,0),None,32,"Fullscreen",(0,1),["options","okbox"], \
                           self.manager.config["fullscreen"])
        self.fps = Checkbox(self.menu,[395,194],(0,0,0),None,32,"Show FPS",(0,1),["options","okbox"], \
                           self.manager.config["fps"])
        Label(self.menu,[395,234],(0,0,0),None,31,"Music:",["options","okbox"])
        self.bs = Scroll(self.menu, [500,234],(0,0,0),None,32,["options","okbox"], \
                         self.manager.config["bsound"]*100)
        Label(self.menu,[395,274],(0,0,0),None,31,"Sound:",["options","okbox"])
        self.sfx = Scroll(self.menu, [500,274],(0,0,0),None,32,["options","okbox"], \
                         self.manager.config["sfx"]*100)
        OKBox(self.menu,(0,0,0),None,22, "You will need to restart\nthe game so changes could\nbe applied.",3,self.menu.switch,"options")
        self.df = Textbox(self.menu,[525,110],(0,0,0),None,32,"",3, \
                          ["inf1"])
        self.cid = None
        self.cid1 = None
        self.check_ach()
示例#10
0
 def __init__(self, driver):
     State.__init__(self, driver)
     self._title = pygame.image.load("title.png").convert()
     mainMenu = [(1, 'Start Game', 0), (2, 'Quit', 0)]
     self._menu = Menu(driver, (5, 400), mainMenu, None, self)
     self._shownMenu = 0
示例#11
0
文件: view.py 项目: sabren/blaze
 def __init__(self,screen,config,objects): 
     State.__init__(self,screen)
     self.config = config
     self.objects = objects
     self.window = LEWindow(screen,config)
     self.toolbar = LEToolbar(screen,config,objects)
示例#12
0
 def __init__(self, context):
     State.__init__(self, context, None, None, None)
示例#13
0
 def __init__(self, scene):
     State.__init__(self, scene)
     self.hover_filter = lambda x: True
示例#14
0
    def __init__(self, driver):
        State.__init__(self, driver)
        self._engine = TileEngine('dungeon.map', driver, self)
        self._font = pygame.font.Font(None, 20)
        self._name = random.choice(names)
        self._messages = [(0, "Welcome to %s" % self._name)]
        self._deequip = None
        self._visited = None
        mapinfo = self._engine.getMapInfo()
        self._mapinfo = mapinfo
        self.xp = localXP = 3500
        playerStats = {
            'level': localXP / 100,
            'str': 30,
            'dex': 30,
            'int': 30,
        }
        self.gender = 'Male'
        self.race = 'Human'
        self.charClass = 'Guardian'
        armorStats = {
            'name': '+10 Robes of the Guardian',
            'absorb': 20,
            'toDodge': 10
        }
        weaponStats = {
            'name': '+10 Flaming Angelic Sword',
            'damageMin': 25,
            'damageMax': 75,
            'toHit': 10,
        }
        weapon = entities.Weapon('sword.png', self._engine, 0, 0, weaponStats)
        armor = entities.Armor('armor.png', self._engine, 0, 0, armorStats)
        self._player = Character('player.png', self._engine, mapinfo['startx'],
                                 mapinfo['starty'], playerStats, 1)
        self._player.giveItem(weapon)
        self._player.equip(weapon)
        self._player.giveItem(armor)
        self._player.equip(armor)

        self._engine.addSprite(self._player)
        self._engine.centerOn(self._player)

        staffStats = {'name': 'Terrifyingly Powerful Staff of Glok-Yar'}
        self._staff = entities.Staff('staff.png', self._engine,
                                     mapinfo['staffx'], mapinfo['staffy'],
                                     staffStats)
        self._engine.addSprite(self._staff)

        self._entries = []
        counter = 1
        while counter:
            try:
                entranceX = mapinfo['entranceX%d' % counter]
                entranceY = mapinfo['entranceY%d' % counter]
                entrance = entities.Entry('stairs.png', self._engine,
                                          entranceX, entranceY)
                self._entries.append(entrance)
                self._engine.addSprite(entrance)
                counter += 1
            except KeyError:
                counter = 0

        self._turn = 0
        mixer.music.load(localSoundsDir + '23 - Cold_Mountain_Clouds.ogg')
        mixer.music.set_volume(localVol * 4)
        mixer.music.play(-1)
示例#15
0
 def __init__(self, scene, tank):
     self.tank = tank
     State.__init__(self, scene)
示例#16
0
 def __init__(self, scene):
     State.__init__(self, scene)
     self.factory_index = 0
     self.selection = None
示例#17
0
 def __init__(self, scene, num_steps):
     State.__init__(self, scene)
     self.num_steps = num_steps
示例#18
0
 def __init__(self, scene, tutorial):
     State.__init__(self, scene)
     self.tutorial = tutorial
示例#19
0
 def __init__(self, driver, player, pgs):
     State.__init__(self, driver)
     self._player = player
     self._pgs = pgs
     self._menu = None