Python Forum
Unwanted random generation of scripted Shapes in GASP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unwanted random generation of scripted Shapes in GASP
#1
Hello,

I'm currently learning Python 2.7 with the help of this tutorial: http://openbookproject.net/thinkcs/pytho.../ch04.html If you look at the bottom of that page, in exercise 10, I am to produce the pictured six houses with a script. I've written a script, but when I load it, not all of the windows and doors are visible. The really odd thing is that the windows and doors that ARE visible are different every time I load the script.

Note that I'm using Windows 8, which means I'm not using the latest version of GASP, as described here: http://dev.laptop.org/pub/gasp/downloads/

Below are an image of the script and the problem. Thanks in advance.

Edit: I suspect the problem has to do with the blue boxes covering the other shapes, as everything is visible when I set the blue boxes to filled=False.

[Image: 2a4wz7t.jpg]
Reply
#2
Please post the code using the Python button (6th button from the right), not a 'picture' of the code.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
from gasp import *

def draw_house(x, y):


    Box((x, y), 100, 100, True, color.BLUE)     #house
    Box((x + 35, y), 30, 50, True, color.GREEN)       #door
    Box((x + 20, y + 60), 20, 20, True, color.YELLOW)       #left window
    Box((x + 60, y + 60), 20, 20, True, color.YELLOW)       #right window
    Polygon(((x, y + 100),(x + 50, y + 140),(x + 100, y + 100)),True, color.RED)

begin_graphics(title="Houses at Night", background=color.BLACK)
draw_house(20, 20)
draw_house(270, 20)
draw_house(520, 20)
draw_house(145, 170)
draw_house(395, 170)
draw_house(270, 320)
update_when('key_pressed')  #keep canvas open until key pressed
end_graphics()              #close canvas
Reply
#4
To be honest i think you shall skip this part of the book,
because i really do not like when when author of books make wrapper around stuff like(Pygame,Tkinter...).
The you wonder about stuff like,is it the GASP tool(Pygame wrapper) that make this error?
Do they keep GASP updated,no it's from 2010 ect.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I design shapes on a curve in python? mervea 2 791 Sep-14-2023, 01:04 PM
Last Post: Pedroski55
  Node Flow Generation in Python Linenloid 0 649 Feb-21-2023, 07:09 PM
Last Post: Linenloid
  Allure Report Generation rotemz 0 777 Jan-24-2023, 08:30 PM
Last Post: rotemz
  x and y must have same first dimension, but have shapes (1,) and (50,) asja2010 5 2,572 Jan-12-2023, 07:24 PM
Last Post: deanhystad
Question Unwanted execution of unittest ThomasFab 9 2,049 Nov-15-2022, 05:33 PM
Last Post: snippsat
  Shapes in Video finndude 0 653 Oct-07-2022, 03:30 PM
Last Post: finndude
  Shapes over video in tkinter finndude 1 952 Oct-04-2022, 06:14 PM
Last Post: deanhystad
  Why doesnt chunk generation work? LotosProgramer 1 1,935 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Removing the unwanted data from a file jehoshua 14 4,055 Feb-01-2022, 09:56 PM
Last Post: jehoshua
  operands could not be broadcast together with shapes (337,451) (225,301) kevinabbot 0 1,558 Dec-14-2021, 04:02 PM
Last Post: kevinabbot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020