Exemplo n.º 1
0
class MessageInstruction(object):
    def __init__(self, parent_layer, message, has_image_background, x, y, width, height, font):
        self.parent_layer = parent_layer
        self.background_layer = ImageLayer(os.path.join('images','tutorial','background.png'))
        self.message = message
        self.has_image_background = has_image_background
        self.message_label = Label(
            self.message, font_name='Rabiohead', font_size=font,
            width=width, height=height,
            color=(0, 0, 0, 255),
            anchor_x='center', anchor_y='center', multiline = True)

        if(self.has_image_background == True):
            # Position needs to be worked out
            self.background_layer.postition = 300, 500
            self.parent_layer.add(self.background_layer)
            self.message_label.position = 50, 50
            self.background_layer.add(self.message_label)
        else:
            self.message_label.position = x, y
            self.parent_layer.add(self.message_label)

    def removeMessage(self):
        if(self.has_image_background == True):
            self.parent_layer.kill()
        else:
            self.message_label.kill()
Exemplo n.º 2
0
 def start_game(self):
     g = cocos.scene.Scene(self.map, self)
     g.add(ImageLayer(
         os.path.join("images", "backgrounds", "notebook-paper.png")),
           z=BACKGROUND_Z)
     self.connectedToServer = True
     cocos.director.director.push(g)
Exemplo n.º 3
0
 def on_win(self):
     Objects.reset_game()
     server = Objects.get_server(self.levelName)
     server.curLevel = self.level+1
     utils.play_sound("Enter.wav")
     game = Scene(server.map, server)
     game.add(ImageLayer(os.path.join("images", "backgrounds", "notebook-paper.png")), z=BACKGROUND_Z)
     director.push(game)
     menu_player.stop()
     self.game_started = True
Exemplo n.º 4
0
    def __init__(self, parent_layer, message, image):
        super(MessageAlert, self).__init__()
        self.message_layer = ImageLayer(image)
        self.message_layer_height = 400  # sets the constants
        self.message_layer_width = 300  # set the constants
        self.parent_layer = parent_layer
        self.message = message
        self.message_label = Label(
            self.message, font_name='Rabiohead', font_size=26,
            x=self.message_layer_width / 2, y=self.message_layer_height / 2,
            width=self.message_layer_width - 100, height=self.message_layer_height - 100,
            color=(0, 0, 0, 255),
            anchor_x='center', anchor_y='center', multiline = True)

        # added text to specified parent layer(should be the
        # self.game_controller_layer of controller.py)
        self.message_label.position = 30, -240
        self.message_layer.add(self.message_label)
        self.message_layer.position = 0, 0
        self.parent_layer.add(self.message_layer)
Exemplo n.º 5
0
    def __init__(self):
        super(HelpZoraScene, self).__init__()
        self.background = ImageLayer(os.path.join("images","backgrounds","chalkboard_align_topleft.png"))
        self.background.position=(0, 0)
        self.background.scale=1
        self.background.anchor=(0.0, 0.0)
        self.background.z=1
        self.poem = RichLabel(text="Help Zora!", position=(500, 500), width=300, font_name='Rabiohead', font_size=27)
        self.image = Sprite(os.path.join("images","maps","surrender.png"),position=(700, 500),scale=0.4)

        self.add(self.background)
        self.add(self.poem)
        self.add(self.image)
Exemplo n.º 6
0
    def start_game(self):
        constants.MULTIPLAYER = True
        server = Objects.get_controller()
        server.client_start_game()
        if server.serverStarted:
            utils.play_sound("Enter.wav")
            game = Scene(server.map, server)
            menu_player.stop()
            game.add(ImageLayer(
                     os.path.join("images", "backgrounds", "notebook-paper.png")), z=BACKGROUND_Z)
            director.push(game)
            self.game_started = True

        else:
            print "start server first"
Exemplo n.º 7
0
    def end_game(self, didWin):
        self.stop_server()
        if constants.MUSIC:
            music.theme_player.stop()

        for child in self.map.get_children():
            child.stop()

        if didWin:
            s = cocos.scene.Scene(EndMenu("Won", self.curLevel))
        else:
            s = cocos.scene.Scene(EndMenu("Lost", self.curLevel))
        s.add(ImageLayer(
            os.path.join("images", "backgrounds", "menu-chalkboard.png")),
              z=-1)
        cocos.director.director.replace(s)
Exemplo n.º 8
0
 def __init__(self):
     super(IntroText, self).__init__()
     self.poem = RichLabel(text=POEM, position=(100, 300), multiline=True, width=300, font_name='ChalkDust', font_size=27)        
     self.introZora = Sprite(os.path.join("images","intro_images","zora.png"), position=(750, 400), scale=1, opacity=0)
     self.introTownmap = Sprite(os.path.join("images","intro_images","town-map.png"), position=(830, 400), scale=.75,opacity=0)
     self.introNetmap = Sprite(os.path.join("images","intro_images","network-map.png"), position=(800, 400), scale=.75,opacity=0)
     self.introNotebook = Sprite(os.path.join("images","intro_images","notebook.png"), position=(780, 400), scale=.75,opacity=0)
     self.background = ImageLayer(os.path.join("images","backgrounds","chalkboard_align_topleft.png"))
     self.background.position=(0, 0)
     self.background.scale=1
     self.background.anchor=(0.0, 0.0)
     self.background.z=1
     self.add(self.poem)
     self.add(self.introZora)
     self.add(self.introTownmap)
     self.add(self.introNetmap)
     self.add(self.introNotebook)
     self.add(self.poem)
     self.add(self.background)
     self.help = RichLabel(text="Help Zora take down the school's network!", halign='center',position=(100, 500), multiline=True, width=700, font_name='ChalkDust', font_size=40)
     self.help.opacity = 1
     self.add(self.help,z=1)
Exemplo n.º 9
0
from cocos.scenes.transitions import FadeTransition
from cocos.text import Label, TextElement, RichLabel
from cocos.utils import SequenceScene
from cocos.actions.interval_actions import MoveBy, Delay
from constants import BACKGROUND_Z, WINDOW_WIDTH, WINDOW_HEIGHT, FULL_SCREEN
from imageLayer import ImageLayer
from game import *
from cocos.actions.interval_actions import FadeIn

from cocos import pygletreactor
pygletreactor.install()

director.init(width=WINDOW_WIDTH, height=WINDOW_HEIGHT, fullscreen=FULL_SCREEN)

s = Scene(MainMenu())
menu_background = ImageLayer(os.path.join("images", "backgrounds", "menu-chalkboard.png"))
menu_background.position = (0,0)
menu_background.anchor = (0.0, 0.0)
menu_background.scale = 1
s.add(menu_background)


# blank_scene = Scene()
# director.run(FadeTransition(s, 1, blank_scene))


def director_run_no_loop(scene):
    # this is the same as director.run, without the eventloop

    director.scene_stack.append(director.scene)
    director._set_scene(scene)
Exemplo n.º 10
0
from cocos.scenes.transitions import FadeTransition
from cocos.text import Label, TextElement, RichLabel
from cocos.utils import SequenceScene
from cocos.actions.interval_actions import MoveBy, Delay
from constants import BACKGROUND_Z, WINDOW_WIDTH, WINDOW_HEIGHT, FULL_SCREEN
from imageLayer import ImageLayer
from game import *
from cocos.actions.interval_actions import FadeIn

from cocos import pygletreactor
pygletreactor.install()

director.init(width=WINDOW_WIDTH, height=WINDOW_HEIGHT, fullscreen=FULL_SCREEN)

s = Scene(MainMenu())
menu_background = ImageLayer(
    os.path.join("images", "backgrounds", "menu-chalkboard.png"))
menu_background.position = (0, 0)
menu_background.anchor = (0.0, 0.0)
menu_background.scale = 1
s.add(menu_background)

# blank_scene = Scene()
# director.run(FadeTransition(s, 1, blank_scene))


def director_run_no_loop(scene):
    # this is the same as director.run, without the eventloop

    director.scene_stack.append(director.scene)
    director._set_scene(scene)
Exemplo n.º 11
0
 def on_multi(self):
     utils.play_sound("Enter.wav")
     s = Scene(MultiplayerMenu(self.levelName))
     s.add(ImageLayer(os.path.join("images", "backgrounds", "menu-chalkboard.png")))
     director.push(s)