コード例 #1
0
def createNPC():
    
    bar = mapMenuItems.scrollBar(910, 10, 610, 10)
    
    texts = py.sprite.Group()
    
    ni = mapMenuItems.textInput((350, 200), 30, 16, 1, button=None, default=[], type="str")
    texts.add(mapMenuItems.textLabel("NPC Name:", (150, 210), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    fi = mapMenuItems.textInput((450, 260), 30, 2, 2, button=None, default=[], type="int")
    texts.add(mapMenuItems.textLabel("Base Friendliness:", (150, 270), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    arb = mapMenuItems.radioButtons(350, 330, ["Good", "Evil"])
    texts.add(mapMenuItems.textLabel("Alignment:", (150, 330), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    drb = mapMenuItems.radioButtons(350, 390, ["Up", "Down", "Left", "Right"])
    texts.add(mapMenuItems.textLabel("Direction:", (150, 390), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    buttons = py.sprite.Group()
    buttons.add(mapMenuItems.button("Done", (800, 550), 60, (200, 0, 200), (255, 50, 255), "../Resources/Fonts/RPGSystem.ttf", "done"))
    buttons.add(mapMenuItems.button("Add Conversation", (460, 500), 60, (200, 200, 100), (100, 200, 200), "../Resources/Fonts/RPGSystem.ttf", "convo", centred=True))
    
    imageButton = npcImageButton(drb)
    faceButton = npcFaceButton()
    while True:
        v.screen.fill((220, 220, 220))
        v.events = []
        v.events = py.event.get()
        imageButton.update()
        faceButton.update()
        bar.update()
        texts.update()
        arb.update()
        drb.update()
        ni.update()
        fi.update()
        buttons.update()
        for event in v.events:
            if event.type == py.MOUSEBUTTONDOWN:
                for button in buttons:
                    if button.pressed():
                        if button.ID == "done":
                            v.selectedNPC = {"Image": imageButton.selected, "Name": ni.outText, "Alignment": arb.outText, "Base Like": fi.outText, "Direction": drb.outText}
                            print(v.selectedNPC)
                            return  
                        if button.ID == "convo":
                            chatEdit()
        
        py.display.flip()
コード例 #2
0
def createEnemy():
    tinps = py.sprite.Group()
    texts = py.sprite.Group()
    v.textNum = 1
    
    tinps.add(mapMenuItems.textInput((400, 100), 40, 16, 1, button=None, default=[], type="str"))
    texts.add(mapMenuItems.textLabel("Enemy Name:", (150, 110), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    tinps.add(mapMenuItems.textInput((400, 200), 40, 2, 2, button=None, default=[], type="int"))
    texts.add(mapMenuItems.textLabel("Attack:", (150, 210), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    tinps.add(mapMenuItems.textInput((400, 300), 40, 3, 3, button=None, default=[], type="int"))
    texts.add(mapMenuItems.textLabel("Health:", (150, 310), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    tinps.add(mapMenuItems.textInput((400, 400), 40, 2, 4, button=None, default=[], type="int"))
    texts.add(mapMenuItems.textLabel("Speed:", (150, 410), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False))
    
    button = mapMenuItems.button("Done", (500, 500), 60, (200, 0, 0), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "GO")
    while True:
        py.event.pump()
        v.events = []
        v.events = py.event.get()
        v.screen.fill((200, 200, 200))
        tinps.update()
        texts.update()
        button.update()
        for event in v.events:
            if event.type == py.MOUSEBUTTONDOWN:
                if button.pressed():
                    for t in tinps:
                        if t.num == 1:
                            v.selectedEnemy["Name"] = t.outText
                        if t.num == 2:
                            v.selectedEnemy["Attack"] = t.outText
                        if t.num == 3:
                            v.selectedEnemy["Health"] = t.outText
                        if t.num == 4:
                            v.selectedEnemy["Speed"] = t.outText
                    py.time.delay(200)
                    return
        py.display.flip()
コード例 #3
0
 def update(self):
     if not self.master.c_buttons[self.num] == {}:
         self.text = self.font.render("Button " + str(self.num + 1), 1, (0, 0, 0))
     else:
         self.text = self.font.render("+ Button " + str(self.num + 1) + " +", 1, (0, 0, 0))
     
     
     if not self.hovered:
         py.draw.rect(v.screen, (150, 150, 150), self.rect)
     else:
         py.draw.rect(v.screen, (100, 100, 100), self.rect)
     
     if self.rect.collidepoint(py.mouse.get_pos()):
         self.hovered = True
     else:
         self.hovered = False
     
     v.screen.blit(self.text, (self.rect.centerx - self.text.get_rect().width/2, self.rect.centery - self.text.get_rect().height/2))
     
     if self.hovered:
         for event in v.events:
             if event.type == py.MOUSEBUTTONDOWN:
                 self.master.editButton = self.num
                 
                 if "Text" in self.master.c_buttons[self.num].keys():
                     print(self.master.c_buttons[self.num])
                     self.b_message = self.master.c_buttons[self.num]["Text"]
                     self.b_id = self.master.c_buttons[self.num]["ID"]
                 else:
                     self.b_id = ""
                     self.b_message = ""
                                         
                 self.master.Btexts = py.sprite.Group()
                 self.master.Btinps = py.sprite.Group()
                 
                 self.master.Btexts.add(mapMenuItems.textLabel("Goto:", (self.master.posx + 20, self.master.posy + 20), (0, 0, 0), None, 25))
                 self.master.Btinps.add(mapMenuItems.textInput((self.master.posx + 10, self.master.posy + 40), 25, 2, 1, button=None, default=list(self.b_id), type="int", fontfile=None))
             
                 self.master.Btexts.add(mapMenuItems.textLabel("Text:", (self.master.posx + 20, self.master.posy + 80), (0, 0, 0), None, 25))
                 self.master.Btinps.add(mapMenuItems.textInput((self.master.posx + 10, self.master.posy + 100), 15, 50, 2, button=None, default=list(self.b_message), type="str", fontfile=None))
コード例 #4
0
 def __init__(self, c_message="", c_goto = "", c_id = "", c_charisma = "", c_buttons = [], c_changelike = "", c_end = ""):
     super().__init__()
     print("new", c_buttons)
     self.created = False
     
     self.c_message = c_message
     self.c_goto = c_goto
     self.c_id = c_id
     self.c_charisma = c_charisma
     self.c_buttons = c_buttons
     self.c_changelike = c_changelike
     self.c_end = c_end
     
     self.posx = 210
     self.posy = 50
     self.rect = py.Rect(self.posx, self.posy, 500, 150)
 
     self.tinps = py.sprite.Group()
     self.texts = py.sprite.Group()
     
     self.texts.add(mapMenuItems.textLabel("ID:", (self.posx + 20, self.posy + 20), (0, 0, 0), None, 25))
     self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 40), 25, 2, 1, button=None, default=list(self.c_id), type="int", fontfile=None))
     
     self.texts.add(mapMenuItems.textLabel("Message: (Lines are conjoined with no space)", (self.posx + 20, self.posy + 80), (0, 0, 0), None, 25))
     self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 100), 15, 50, 2, button=None, default=list(self.c_message[:len(self.c_message)//2]), type="str", fontfile=None))
     self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 120), 15, 50, 3, button=None, default=list(self.c_message[len(self.c_message)//2:]), type="str", fontfile=None))
     
     self.texts.add(mapMenuItems.textLabel("Goto:", (self.posx + 80, self.posy + 20), (0, 0, 0), None, 25))
     self.tinps.add(mapMenuItems.textInput((self.posx + 80, self.posy + 40), 25, 2, 4, button=None, default=list(self.c_goto), type="int", fontfile=None))
     
     self.texts.add(mapMenuItems.textLabel("Charisma", (self.posx + 160, self.posy + 5), (0, 0, 0), None, 20))
     self.texts.add(mapMenuItems.textLabel("Needed:", (self.posx + 160, self.posy + 20), (0, 0, 0), None, 20))
     self.tinps.add(mapMenuItems.textInput((self.posx + 160, self.posy + 40), 25, 2, 5, button=None, default=list(self.c_charisma), type="int", fontfile=None))
     
     self.texts.add(mapMenuItems.textLabel("Change", (self.posx + 240, self.posy + 5), (0, 0, 0), None, 20))
     self.texts.add(mapMenuItems.textLabel("Friendliness:", (self.posx + 240, self.posy + 20), (0, 0, 0), None, 20))
     self.tinps.add(mapMenuItems.textInput((self.posx + 240, self.posy + 40), 25, 2, 6, button=None, default=list(self.c_changelike), type="int", fontfile=None))
 
     self.texts.add(mapMenuItems.textLabel("End:", (self.posx + 330, self.posy + 20), (0, 0, 0), None, 25))
     self.tinps.add(mapMenuItems.textInput((self.posx + 330, self.posy + 40), 25, 2, 7, button=None, default=list(self.c_end), type="int", fontfile=None))
 
     self.Btexts = py.sprite.Group()
     self.Btinps = py.sprite.Group()
 
     self.Bselect = py.sprite.Group()
     print("c buttons:", self.c_buttons) #TODO: Fix blank buttons
     while len(self.c_buttons) < 4:
         self.c_buttons.append({})
     for i in range(len(self.c_buttons)):
         self.Bselect.add(self.button(i, self))
     
     self.editButton = None
     
     self.buttonGo = mapMenuItems.button("Save", (570, 60), 80, (100, 100, 100), (150, 150, 150), None, "save", centred=False, bsize=(130, 80), centretext=True)
     self.buttonDel = mapMenuItems.button("Delete", (420, 60), 60, (100, 100, 100), (150, 150, 150), None, "delete", centred=False, bsize=(130, 80), centretext=True)
コード例 #5
0
def setup():
    tinps = py.sprite.Group()
    texts = py.sprite.Group()
    v.textNum = 1
    tinps.add(mapMenuItems.textInput((500, 100), 60, 2, 1, button=None, default=['1', '0'], type="int"))
    texts.add(mapMenuItems.textLabel("Map Width:", (240, 110), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((500, 180), 60, 2, 2, button=None, default=['1', '0'], type="int"))
    texts.add(mapMenuItems.textLabel("Map Height:", (240, 190), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    if v.tempId == None:
        df = ['1']
    else:
        df = list(str(v.tempId))
    tinps.add(mapMenuItems.textInput((500, 260), 60, 2, 3, button=None, default=df, type="int"))
    texts.add(mapMenuItems.textLabel("Map ID:", (240, 270), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((400, 350), 30, 24, 4, button=None, default=['P', 'l', 'a', 'c', 'e'], type="str"))
    texts.add(mapMenuItems.textLabel("Location Name:", (40, 350), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((500, 430), 40, 10, 5, button=None, default=['P', 'l', 'a', 'i', 'n', 's'], type="str"))
    texts.add(mapMenuItems.textLabel("Biome:", (240, 440), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    buttons = py.sprite.Group()
    buttons.add(mapMenuItems.button("Back", (10, 550),80, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "B"))
    buttons.add(mapMenuItems.button("Continue", (690, 550), 70, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "C"))
    
    while True:
        py.event.pump()
        v.events = []
        v.events = py.event.get()
        v.screen.fill((0, 255, 0))
        tinps.update()
        texts.update()
        buttons.update()
        py.display.flip()
        
        for b in buttons:
            if b.pressed():
                if py.mouse.get_pressed()[0]:
                    if b.ID == "B":
                        startMenu()
                        return
                    if b.ID == "C":
                        for i in tinps:
                            if i.num == 1:
                                x = int(i.outText)
                            if i.num == 2:
                                y = int(i.outText)
                            if i.num == 3:
                                v.currentID = int(i.outText)
                            if i.num == 4:
                                v.currentName = str(i.outText)
                            if i.num == 5:
                                v.currentBiome = str(i.outText)
                        v.size = (x, y)
                        v.baseTiles = py.sprite.Group()
                        v.topTiles = py.sprite.Group()
                        v.tiles = py.sprite.Group()
                        for x in range(v.size[0]):
                            for y in range(v.size[1]):
                                v.baseTiles.add(tileEdit.tile(x, y, "base"))
                                v.topTiles.add(tileEdit.tile(x, y, "top"))
                        mapEditor()
                        return