Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text wont draw
#1
Hey guys so im working on this mini game and in def Mknight(): the text wont draw I dont get any errors and if I put a txt.draw(p1) it gives me an error saying its drawn but its not.


from graphics import*
from pygame import*
import pygame
import graphics

##Variables##
x,y=0,0     #positions of mouse clicks
p1 = GraphWin("coord locator",1440,900)

##Main##
p1.setBackground('blue')
txt = Text(Point(725,125),'Select Your class')
txt.setTextColor('red')
txt.setSize(16)
txt.setFace('times roman')
txt.draw(p1)
txt1 = Text(Point(690,200),'Mounted Knight\t\t\t\t\t Knight')
txt1.setTextColor('red')
txt1.setSize(16)
txt1.setFace('times roman')
txt1.draw(p1)
class1=Image(Point(450,400),'Mknightlogo.gif')
class1.draw(p1)
class2=Image(Point(975,400),'Knightlogo.gif')
class2.draw(p1)
exit1 = Rectangle(Point(40,40),Point(10,10))
exit1.draw(p1)
exit1.setFill('Red')
exit1.setWidth(1)
txt2 = Text(exit1.getCenter(),'Exit')
txt2.draw(p1)

while True:
    p=p1.checkMouse()
    if p:
        x=p.getX()
        y=p.getY()
        if 10<x<40 and 10<y<40 :
            p1.close()
        elif p:
            break

##Functions##
def Mknight():
    p1.setBackground('green')
    txt.setText('You have choosen to ride your trusty steed')

def Knight():
    p1.setBackground('red')


while True:
    p=p1.checkMouse()
    p1.setBackground('blue')  
    if p:
        x=p.getX()
        y=p.getY()
        print(x,y)
        if 300<x<595 and 230<y<560 :
            Mknight()
            txt.undraw()
            class2.undraw()
            txt1.undraw()
            class1.undraw()
            x=p.getX()  #exit
            y=p.getY()
            break
        elif 10<x<40 and 10<y<40 :
            p1.close()
            break
        if 850<x<1103 and 265<y<525 :
            Knight()
            txt.undraw()
            class2.undraw()
            txt1.undraw()
            class1.undraw()
            x=p.getX()  #exit
            y=p.getY()
            break
        elif 10<x<40 and 10<y<40:
            p1.close()
            break
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Error trying to draw a gif with graphics.py fierygaming 8 282 May-29-2018, 07:12 PM
Last Post: fierygaming

Forum Jump:


Users browsing this thread: 1 Guest(s)