Hi, i'm new to Python and i'm currently following the "How to Think like a Computer Scientist" tutorials. I'm at Chapter 4: Conditionals and doing the last exercise where i need to create six colored houses on a black background.

I've successfully created the house at the bottom left, but when i fill the "house" box with blue color, it blocks out the left window and the door. The right window, miraculously, remain unblocked. (I've left the background color as WHITE for now)

Anybody know why? Do you get the same result with the following code?

from gasp import *

begin_graphics(title="Houses At Night", background=color.WHITE)

Box((20, 20), 100, 100, filled=True, color=color.BLUE) #the house
Box((55, 20), 30, 50, filled=True, color=color.GREEN) #the door
Box((40, 80), 20, 20, filled=True, color=color.YELLOW) #the left window
Box((80, 80), 20, 20, filled=True, color=color.YELLOW) #the right window
Polygon(((20, 120), (70, 160), (70, 120)), filled=True, color=color.RED) #Left Roof
Polygon(((70, 160), (120, 120), (70, 120)), filled=True, color=color.RED) #Right Roof

update_when('key_pressed')

end_graphics()

Recommended Answers

All 2 Replies

My recommendation, don't work with an old ditty like module gasp. It is a wrapper for PyGame and doesn't work very well with newer versions of PyGame on Windows.

I got it to go this way ...

# for Windows and Python26 dowmload and install gasp from:
# http://edge.launchpad.net/gasp-core/0.1.x/0.2.0beta1/+download/python-gasp-0.2.0beta1.win32.exe
# needs PyGame installed too

from gasp import *

begin_graphics(title="Houses At Night", background=color.WHITE)

Box((55, 20), 30, 50, filled=True, color=color.GREEN) #the door

Box((20, 20), 100, 100, filled=True, color=color.BLUE) #the house
#Box((55, 20), 30, 50, filled=True, color=color.GREEN) #the door
Box((40, 80), 20, 20, filled=True, color=color.YELLOW) #the left window
Box((80, 80), 20, 20, filled=True, color=color.YELLOW) #the right window
Polygon(((20, 120), (70, 160), (70, 120)), filled=True, color=color.RED) #Left Roof
Polygon(((70, 160), (120, 120), (70, 120)), filled=True, color=color.RED) #Right Roof

update_when('key_pressed')  # wait

end_graphics()

Thanks alot. LOL a simple re-arrangement did the trick. It really doesn't make sense at all because i swear my code was alright.

But i guess if i have to write any other things using GASP, i should just simply re-arrange if there are any semantic errors.

Once again. Thanks for the help.

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.