hey ppl

Trying to get this code working for this gui cube game
It is an assignment so i'm being honest, I have know idea on how to get the tkinker function to work. have searched the internet but still having problems in getting it too work.
I have tried to do as much as I can to get the program to work but it is still missing bits and pieces

I have put a megaupload link with the files in it
One file called test.py is the file i have been working on and the other one is the original, you will see that i have tried to get the program to from its original state

As far as i know that game works by matching the shades of colors to the color on the cube and will give you a score if you get it correct or incorrect

I don't expect someone to write the code for me all though that would be awesome I am wanting some help so I can continue on getting the damn thing to work

http://www.megaupload.com/?d=EN3V6BZH

Thanks guys

Post the formula that you would like to use for solving the problem. The most common method is layer by layer. Also, post the code here if you want people who don't have, or want to deal with MS Windows archiver to respond.

here is the code, when is says #your code goes here, This is the first part that I have done, I have managed to get the colors to change randomly when you press the start button but the tkinter function cant do that yet

from tkinter import *
from tkinter import messagebox

def set_up():
    global lumin1, lumin2, game_started

    
    # replace line below with random colour for left button
    import random
    red = random.randrange(256)
    blue = random.randrange(256)
    green = random.randrange(256)
    leftButton.config(background=rgb(red,green,blue))
    # replace line below with luminance calculation for left button
    lumin1 = int(round((red+blue+green)/3.0))
    
    # replace line below with random colour for left button
    red = random.randrange(256)
    blue = random.randrange(256)
    green = random.randrange(256)
    rightButton.config(background=rgb(red,green,blue))
    # replace line below with luminance calculation for left button
    lumin2 = int(round((red+blue+green)/3.0))

def clicked_left():
    global lumin1,lumin2, game_started, score
    

def clicked_right():
    global lumin1,lumin2, game_started, score
    total = 0
    total = total +1
        
def check_it():
    global score

def go_home():
    global score
    exitString = "Final Score is "
    messagebox.showinfo("All done!",exitString)
    # shut down our main window
    root.destroy()

def change_pic():
    global pic_flag
    piccy.config(image = myImage)
    piccy.config(image = myImage2)

def rgb(red, green, blue):
    return "#{0:02X}{1:02X}{2:02X}".format(red,green,blue)


# create main window
root = Tk()
root.tk_bisque()
root.title("Lightness Game")
# initialisation section
lumin1=0
lumin2=0
score=0
game_started = False
# set up all widgets
pic_frame = Frame(root)
pic_frame.pack(fill=X, side=TOP)
myImage = PhotoImage(file="RGB_cube.gif")
myImage2 = PhotoImage(file="YUV_cube.gif")
piccy=Button(pic_frame, image=myImage, borderwidth=0,
             command=change_pic)
piccy.pack()
game_frame = Frame(root)
game_frame.pack(fill=X)
leftButton=Button(game_frame,command=clicked_left, width=25,
                  height=5, background = "pink")
leftButton.pack(side=LEFT)
rightButton=Button(game_frame, command=clicked_right, width=25,
                   height=5, background = "pink")
rightButton.pack(side=RIGHT)
guess_frame = Frame(root)
button_frame = Frame(root)
button_frame.pack(fill=X, side=BOTTOM)
quitter=Button(button_frame, text='QUIT', command=go_home,
               activebackground="lightblue")
quitter.pack(side=RIGHT)
newbutton=Button(button_frame, text='START', command=set_up)
newbutton.pack(side=RIGHT)
checker=Button(button_frame, text='Check my score', command=check_it)
checker.pack(side=RIGHT)
result =Label(button_frame,font=('Calibri',12,'bold'),text='')
result.pack(side=LEFT)
# start window's main processing
root.mainloop()

Start with organizing the questions. I'm not real familiar with the game, but I think a cube and ladder are the first two objects.

print "Describe a cube"
features=(("Size", "large", "medium", "small"),
          ("Made Of", "steel", "iron", "wood", "styrofoam", "cloth"))
cube_response = []
for feature in features:
    print "\npick one of the following"
    print feature[0]
    for ctr in range(1, len(feature)):
        print "     %d %s" % (ctr, feature[ctr])
    choice = raw_input("What is your choice? ")
    cube_response.append(choice)

You can define the parameters for each object and send them to a common function to process.

Thanks for reply but am not sure how this will work with my current code?

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.