r/inventwithpython • • Dec 18 '13

transpositionHacker.py

1 Upvotes

Trying to figure out where I have a problem, and no access to internet on the computer I am coding on (Personal laptop at work). I have the program completed and it runs, but it fails to hack the example. Any direction on where to check for errors?


r/inventwithpython • • Nov 25 '13

What if I want to use 2.x instead?

1 Upvotes

Can I still follow this book and just make the small changes in order to learn 2.7 rather than 3? or would I run into more problems than I need?


r/inventwithpython • • Nov 02 '13

Taking text input and setting it as a variable...

1 Upvotes

I have the code below to take a text input but when I try and use 'players' in a string it is always giving me a None value. Is there a better way of doing this? Also I only want to allow an integer to be accepted as the input. I have tried Try/Exept but I think the first issue is the stumbling block.

def textbox(words, x, y):
    txtbx = eztext.Input(maxlength=45, color=(255,0,0), prompt=words)
    txtbx.set_pos(x,y)
    while True:
        txtbx.draw(screen)
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.MOUSEBUTTONDOWN:
                return
        txtbx.update(events)
        txtbx.draw(screen)
        pygame.display.update()
    return txtbx

players = textbox("How many players are there? ", 100,200)

r/inventwithpython • • Nov 02 '13

Do something if Mouse clicked in certain area of screen?

1 Upvotes

I want my game to wait after playerroll() for another mouseclick, then if this mouseclick is in a specific area (ie over a certain image) then perform an action on that image. My code so far is below but it just carries on with the code without waiting to see if another mouseclick happened or if it was in that certain area. Can anyone help?

for event in pygame.event.get():
    if event.type == pygame.MOUSEBUTTONDOWN:
        dice_roll()
        playerroll()
    for event in pygame.event.get():
        if event.type == pygame.MOUSEBUTTONDOWN:
            if jackpot[roll1-1].get_rect().collidepoint(pos):
                moveletter(roll1-1)
                jackpot[roll1-1] = "none"

r/inventwithpython • • Aug 27 '13

How to ensure errors are removed as script doesn't work.

1 Upvotes

I was doing Dragon realm and typed it into idle. I ran it and it didn't work, no errors it just produce no output and went back to prompt. I saved the file as another name.

So I used the diff tool. And edited the original file to be the same and it worked. Mind you it only had an extra space in 2 lines.

So I took the original file and ran it through a pep8 checker and fixed the errors until it passed pep8. I ran the file it failed as it originally did.

My concern is if I didn't have the authors script and I was running my own script with this error how would I ever figure out the error. If pep8 passed then I would probably think I had a code error.

Is there a way to ensure a file is 100% ok?