lundi 1 décembre 2014

English peg solitaire game python3


I am new to programming and for a course I am taking, we are required to code for an English peg solitaire game. I ran into a few problems with my splash screen. What I want to do is for the loop to see if the area clicked is inside the purple(game) rectangle, and if it is clicked it will call on the function game function.


create the splashScreen() function


def splashScreen():



win=GraphWin("Splash Screen", 350, 350)


Create a Rectangle object with the text 'Play'



rect1=Rectangle(Point(110, 220), Point(290, 330))
rect1.setFill("purple")
rect1.draw(win)
text1=Text(Point(215, 290), "Game")
text1.setFill("yellow")
text1.draw(win)


for the demo rectangle



rect2=Rectangle(Point(160, 320), Point(300, 340))
rect2.setFill("yellow")
rect2.draw(win)
text1=Text(Point(215, 330), "Demo")
text1.setFill("purple")
text1.draw(win)


create messages for the game name, the game description and name of the game creator



message=Text(Point(230, 50), "English peg solitaire Game")
message.setSize(20)
message.setFill("green")
message.draw(win)
message=Text(Point(220, 150), "The game is cross shaped and has 45 tiles,\n44 of them containing full circles, and 1 empty\ncircle which is in the center. User can move \nthe black circles into the red one,but only \nthe tiles surrounding the tiles adjacent to the empty \nspot can move, and it can only move into \nthe empty space.")
message.setSize(12)
message.setFill("red")
message.draw(win)
message=Text(Point(230, 250), "John Doe")
message.setSize(12)
message.setFill("orange")
message.draw(win)

where= win.getMouse() # get the mouse
row=where.y//size
col=where.x//size
while where!=row or where!=col:
win.getMouse()
win.close




Aucun commentaire:

Enregistrer un commentaire