tags:

views:

138

answers:

2

Possible Duplicate:
stop moving through wall in maze using Python

How can I do this using Python 3.1: use the current cell, check if there is a wall to the right, left, up, down etc.

This is my code for moving:

if event.keysym == 'Right':
    print( 'moving to the right', c)
    c.move(CELLSIZE,0)

I tried this code to stop moving but it doesn't work:

    if event.keysym == 'Wall':
        curcell.right = True
A: 

You will need to change your condition if event.keysym == 'Right': to something like

if (event.keysym == 'Right') and (there is not a wall to the right):
    print( 'moving to the right', c)
    c.move(CELLSIZE,0)

In other words, you need to check for a wall before you move, not after.

Jon Rodriguez
+2  A: 

these magic codes should help solve your problem:

import webbrowser

webbrowser.open('http://www.catb.org/esr/faqs/smart-questions.html')
webbrowser.open('http://docs.python.org/tutorial/index.html')
webbrowser.open('http://www.google.com')
aaronasterling
Funny thing is, this might actually work.
Jim Brissom