コード例 #1
0
 def _load_background(self):
     background = Sprite(self.gallery.content["display"]["city_" +
                                                         self.market])
     self.optimal_scale = (self.config.window_width *
                           self.display_pos_size["display_city_commerce"]
                           ["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_city_commerce"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_city_commerce"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
     if self.market == "commerce":
         overlay = Sprite(self.gallery.content["display"]["city_commerce_" +
                                                          self.supply])
         overlay.image_anchor = 0, 0
         overlay.x = self.left_margin
         overlay.y = self.bottom_margin
         overlay.scale = self.optimal_scale
         self.add(overlay)
コード例 #2
0
 def __init__(self):
     Layer.__init__(self)
     self.config = Config()
     self.gallery = Gallery()
     self.schedule_interval(self.music_start, interval=7)
     self.intro_sound = load("music/sound_start.wav", streaming=False)
     self.intro_sound.play()
     self.is_event_handler = True
     background = Sprite(self.gallery.content["display"]["title"])
     self.optimal_scale = (
         self.config.window_width *
         self.display_pos_size["display_title"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_title"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_title"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
     place_holder_image = Sprite(self.gallery.content["screen"]["title"])
     place_holder_image.position = director.window.width / 2, director.window.height / 2
     place_holder_image.scale = self.optimal_scale
     place_holder_image.do(ScaleBy(5.2, duration=25))
     self.add(place_holder_image)
コード例 #3
0
 def __init__(self):
     super(Snake, self).__init__()
     self.score = 30
     self.head = Sprite('img/circle.png', color=random.choice(rand_color))
     self.head.scale = 1.5
     self.head.set_position(director.get_window_size()[0] / 2,
                            director.get_window_size()[1] / 2)
     eyeball = Sprite('img/circle.png', color=(253, 55, 80))
     eyeball.scale = 0.5
     eye_left = Sprite('img/circle.png')
     eye_left.y = 5
     eye_left.scale = 0.5
     eye_left.add(eyeball)
     eye_right = Sprite('img/circle.png')
     eye_right.y = -5
     eye_right.scale = 0.5
     eye_right.add(eyeball)
     mouth = Sprite('img/circle.png', color=(0, 0, 0))
     mouth.x = +5
     mouth.scale = 0.3
     self.head.add(mouth)
     self.head.add(eye_left)
     self.head.add(eye_right)
     self.add(self.head)
     self.schedule_interval(self.update, random.random() * 0.2 + 0.1)
コード例 #4
0
 def _load_trade_boxes(self):
     self.remove_trade_boxes()
     if self.trade_display:
         self._load_button_gen("button", "drop", events.emit_commerce_switch_trade_dump, "button_switch", 0, 1, 0.95)
         for wagon in self.wagons_for_trade:
             self._load_button_gen("wagon", self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].display_image+"_t", events.emit_wagon_select, "trade_bracket"+str(wagon), wagon, 1, 0.99 )
             label_wagon_name = Label(self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].wagon_name + " ("+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].storage+")", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.152)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=16*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_name"+str(wagon))
             label_wagon_name = Label(" ", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.026)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=14*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_hold"+str(wagon))
             self._load_button_gen("button", "plus", events.emit_item_buy, "button_buy"+str(wagon), wagon, 0.72, 0.95 )
             self._load_button_gen("button", "minus", events.emit_item_sell, "button_sell"+str(wagon), wagon, 0.72, 0.95 )
     else:
         self._load_button_gen("button", "trade", events.emit_commerce_switch_trade_dump, "button_switch", 0, 1, 0.95)
         for wagon in self.wagons_for_dump:
             trade_bracket = Sprite(self.gallery.content["wagon"][self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].display_image+"_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]
             self.add(trade_bracket, name="trade_bracket"+str(wagon))
             label_wagon_name = Label(self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].wagon_name + " ("+self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].storage+")", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.152)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=16*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_name"+str(wagon))
             label_wagon_name = Label(" ", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.026)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=14*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_hold"+str(wagon))
             self._load_button_gen("button", "minus", events.emit_item_sell, "button_sell"+str(wagon), wagon, 0.72, 0.95 )
     self.update_desc()
コード例 #5
0
 def _load_background(self):
     background = Sprite(
         self.gallery.content["display"]["worldmap_minitrain"])
     self.optimal_scale = (self.config.window_width * self.display_pos_size[
         "display_worldmap_minitrain"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_worldmap_minitrain"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_worldmap_minitrain"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     #self.add(background)
     white_base = ColorLayer(255,
                             255,
                             255,
                             255,
                             width=background.width * 6,
                             height=background.height + 10)
     white_base.x = background.x - (background.width * 3)
     white_base.y = background.y + self.bottom_margin
     self.add(white_base)
コード例 #6
0
    def _load_background(self):
        background = Sprite(
            self.gallery.content["display"]["worldmap_quarters"])
        self.optimal_scale = (self.config.window_width * self.display_pos_size[
            "display_worldmap_quarters"]["W"]) / background.width
        background.image_anchor = 0, 0
        background.scale = self.optimal_scale
        background.x = self.config.window_width * self.display_pos_size[
            "display_worldmap_quarters"]["X"]
        background.y = self.config.window_height * self.display_pos_size[
            "display_worldmap_quarters"]["Y"]
        self.left_margin = background.x
        self.bottom_margin = background.y
        self.optimal_width = background.width
        self.optimal_height = background.height
        self.add(background)

        self.ps_alarm = Sun()
        self.ps_alarm.total_particles = 20
        self.ps_alarm.speed = 0.0
        self.ps_alarm.speed_var = 0.0
        self.ps_alarm.life_var = 0.0
        self.ps_alarm.blend_additive = True
        self.ps_alarm.position = (
            self.optimal_width * self.button_positions["ps_alarm"]["X"] +
            self.left_margin), (
                self.optimal_height * self.button_positions["ps_alarm"]["Y"] +
                self.bottom_margin)
        self.ps_alarm.start_color = Color(1, 0.40, 0.40, 0.40)
        self.ps_alarm.size = 50.0
コード例 #7
0
ファイル: display-cocos.py プロジェクト: rynote/tailor
    def check_queue(self, dt=0):
        width, height = cocos.director.director.get_window_size()

        image = fetch_image()
        sprite = Sprite(image)

        sprite.rotation = random.randint(-25, 25)

        end_scale = 1024.0 / image.width

        sw = int((image.width * end_scale) / 2)
        sh = int((image.height * end_scale) / 2)

        sprite.x = random.randint(sw, width - sw)
        sprite.y = random.randint(sh, height - sh)

        sprite.opacity = 0
        sprite.scale = end_scale * 1.5

        sprite.do(
            spawn(
                FadeIn(.2),
                AccelDeccel(ScaleTo(end_scale, duration=.4))) +
            Delay(15) +
            FadeOut(.5) +
            CallFunc(sprite.kill))

        self.z += 1
        self.add(sprite, z=self.z)
コード例 #8
0
 def add_named_node(self,name,p0,color=(255,255,255)):
     x,y = p0
     b = Sprite('data/npoint.png',color=color)
     b.x = x*scale+offset
     b.y = y*scale+offset
     b.scale = 1.0/8.0
     self.add(b)
     self.add_named(name,[b])
コード例 #9
0
    def __init__(self):
        super(GameDecoratorLayer, self).__init__()
        bg = "bgs/the_void.png"
        sprite = Sprite(bg)
        sprite.x = sprite.width / 2
        sprite.y = sprite.height / 2

        self.add(sprite)
コード例 #10
0
ファイル: game_map.py プロジェクト: HieuLsw/blobjob
 def __init__(self):
     super(GameDecoratorLayer,self).__init__()
     bg = "bgs/the_void.png"
     sprite = Sprite(bg)
     sprite.x = sprite.width/2
     sprite.y = sprite.height/2
     
     self.add(sprite)
コード例 #11
0
ファイル: intro_scene.py プロジェクト: HieuLsw/blobjob
 def __init__(self):
     super(IntroScene,self).__init__()
     bg = Layer()
     bg.image = 'bgs/howto_bg.jpg'
     sprite = Sprite(bg.image)
     sprite.x = 400
     sprite.y = 300
     bg.add(sprite)
     self.add(bg)
     self.add(IntroHandlerLayer())
コード例 #12
0
ファイル: intro_scene.py プロジェクト: SMajev/blobjob
 def __init__(self):
     super(IntroScene, self).__init__()
     bg = Layer()
     bg.image = 'bgs/howto_bg.jpg'
     sprite = Sprite(bg.image)
     sprite.x = 400
     sprite.y = 300
     bg.add(sprite)
     self.add(bg)
     self.add(IntroHandlerLayer())
コード例 #13
0
 def __init__(self):
     super(BackgroundLayer, self).__init__(255, 255, 255, 255)
     
     # wall tile (120 x 120 px):
     for i in range(0, settings.WINDOW_SIZE[0], 120):
         for j in range(0, settings.WINDOW_SIZE[1], 120):
             wall_tile = Sprite('wall.png')
             wall_tile.x = wall_tile.image.width / 2 + i
             wall_tile.y = wall_tile.image.height / 2 + j
             self.add(wall_tile)
コード例 #14
0
 def add_circle(self,center,radius):
     cx , cy = center
     sprites = []
     for a in xrange(0, 360, 8):
         b = Sprite('data/npoint.png')#,color=(140,140,140))
         b.x = (cx + radius*cos(radians(a)))*scale+offset
         b.y = (cy + radius*sin(radians(a)))*scale+offset
         b.scale = 1.0/16.0
         self.add(b)
         sprites.append(b)
     return sprites
コード例 #15
0
 def add_wpts(self,wpts):
     sprites = []
     for x,y in wps:
         b = Sprite('data/npoint.png')#,color=(140,140,140))
         b.x = x*scale+offset
         b.y = y*scale+offset
         b.scale = 1.0/8.0
         self.add(b)
         self.add_named('P%s %s'%(x,y),[b])
         sprites.append(b)
     return sprites
コード例 #16
0
ファイル: game_menu.py プロジェクト: HieuLsw/blobjob
    def create_background(self):
        x_size, y_size = director.get_window_size()
        self.sprite = Sprite(self.image)
#        self.sprite.anchor_x = self.sprite.width / 2
#        self.sprite.anchor_y = self.sprite.height / 2
        for x in xrange(0, x_size, self.sprite.width):
            for y in xrange(0, y_size, self.sprite.height):
                sprite = Sprite(self.image)
                sprite.x = x
                sprite.y = y
                self.batch.add(sprite)
コード例 #17
0
 def _load_background(self, bubble_type, px, py, pscale):
     background = Sprite(self.gallery.content["text"]["bubble_" +
                                                      bubble_type])
     background.scale = pscale
     background.image_anchor = 0, 0
     background.x = px
     background.y = py
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
コード例 #18
0
ファイル: game_menu.py プロジェクト: SMajev/blobjob
 def create_background(self):
     x_size, y_size = director.get_window_size()
     self.sprite = Sprite(self.image)
     #        self.sprite.anchor_x = self.sprite.width / 2
     #        self.sprite.anchor_y = self.sprite.height / 2
     for x in xrange(0, x_size, self.sprite.width):
         for y in xrange(0, y_size, self.sprite.height):
             sprite = Sprite(self.image)
             sprite.x = x
             sprite.y = y
             self.batch.add(sprite)
コード例 #19
0
ファイル: display-cocos.py プロジェクト: rynote/tailor
    def check_queue(self, dt=0):
        width, height = cocos.director.director.get_window_size()

        if self.bkg:
            self.bkg.do(
                CallFunc(self.bkg.kill)
            )

        image = fetch_image()
        sprite = Sprite(image)

        end_scale = 1024.0 / image.width * self.scale

        sw = int((image.width * end_scale) / 2)
        sh = int((image.height * end_scale) / 2)

        if random.randint(0, 1):
            sprite.x = 0
        else:
            sprite.x = width

        sprite.y = random.randint(height * .25, height * .75)

        #dst = random.randint(width*.25, width*.75), height / 2
        dst = width / 2, height / 2

        sprite.scale = end_scale * 5
        sprite.opacity = 0
        sprite.do(
            spawn(
                FadeIn(1),
                AccelDeccel(
                    spawn(
                        ScaleTo(end_scale, duration=2),
                        MoveTo(dst, duration=2)))) +
            Delay(self.interval) +
            FadeOut(.5) +
            CallFunc(sprite.kill))

        self._z += 1
        self.add(sprite, z=self._z)
コード例 #20
0
 def _load_background(self):
     background = Sprite(self.gallery.content["display"]["city_hud"])
     self.optimal_scale=(self.config.window_width * self.display_pos_size["display_city_hud"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size["display_city_hud"]["X"]
     background.y = self.config.window_height * self.display_pos_size["display_city_hud"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
コード例 #21
0
ファイル: podium.py プロジェクト: jtietema/racer
    def __init__(self):
        super(Podium, self).__init__()

        self.podium = Layer()
        self.podium.is_event_handler = True
        self.podium.on_key_press = self.on_key_press

        center = director.window.width / 2

        podium_sprite = Sprite('podium.png')
        podium_sprite.image_anchor_y = 0
        podium_sprite.x = center

        self.podium.add(podium_sprite)

        top_3 = state.cup.total_ranking[:3]

        for index, car in enumerate(top_3):
            label = util.Label(text=car.name,
                               font_size=25,
                               anchor_y='bottom',
                               anchor_x='center')
            label.x = center + (X_DIR[index] * BLOCK_WIDTH)
            label.y = HEIGHTS[index] + 20
            self.podium.add(label, z=3)

        self.add(self.podium, z=2)

        fireworks = Fireworks()
        fireworks.x = center
        fireworks.y = director.window.height / 2 + 100
        self.add(fireworks, z=1)

        if state.profile.car in top_3:
            position = top_3.index(state.profile.car)
            earned = MONEY[position]
            head_text = 'You earned $%d!' % (earned, )

            state.profile.money += earned
            state.profile.save()

            if position == 0:
                head_text = 'Congratulations! ' + head_text
        else:
            head_text = 'Better luck next time!'

        head_label = util.Label(text=head_text,
                                font_size=30,
                                anchor_x='center',
                                anchor_y='bottom')
        head_label.x = center
        head_label.y = director.window.height - 75
        self.add(head_label, z=3)
コード例 #22
0
ファイル: game_menu.py プロジェクト: SMajev/blobjob
def get_scene():
    menu_layer = MultiplexLayer(MainMenu(), ConfigMenu())
    #    back = BackgroundLayer('bgs/menu_background.jpg')
    #    back_layer.add(back.back_batch())
    back_layer = Layer()
    bg_sprite = Sprite('bgs/menu_background.jpg')
    bg_sprite.x = bg_sprite.width / 2
    bg_sprite.y = bg_sprite.height / 2
    back_layer.add(bg_sprite)
    scene = MainMenuScene()
    scene.add(back_layer, z=0)
    #    menu_layer.image = 'bgs/menu_background.jpg'
    scene.add(menu_layer)
    return scene
コード例 #23
0
    def menu_xo(self):
        if not self.interact:
            background = Sprite(
                self.gallery.content["display"]["worldmap_hud_interact2"])
            background.image_anchor = 0, 0
            background.scale = self.optimal_scale
            background.x = 0
            background.y = 0
            self.add(background, name="display_worldmap_hud_interact")
            self.interact = True
            opt = {
                "0": {
                    "text": "Prospect for coal",
                    "param": "prospect"
                },
                "1": {
                    "text": "Deploy explosives",
                    "param": "mine"
                },
                "2": {
                    "text": "Discuss",
                    "param": "discuss_xo"
                },
                "3": {
                    "text": "That is all",
                    "param": "end"
                }
            }

            display_interact_box_self = DisplayInteractBox(
                opt, "1", self.optimal_width *
                self.button_positions["display_interact_box_self"]["X"],
                self.optimal_width *
                self.button_positions["display_interact_box_self"]["Y"],
                self.optimal_scale)
            self.add(display_interact_box_self,
                     name="display_interact_box_self")
            label_line_1 = self._load_label_gen("label_line_1")
            self.add(label_line_1, name="label_line_1")
            label_line_2 = self._load_label_gen("label_line_2")
            self.add(label_line_2, name="label_line_2")
            label_line_3 = self._load_label_gen("label_line_3")
            self.add(label_line_3, name="label_line_3")
            label_line_4 = self._load_label_gen("label_line_4")
            self.add(label_line_4, name="label_line_4")
            label_line_5 = self._load_label_gen("label_line_5")
            self.add(label_line_5, name="label_line_5")
            self.clear_text()
            self.get("label_line_1"
                     ).element.text = "Yes Conductor, how can I assist? "
コード例 #24
0
 def display_wagon_info(self, wagon):
     try:
         self.remove("sprite_wagon_selected")
     except:
         A=1
     wagon_selected = Sprite(self.gallery.content["wagon"][self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].display_image+"_c"])
     wagon_selected.image_anchor = 0, 0
     wagon_selected.scale = self.optimal_scale*1.66
     wagon_selected.x = self.optimal_width * self.button_positions["sprite_wagon_selected"]["X"]
     wagon_selected.y = self.optimal_height * self.button_positions["sprite_wagon_selected"]["Y"]
     self.add(wagon_selected, name="sprite_wagon_selected")
     self.get("label_stores_1").element.text=self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].screen_name
     self.get("label_stores_2").element.text="Net weight: "+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].net_weight+", Capacity: "+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].capacity+str(self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].units)+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].storage
     self.update_desc()
コード例 #25
0
ファイル: game_menu.py プロジェクト: HieuLsw/blobjob
def get_scene():
    menu_layer = MultiplexLayer(MainMenu(), ConfigMenu())
#    back = BackgroundLayer('bgs/menu_background.jpg')
#    back_layer.add(back.back_batch())
    back_layer = Layer()
    bg_sprite = Sprite('bgs/menu_background.jpg')
    bg_sprite.x = bg_sprite.width/2
    bg_sprite.y = bg_sprite.height/2
    back_layer.add(bg_sprite)
    scene = MainMenuScene()
    scene.add(back_layer, z=0)
#    menu_layer.image = 'bgs/menu_background.jpg'
    scene.add(menu_layer)
    return scene
コード例 #26
0
ファイル: game_menu.py プロジェクト: HieuLsw/blobjob
def pause_menu():
    w, h = director.window.width, director.window.height
    texture = pyglet.image.Texture.create_for_size(
                    GL_TEXTURE_2D, w, h, GL_RGBA)
    texture.blit_into(pyglet.image.get_buffer_manager().get_color_buffer(), 0,0,0)
    scene = PauseMenuScene()
    bg = Sprite(texture.get_region(0, 0, w, h))
    bg.x=w/2;
    bg.y=h/2;
    scene.add(bg,z=-999)
    overlay = ColorLayer(25,25,25,205)
    scene.add(overlay)
    menu = PauseMenu()
    scene.add(menu)
    return scene
コード例 #27
0
ファイル: boids.py プロジェクト: ricardoquesada/aiamsori
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()
        self.boids = []
        for i in range(20):
            b = Sprite('boid.png')
            b.x = random.randint(0, x)
            b.y = random.randint(0, y)
            b.rotation = 0 #random.randint(0, 360)
            b.speed = 26#200 #random.randint(0, 400)
            self.boids.append(b)
            self.add(b)
        self.mouse = cocos.cocosnode.CocosNode()
        self.schedule(self.update)
コード例 #28
0
 def add_line(self,p0,p1,color=(255,255,255)):
     step = int(fstep*scale)
     x0 , y0 = p0
     x1 , y1 = p1
     d = float(geom.dist(p0,p1))
     a = fstep
     sprites = []
     while a<d:
         b = Sprite('data/npoint.png', color=color)
         b.x = (a*x0 + (d-a)*x1)*scale/d + offset
         b.y = (a*y0 + (d-a)*y1)*scale/d + offset
         b.scale = 1.0/16.0
         self.add(b)
         sprites.append(b)
         a += fstep
     return sprites
コード例 #29
0
ファイル: game_menu.py プロジェクト: SMajev/blobjob
def pause_menu():
    w, h = director.window.width, director.window.height
    texture = pyglet.image.Texture.create_for_size(GL_TEXTURE_2D, w, h,
                                                   GL_RGBA)
    texture.blit_into(pyglet.image.get_buffer_manager().get_color_buffer(), 0,
                      0, 0)
    scene = PauseMenuScene()
    bg = Sprite(texture.get_region(0, 0, w, h))
    bg.x = w / 2
    bg.y = h / 2
    scene.add(bg, z=-999)
    overlay = ColorLayer(25, 25, 25, 205)
    scene.add(overlay)
    menu = PauseMenu()
    scene.add(menu)
    return scene
コード例 #30
0
 def _load_background(self):
     background = Sprite(self.gallery.content["display"]["worldmap_hud"])
     self.optimal_scale = (self.config.window_width *
                           self.display_pos_size["display_worldmap_hud"]
                           ["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_worldmap_hud"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_worldmap_hud"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     black_base = ColorLayer(0,
                             0,
                             0,
                             255,
                             width=background.width,
                             height=background.height)
     black_base.x = background.x
     black_base.y = background.y
     self.add(black_base)
     self._load_button_gen("button", "engine", events.emit_show_engine,
                           "button_engine", 0, 1, 0.9)
     self._load_button_gen("button", "quarters", events.emit_show_quarters,
                           "button_quarters", 0, 1, 0.9)
     self._load_button_gen("button", "cnc", events.emit_show_cnc,
                           "button_cnc", 0, 1, 0.9)
     self._load_button_gen("button", "minimap", events.emit_show_minimap,
                           "button_minimap", 0, 1, 0.9)
     self._load_button_gen("button", "find_engine", events.emit_find_engine,
                           "button_find_engine", 0, 1, 0.9)
     self._load_button_gen("button", "arrow_left",
                           events.emit_scroll_minitrain,
                           "button_arrow_left", 0, 0.4, 0.95)
     self._load_button_gen("button", "arrow_right",
                           events.emit_scroll_minitrain,
                           "button_arrow_right", 0, 0.4, 0.95)
     #self._load_button_direction()
     self._load_button_gen("button", "break_on", events.emit_switch_break,
                           "button_break", 0, 1, 0.95)
     self._load_button_gen("button", "direction_for",
                           events.emit_switch_direction, "button_direction",
                           0, 1, 0.95)
     self.add(background)
コード例 #31
0
    def _load_interface(self):
        hud = Sprite(self.gallery.content["display"]["mainmenu_hud"])
        hud.image_anchor = 0, 0
        hud.scale = self.optimal_scale
        hud.x = 0
        hud.y = 0
        self.add(hud)

        self._load_button_gen("button", "startgame", events.emit_start_game,
                              "button_startgame", 0, 0.4, 0.95)
        self._load_button_gen("button", "loadgame", events.emit_load_game,
                              "button_loadgame", 0, 0.4, 0.95)
        self._load_button_gen("button", "sound_" + self.sound_on_off,
                              events.emit_sound_switch, "button_sound_switch",
                              0, 0.4, 0.95)
        self._load_button_gen("button", "startgame", events.emit_quick_battle,
                              "button_quickbattle", 0, 0.4, 0.95)
コード例 #32
0
 def _load_button_speedregulator(self):
     self.add(ButtonSpeedRegulator(self.optimal_scale),
              name="button_speedregulator")
     button = self.children_names["button_speedregulator"]
     button.x = self.optimal_width * self.button_positions[
         "button_speedregulator"]["X"] + self.left_margin
     button.y = self.optimal_height * self.button_positions[
         "button_speedregulator"]["Y"] + self.bottom_margin
     knob_speedregulator = Sprite(
         self.gallery.content["knob"]["speedregulator"])
     knob_speedregulator.scale = self.optimal_scale
     x = self.optimal_width * self.button_positions[
         "button_speedregulator"]["X"]
     y = self.optimal_height * self.button_positions[
         "button_speedregulator"]["Y"]
     knob_speedregulator.x = x + self.left_margin + (button.width * 0.15)
     knob_speedregulator.y = y + self.bottom_margin + (button.height * 0.65)
     self.add(knob_speedregulator, name="knob_speedregulator")
コード例 #33
0
 def refresh_labels(self):
     if self.transarctica.update_minitrain:
         xx = self.optimal_width * 0.985
         for sp in self.get_children():
             self.remove(sp)
         white_base = ColorLayer(235,
                                 200,
                                 130,
                                 255,
                                 width=self.optimal_width * 6,
                                 height=self.optimal_height + 15)
         white_base.x = self.left_margin - (self.optimal_width * 3)
         white_base.y = self.bottom_margin
         self.add(white_base)
         for wg in self.transarctica.train_layout:
             train = Sprite(
                 self.gallery.content["wagon"][self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image +
                                               "_tr"])
             train.image_anchor = 0, 0
             train.scale = self.optimal_scale * 0.40
             xx = xx - train.width
             train.x = xx
             train.y = self.bottom_margin + 10
             #damage_base = ColorLayer( 85*int(self.config.conf_wagons[self.transarctica.train_layout[wg]].damage),45,45,45*int(self.config.conf_wagons[self.transarctica.train_layout[wg]].damage), width=train.width, height=train.height)
             self.add(train)
             if int(self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage) > 0:
                 damage_base = ColorLayer(
                     255,
                     0,
                     0,
                     255,
                     width=trunc(
                         (train.width / 4) *
                         (4 - int(self.config.conf_wagons[
                             self.transarctica.train_layout[wg]].damage))),
                     height=train.height // 10)
                 damage_base.x = train.x
                 damage_base.y = train.y + damage_base.height * 9
                 self.add(damage_base)
         self.transarctica.update_minitrain = False
コード例 #34
0
ファイル: lab.py プロジェクト: gitTARDIS/HATman
	def drawSprites(self):
		# Sprites for the wayNodes = dots that are eaten by pacman
		self.nodeSprites = []

		# add nodeSprites to array, add all to layer
		for nodes in self.nodes:
			for node in nodes:
				if node.sort == "cross":
					tempSprite = Sprite("images/cnode.png")
				if node.sort == "wall":
					tempSprite = Sprite("images/wall.png")
				if node.sort == "way":
					tempSprite = Sprite("images/node.png")

				tempSprite.x = node.x
				tempSprite.y = node.y

				if node.sort == "cross" or node.sort == "way":
					self.nodeSprites.append(tempSprite)

				self.add(tempSprite)
コード例 #35
0
 def _load_trade_boxes(self):
     self.remove_trade_boxes()
     if self.trade_display:
         self._load_button_gen("button", "drop",
                               events.emit_commerce_switch_trade_dump,
                               "button_switch", 0, 1, 0.95)
         for item in self.items_for_trade:
             trade_bracket = Sprite(
                 self.gallery.content["item"][self.config.conf_items[
                     self.items_for_trade[item]["item_id"]].display_image +
                                              "_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["Y"]
             self.add(trade_bracket, name="trade_bracket" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_trade[item]
                                        ["item_id"]].item_name,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.138),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.152)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=16 * self.optimal_scale,
                 anchor_x="center",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_name" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_trade[item]
                                        ["item_id"]].storage,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.130)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_storage" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.104)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_supply" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.078)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_demand" + str(item))
             label_item_name = Label(
                 "Price: " + str(self.items_for_trade[item]["price"]),
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.052)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_price" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.026)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_hold" + str(item))
             #if (self.items_for_trade[item]["sell_units"] > 0):
             self._load_button_gen("button", "plus", events.emit_item_buy,
                                   "button_buy" + str(item), item, 0.72,
                                   0.95)
             #if (self.items_for_trade[item]["buy_units"] > 0):
             self._load_button_gen("button", "minus", events.emit_item_sell,
                                   "button_sell" + str(item), item, 0.72,
                                   0.95)
     else:
         self._load_button_gen("button", "trade",
                               events.emit_commerce_switch_trade_dump,
                               "button_switch", 0, 1, 0.95)
         for item in self.items_for_dump:
             trade_bracket = Sprite(
                 self.gallery.content["item"][self.config.conf_items[
                     self.items_for_dump[item]["item_id"]].display_image +
                                              "_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["Y"]
             self.add(trade_bracket, name="trade_bracket" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_dump[item]
                                        ["item_id"]].item_name,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.138),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.152)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=16 * self.optimal_scale,
                 anchor_x="center",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_name" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_dump[item]
                                        ["item_id"]].storage,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.130)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_storage" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.104)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(
                 label_item_name, name="button_buy" +
                 str(item))  #just to have an object with the name to remove
             self.add(label_item_name,
                      name="trade_bracket_item_hold" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.078)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_demand" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.052)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_price" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.026)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_supply" + str(item))
             self._load_button_gen("button", "minus", events.emit_item_sell,
                                   "button_sell" + str(item), item, 0.72,
                                   0.95)
     self.update_desc()
コード例 #36
0
 def draw_wagons_buttons(self):
     if self.service_mode == "R":
         self.get(
             "label_line_4"
         ).element.text = "Select wagon to Repair." + "You have " + str(
             self.transarctica.cargo_manifest[
                 self.transarctica.get_item_id_from_name(
                     "Lignite")]["hold"]) + " baks lignite"
     elif self.service_mode == "S":
         self.get(
             "label_line_4"
         ).element.text = "Select wagons to Switch." + "You have " + str(
             self.transarctica.cargo_manifest[
                 self.transarctica.get_item_id_from_name(
                     "Lignite")]["hold"]) + " baks lignite"
     wagon_scale = 0.30
     right_pad = self.config.window_width * 0.85
     curr_x = right_pad
     curr_y = self.optimal_height * 0.15
     train = Sprite(self.gallery.content["wagon"]["blank"])
     train.scale = self.optimal_scale * wagon_scale
     divider = train.width
     if self.service_mode == "S":
         self._load_button_gen("wagon", "blank", events.emit_wagon_service,
                               "button_wagon_b" + str(0), 100, wagon_scale,
                               0.95, curr_x, curr_y)
         self.elements_to_remove.append("button_wagon_b" + str(0))
         for wg in self.transarctica.train_layout:
             train = Sprite(
                 self.gallery.content["wagon"][self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image])
             train.image_anchor = 0, 0
             train.scale = self.optimal_scale * wagon_scale
             curr_x = curr_x - train.width
             if curr_x <= 50:
                 right_pad -= self.config.window_width * 0.05
                 curr_x = right_pad - train.width
                 curr_y -= self.optimal_height * 0.05
             train.x = curr_x
             train.y = curr_y
             self._load_button_gen(
                 "wagon", self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image,
                 events.emit_wagon_service, "button_wagon_" + str(wg), wg,
                 wagon_scale, 0.95, curr_x, curr_y)
             self.elements_to_remove.append("button_wagon_" + str(wg))
             if int(self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage) > 0:
                 damage_base = ColorLayer(
                     255,
                     0,
                     0,
                     255,
                     width=trunc(
                         (train.width / 4) *
                         (4 - int(self.config.conf_wagons[
                             self.transarctica.train_layout[wg]].damage))),
                     height=train.height // 10)
                 damage_base.x = train.x
                 damage_base.y = train.y + damage_base.height * 9
                 self.add(damage_base, name="healthbar_wagon_" + str(wg))
                 self.elements_to_remove.append("healthbar_wagon_" +
                                                str(wg))
             curr_x = curr_x - divider
             self._load_button_gen("wagon", "blank",
                                   events.emit_wagon_service,
                                   "button_wagon_b" + str(wg + 1), 101 + wg,
                                   wagon_scale, 0.95, curr_x, curr_y)
             self.elements_to_remove.append("button_wagon_b" + str(wg + 1))
     if self.service_mode == "R":
         for wg in self.transarctica.train_layout:
             if self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage > 0:
                 train = Sprite(
                     self.gallery.content["wagon"][self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].display_image])
                 train.image_anchor = 0, 0
                 train.scale = self.optimal_scale * wagon_scale
                 curr_x = curr_x - train.width
                 if curr_x <= 50:
                     right_pad -= self.config.window_width * 0.05
                     curr_x = right_pad - train.width
                     curr_y -= self.optimal_height * 0.05
                 train.x = curr_x
                 train.y = curr_y
                 self._load_button_gen(
                     "wagon", self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].display_image,
                     events.emit_wagon_service, "button_wagon_" + str(wg),
                     wg, wagon_scale, 0.95, curr_x, curr_y)
                 self.elements_to_remove.append("button_wagon_" + str(wg))
                 if int(self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].damage) > 0:
                     damage_base = ColorLayer(
                         255,
                         0,
                         0,
                         255,
                         width=trunc(
                             (train.width / 4) *
                             (4 - int(self.config.conf_wagons[
                                 self.transarctica.train_layout[wg]].damage)
                              )),
                         height=train.height // 10)
                     damage_base.x = train.x
                     damage_base.y = train.y + damage_base.height * 9
                     self.add(damage_base,
                              name="healthbar_wagon_" + str(wg))
                     self.elements_to_remove.append("healthbar_wagon_" +
                                                    str(wg))
コード例 #37
0
ファイル: wptlayer.py プロジェクト: ricardoquesada/aiamsori
 def spawn_many(self,wpt_list):
     for e in wpt_list:
         b = Sprite('data/wpt.png')
         b.x = e[0]
         b.y = e[1]
         self.add(b)
コード例 #38
0
    def _load_background(self):
        background = Sprite(self.gallery.content["display"]["worldmap_engine"])
        self.optimal_scale = (self.config.window_width *
                              self.display_pos_size["display_worldmap_engine"]
                              ["W"]) / background.width
        background.image_anchor = 0, 0
        background.scale = self.optimal_scale
        background.x = self.config.window_width * self.display_pos_size[
            "display_worldmap_engine"]["X"]
        background.y = self.config.window_height * self.display_pos_size[
            "display_worldmap_engine"]["Y"]
        self.left_margin = background.x
        self.bottom_margin = background.y
        self.optimal_width = background.width
        self.optimal_height = background.height

        pic_fire = Sprite(
            self.gallery.content["display"]["worldmap_engine_fire"])
        pic_fire.image_anchor = 0, 0
        pic_fire.scale = self.optimal_scale
        pic_fire.x = self.optimal_width * self.button_positions["pic_fire"][
            "X"] + self.left_margin
        pic_fire.y = self.optimal_height * self.button_positions["pic_fire"][
            "Y"] + self.bottom_margin
        self.add(pic_fire, name="pic_fire")

        self.ps_fire = Fire()
        self.ps_fire.size = 120
        self.ps_fire.position = (
            self.optimal_width * self.button_positions["ps_fire"]["X"] +
            self.left_margin,
            self.optimal_height * self.button_positions["ps_fire"]["Y"] +
            self.bottom_margin)
        self.add(self.ps_fire, name="ps_fire")

        self.add(background)

        pic_anthracite = Sprite(
            self.gallery.content["display"]["worldmap_engine_anthracite"])
        pic_anthracite.image_anchor = 0, 0
        pic_anthracite.scale = self.optimal_scale
        pic_anthracite.x = self.optimal_width * self.button_positions[
            "pic_anthracite"]["X"] + self.left_margin
        pic_anthracite.y = self.optimal_height * self.button_positions[
            "pic_anthracite"]["Y"] + self.bottom_margin
        self.add(pic_anthracite, name="pic_anthracite")

        pic_lignite = Sprite(
            self.gallery.content["display"]["worldmap_engine_lignite"])
        pic_lignite.image_anchor = 0, 0
        pic_lignite.scale = self.optimal_scale
        pic_lignite.x = self.optimal_width * self.button_positions[
            "pic_lignite"]["X"] + self.left_margin
        pic_lignite.y = self.optimal_height * self.button_positions[
            "pic_lignite"]["Y"] + self.bottom_margin
        self.add(pic_lignite, name="pic_lignite")

        self.ps_alarm = Sun()
        self.ps_alarm.total_particles = 20
        self.ps_alarm.speed = 0.0
        self.ps_alarm.speed_var = 0.0
        self.ps_alarm.life_var = 0.0
        self.ps_alarm.blend_additive = True
        self.ps_alarm.position = (
            self.optimal_width * self.button_positions["ps_alarm"]["X"] +
            self.left_margin), (
                self.optimal_height * self.button_positions["ps_alarm"]["Y"] +
                self.bottom_margin)
        self.ps_alarm.start_color = Color(1, 0.40, 0.40, 0.40)
        self.ps_alarm.size = 50.0