Landen-S-Brown 0 Newbie Poster

I just joined this community, after searching and not finding what i was looking for.
I am new to programming, I'm just 15, my dad programs for a living, but doesn't know much with python.
Forgive me if my code is sloppy, i have been told so by my dad numerous times, but it works, and thats all i want at this point in time.

I Have created a small game in pygame using up arrow, left arrow, right arrow, and down arrow to move the character (which is a just a square at the moment).

I have small character interaction with NPC's, such as:

def Distance(point1, point2):
    dist = math.hypot(point2.centerx-point1.centerx, point2.centery-point1.centery)
    return dist

#Distance Between Characters
def CollisionDetection(point1, point2):
    if Distance(point1, point2) <= 50:
        return True
    else:
        return False
#Setting true or false if user controlled character is within distance (diet)


class Monster():
    def __init__(self, pic, rect, string, stringrect):
        self.pic = pic
        self.rect = rect
        self.string = string #For a message
        self.stringrect = stringrect #For Moving the message
    def SetText(self):
        self.stringrect.centerx = self.rect.centerx
        self.stringrect.centery = (self.rect.centery - 40)
        #Centering the string above the Monster or NPC's Head#

#Creating My Square#
class Square():
    def __init__(self, mypic, myrect):
        self.mypic = mypic
        self.myrect = myrect


#MBlock for Monster Block
mblock = pygame.image.load("../Sprites/MBlock.png").convert()          
mblockRect = mblock.get_rect()
monster.string = text = font.render("Talk To Me, Wth 'x'", True, (255, 255, 255))

#My Character

block = pygame.image.load("../Sprites/MyBlock.png").convert()
blockRect = block.get_rect()
player = Square(block, blockRect)
textnumber = 0

#IN THE WHILE LOOP

if CollisionDetection(blockRect, mblockRect) and keyinput[pygame.K_x]:
            if textnumber == 0:
                textnumber = textnumber + 1
                monster.string = text = font.render("Hello?!. Press X to Continue", True, (255, 255, 255))
                monster.SetText()
                time.sleep(0.1)
            elif textnumber == 1:
                textnumber = textnumber + 1
                monster.string = text = font.render("Please help me, I have been trapped in this dungeon! Press X                                   to Continue", True, (255, 255, 255))
                monster.SetText()
                time.sleep(0.1)
            elif textnumber == 2:
                textnumber = textnumber + 1
                monster.string = text = font.render("If you Can Find a way out of this prison, I will Reward You Greatly! Press X to Accept", True, (255, 255, 255))
                time.sleep(0.1) 
                
            elif textnumber == 3:
                textnumber = textnumber + 1
                mmonster.string = text = font.render("Thank you! Keep Looking!", True, (255, 255, 255))

All Works fine and all, but i hate the text over the NPC's Head. Can someone advise me on how to create a separate menu (In the same window) For making shops, messages, or the start menu? I would really appreciate it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.