Example #1
0
    def __init__(self):
        self.date_window = SimpleBox(pygame.Rect(500,10,90,15),Static.beige,False,True)
        self.date_window.add_sprite(MText(0,Point(2,2),100,Resources().font12,time.strftime("%d/%m/%Y"),Static.gray))
        
        self.main_options = MainOptions(Point(-170,10))
        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().background1))
        self.foreground = SimpleBox(pygame.Rect(0,0,480,320))
        self.foreground.add_sprite(MSprite(1,Point(0,0),Resources().foreground1))

        self.monster = SimpleBox(pygame.Rect(230,225,0,0))
        self.monster.add_sprite(MSprite(1,Point(0,0),Resources().monster_placeholder))
        return
Example #2
0
    def __init__(self):       
        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().title_bg))
        self.title = SimpleBox(pygame.Rect(Static.center(0,256,Static.width),-50,256,32),Static.beige,False,True)
        self.title.add_sprite(MText(0,Point(20,3),256,Resources().font24,"Choose a name!",Static.gray))
        self.monster = SimpleBox(pygame.Rect(200,-100,0,0))
        self.monster.add_sprite(MSprite(1,Point(0,0),Resources().monster_placeholder))
        self.virtual_keyboard = VirtualKeyboard(Point(50,600))

        self.name = ""
        self.name_container = SimpleBox(pygame.Rect(Static.center(0,256,Static.width),-50,256,32),Static.gray,False,True)
        self.name_container.add_sprite(MText(0,Point(20,3),256,Resources().font24,"",Static.white))
        return
Example #3
0
    def __init__(self):
        SoundManager().load_track("shop_track2.ogg")
        SoundManager().play(-1)

        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().title_bg))

        self.title_box = SimpleBox(pygame.Rect(Static.center(0,480,Static.width),0,480,280))
        self.title_box.add_sprite(MSprite(1,Point(0,0),Resources().title))

        self.press_start_box = SimpleBox(pygame.Rect(Static.center(0,480,Static.width),280,480,12))
        text = MText(1,Point(0,0),480,Resources().font24,"PRESS START",Static.gray,[MTextEffect.blinking])

        text.loc.x = Static.center(0,text.image.get_width(),480)
        self.press_start_box.add_sprite(text)
        return
Example #4
0
 def __init__(self):
     self.title = Title()
     self.create_monster = CreateMonster()
     self.game_screen = GameScreen()
     self.currentscreen = Screen()
     self.fps_container = SimpleBox(pygame.Rect(10,10,0,0))
     self.fps_container.add_sprite(MText(1,Point(0,0),50,Resources().font12,""))
     
     self.change_screen(self.title,False);
     return
Example #5
0
    def __init__(self,origin = Point(0,0)):
        super().__init__(origin)
        self.train_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 10,150,32),Static.regent_gray,False,True)
        self.train_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Train",Static.gray))

        self.battle_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 51,150,32),Static.beige,False,True)
        self.battle_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Battle",Static.gray))

        self.interact_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 92,150,32),Static.beige,False,True)
        self.interact_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Interact",Static.gray))

        self.shop_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 133,150,32),Static.beige,False,True)
        self.shop_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Shop",Static.gray))

        self.items_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 174,150,32),Static.beige,False,True)
        self.items_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Items",Static.gray))

        self.netbattle_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 215,150,32),Static.gray,False,True)
        self.netbattle_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Net Battle",Static.light_gray))

        self.train_button.down = self.battle_button
        self.battle_button.up = self.train_button
        self.battle_button.down = self.interact_button
        self.interact_button.up = self.battle_button
        self.interact_button.down = self.shop_button
        self.shop_button.up = self.interact_button
        self.shop_button.down = self.items_button
        self.items_button.up = self.shop_button
        self.items_button.down = self.netbattle_button
        self.netbattle_button.up = self.items_button
        
        self.selected = self.train_button
        return
Example #6
0
class GameManager(metaclass = Singleton):
    def __init__(self):
        self.title = Title()
        self.create_monster = CreateMonster()
        self.game_screen = GameScreen()
        self.currentscreen = Screen()
        self.fps_container = SimpleBox(pygame.Rect(10,10,0,0))
        self.fps_container.add_sprite(MText(1,Point(0,0),50,Resources().font12,""))
        
        self.change_screen(self.title,False);
        return

    def update(self):
        self.fps_container.update()
        self.fps_container.get_sprite(1).set_text("%.3f" % TimeManager().fps)

        InputManager().update_start()
        if self.currentscreen is not None:
            self.currentscreen.update()
        InputManager().update_end()
        return

    def draw(self,screen):
        if self.currentscreen is not None:
            self.currentscreen.draw(screen)

        self.fps_container.draw(screen)
        return

    def change_screen(self, new_screen, perform_transition = False):
        if self.currentscreen is not None:
            self.currentscreen.close()

        if perform_transition:
            self.currentscreen = new_screen
        else:
            self.currentscreen = new_screen
        self.currentscreen.open()
        return
Example #7
0
    def __init__(self,origin = Point(0,0)):
        super().__init__(origin)
        self.keyboard = SimpleBox(pygame.Rect(origin.x,origin.y,0,0))
        self.keys = [[0]*3 for i in range(10)]
        self.selected = (0,0)

        alpha_count = 0

        self.pressed_key = ""

        for y in range(0,3):
            for x in range(0, 10):
                key = SimpleBox(pygame.Rect(0,0,0,0))
                if alpha_count < 26:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,24,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,Static.alpha[alpha_count]))
                    key.data1 = Static.alpha[alpha_count]
                if alpha_count == 26:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,62,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,"<-"))
                    key.data1 = "<-"
                if alpha_count == 28:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,62,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,"GO!"))
                    key.data1 = "GO"

                alpha_count += 1
                self.keys[x][y] = key
                self.keyboard.add_child(key)

        self.keys[self.selected[0]][self.selected[1]].bg.set_color(Static.regent_gray)
Example #8
0
class CreateMonster(Screen):
    def __init__(self):       
        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().title_bg))
        self.title = SimpleBox(pygame.Rect(Static.center(0,256,Static.width),-50,256,32),Static.beige,False,True)
        self.title.add_sprite(MText(0,Point(20,3),256,Resources().font24,"Choose a name!",Static.gray))
        self.monster = SimpleBox(pygame.Rect(200,-100,0,0))
        self.monster.add_sprite(MSprite(1,Point(0,0),Resources().monster_placeholder))
        self.virtual_keyboard = VirtualKeyboard(Point(50,600))

        self.name = ""
        self.name_container = SimpleBox(pygame.Rect(Static.center(0,256,Static.width),-50,256,32),Static.gray,False,True)
        self.name_container.add_sprite(MText(0,Point(20,3),256,Resources().font24,"",Static.white))
        return
    
    def draw(self,screen):
        self.background.draw(screen)
        self.title.draw(screen)
        self.monster.draw(screen)
        self.name_container.draw(screen)
        self.virtual_keyboard.draw(screen)
        return

    def update(self):
        self.background.update()
        self.title.update()
        self.monster.update()
        self.name_container.update()
        self.virtual_keyboard.update()

        if self.virtual_keyboard.pressed_key != "":
            if self.virtual_keyboard.pressed_key == "<-":
                self.name = self.name[:-1]
                self.name_container.get_sprite(0).set_text(self.name)
            elif self.virtual_keyboard.pressed_key == "GO":
                if self.name != "":
                    GameManager().change_screen(GameManager().game_screen,False)
            else:
                self.name = self.name + self.virtual_keyboard.pressed_key
                self.name_container.get_sprite(0).set_text(self.name)

        if InputManager().key_pressed(MKey.BUTTON_2,True):
            GameManager().change_screen(GameManager().game_screen,False)
        return

    def open(self):
        self.name = ""
        self.name_container.get_sprite(0).set_text(self.name)

        self.title.set_tween((Static.center(0,256,Static.width),15))
        self.monster.set_tween((200,60))
        self.name_container.set_tween((Static.center(0,256,Static.width),135))
        self.virtual_keyboard.open(Point(50,175))
        return

    def close(self):
        self.title.set_position((Static.center(0,256,Static.width),-100))
        self.monster.set_position((200,-100))
        self.name_container.set_position((Static.center(0,256,Static.width),-100))
        self.virtual_keyboard.close(Point(50,600))
        return
Example #9
0
class VirtualKeyboard(Window):

    def __init__(self,origin = Point(0,0)):
        super().__init__(origin)
        self.keyboard = SimpleBox(pygame.Rect(origin.x,origin.y,0,0))
        self.keys = [[0]*3 for i in range(10)]
        self.selected = (0,0)

        alpha_count = 0

        self.pressed_key = ""

        for y in range(0,3):
            for x in range(0, 10):
                key = SimpleBox(pygame.Rect(0,0,0,0))
                if alpha_count < 26:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,24,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,Static.alpha[alpha_count]))
                    key.data1 = Static.alpha[alpha_count]
                if alpha_count == 26:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,62,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,"<-"))
                    key.data1 = "<-"
                if alpha_count == 28:
                    key = SimpleBox(pygame.Rect(x * 38,y * 38,62,24),Static.beige,False,True)
                    key.add_sprite(MText(0,Point(7,5),24,Resources().font12,"GO!"))
                    key.data1 = "GO"

                alpha_count += 1
                self.keys[x][y] = key
                self.keyboard.add_child(key)

        self.keys[self.selected[0]][self.selected[1]].bg.set_color(Static.regent_gray)

    def update(self):
        self.keyboard.update()
        previous = self.selected
        keychange = False
        self.pressed_key = ""
        if InputManager().key_pressed(MKey.RIGHT,True):
            if self.selected[0] < 9:
                self.selected = (self.selected[0] + 1,self.selected[1])
                keychange = True
        if InputManager().key_pressed(MKey.DOWN,True):
            if self.selected[1] < 2:
                self.selected = (self.selected[0],self.selected[1] +1)
                keychange = True
        if InputManager().key_pressed(MKey.LEFT,True):
            if self.selected[0] > 0:
                self.selected = (self.selected[0] -1,self.selected[1])
                keychange = True
        if InputManager().key_pressed(MKey.UP,True):
            if self.selected[1] > 0:
                self.selected = (self.selected[0],self.selected[1]-1)
                keychange = True

        if keychange == True:
            if(self.selected[0] == 7 and self.selected[1] == 2):
                self.selected = (6, 2) 
            if(self.selected[0] == 9 and self.selected[1] == 2):
                self.selected = (8, 2) 
            if previous == self.selected:
                self.selected = (8,2)
            self.keys[previous[0]][previous[1]].bg.set_color(Static.beige)
            self.keys[self.selected[0]][self.selected[1]].bg.set_color(Static.regent_gray)

        if InputManager().key_pressed(MKey.BUTTON_1,True):
            self.pressed_key = self.keys[self.selected[0]][self.selected[1]].data1

    def draw(self, screen):
        self.keyboard.draw(screen)
        #for row in self.keys:
        #    for k in row:
        #        k.draw(screen)

    def open(self,loc):
        self.keyboard.set_tween((loc.x,loc.y))
        return
    def close(self,loc):
        self.keyboard.set_position((loc.x,loc.y))
        return
Example #10
0
class GameScreen(Screen):
    def __init__(self):
        self.date_window = SimpleBox(pygame.Rect(500,10,90,15),Static.beige,False,True)
        self.date_window.add_sprite(MText(0,Point(2,2),100,Resources().font12,time.strftime("%d/%m/%Y"),Static.gray))
        
        self.main_options = MainOptions(Point(-170,10))
        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().background1))
        self.foreground = SimpleBox(pygame.Rect(0,0,480,320))
        self.foreground.add_sprite(MSprite(1,Point(0,0),Resources().foreground1))

        self.monster = SimpleBox(pygame.Rect(230,225,0,0))
        self.monster.add_sprite(MSprite(1,Point(0,0),Resources().monster_placeholder))
        return
    
    def draw(self,screen):
        self.background.draw(screen)
        self.foreground.draw(screen)
        self.main_options.draw(screen)
        self.date_window.draw(screen)
        self.monster.draw(screen)
        return

    def update(self):
        self.background.update()
        self.foreground.update()
        self.main_options.update()
        self.date_window.update()
        self.monster.update()
        return

    def open(self):
        self.main_options.open(Point(10,10))
        self.date_window.set_tween((380,10))
        return
    
    def close(self):
        self.main_options.close(Point(-170,1))
        self.date_window.set_tween((500,10))
        return
Example #11
0
class Title(Screen):
    def __init__(self):
        SoundManager().load_track("shop_track2.ogg")
        SoundManager().play(-1)

        self.background = SimpleBox(pygame.Rect(0,0,480,320))
        self.background.add_sprite(MSprite(1,Point(0,0),Resources().title_bg))

        self.title_box = SimpleBox(pygame.Rect(Static.center(0,480,Static.width),0,480,280))
        self.title_box.add_sprite(MSprite(1,Point(0,0),Resources().title))

        self.press_start_box = SimpleBox(pygame.Rect(Static.center(0,480,Static.width),280,480,12))
        text = MText(1,Point(0,0),480,Resources().font24,"PRESS START",Static.gray,[MTextEffect.blinking])

        text.loc.x = Static.center(0,text.image.get_width(),480)
        self.press_start_box.add_sprite(text)
        return

    def draw(self,screen):
        self.background.draw(screen)
        self.title_box.draw(screen)
        self.press_start_box.draw(screen)
        return

    def update(self):
        self.background.update()
        self.title_box.update()
        self.press_start_box.update()
        if(InputManager().key_pressed(MKey.BUTTON_1,True)):
            GameManager().change_screen(GameManager().create_monster,False)
        return

    def open(self):
        self.title_box.set_position((self.title_box.bg.rect.x,-500))
        self.title_box.set_tween((self.title_box.bg.rect.x,0))
        return
Example #12
0
class MainOptions(Window):
    def __init__(self,origin = Point(0,0)):
        super().__init__(origin)
        self.train_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 10,150,32),Static.regent_gray,False,True)
        self.train_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Train",Static.gray))

        self.battle_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 51,150,32),Static.beige,False,True)
        self.battle_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Battle",Static.gray))

        self.interact_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 92,150,32),Static.beige,False,True)
        self.interact_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Interact",Static.gray))

        self.shop_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 133,150,32),Static.beige,False,True)
        self.shop_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Shop",Static.gray))

        self.items_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 174,150,32),Static.beige,False,True)
        self.items_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Items",Static.gray))

        self.netbattle_button = SimpleBox(pygame.Rect(self.origin.x,self.origin.y + 215,150,32),Static.gray,False,True)
        self.netbattle_button.add_sprite(MText(0,Point(5,5),100,Resources().font24,"Net Battle",Static.light_gray))

        self.train_button.down = self.battle_button
        self.battle_button.up = self.train_button
        self.battle_button.down = self.interact_button
        self.interact_button.up = self.battle_button
        self.interact_button.down = self.shop_button
        self.shop_button.up = self.interact_button
        self.shop_button.down = self.items_button
        self.items_button.up = self.shop_button
        self.items_button.down = self.netbattle_button
        self.netbattle_button.up = self.items_button
        
        self.selected = self.train_button
        return

    def update(self):
        self.train_button.update()
        self.battle_button.update()
        self.interact_button.update()
        self.shop_button.update()
        self.items_button.update()
        self.netbattle_button.update()
        if(self.enabled):
            self.selected
            if InputManager().key_pressed(MKey.UP,True):
                if self.selected.up != None:
                    self.selected.bg.set_color(Static.beige)
                    if self.selected is self.netbattle_button:
                        self.selected.bg.set_color(Static.gray)
                    self.selected = self.selected.up
                    self.selected.bg.set_color(Static.regent_gray)
            if InputManager().key_pressed(MKey.DOWN,True):
                 if self.selected.down != None:
                    self.selected.bg.set_color(Static.beige)
                    if self.selected is self.netbattle_button:
                        self.selected.bg.set_color(Static.gray)
                    self.selected = self.selected.down
                    self.selected.bg.set_color(Static.regent_gray)
        return

    def draw(self, screen):
        self.train_button.draw(screen)
        self.battle_button.draw(screen)
        self.interact_button.draw(screen)
        self.shop_button.draw(screen)
        self.items_button.draw(screen)
        self.netbattle_button.draw(screen)
        return

    def open(self,loc):
        super().open(loc)
        self.train_button.set_tween((self.origin.x,self.origin.y + 10))
        self.battle_button.set_tween((self.origin.x,self.origin.y + 51))
        self.interact_button.set_tween((self.origin.x,self.origin.y + 92))
        self.shop_button.set_tween((self.origin.x,self.origin.y + 133))
        self.items_button.set_tween((self.origin.x,self.origin.y + 174))
        self.netbattle_button.set_tween((self.origin.x,self.origin.y + 215))
        return

    def close(self,loc):
        super().close(loc)
        self.train_button.set_tween((self.origin.x,self.origin.y + 10))
        self.battle_button.set_tween((self.origin.x,self.origin.y + 51))
        self.interact_button.set_tween((self.origin.x,self.origin.y + 92))
        self.shop_button.set_tween((self.origin.x,self.origin.y + 133))
        self.items_button.set_tween((self.origin.x,self.origin.y + 174))
        self.netbattle_button.set_tween((self.origin.x,self.origin.y + 215))
        return