Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The indentation is incorrect in the OOP car example #201

Open
lanephillips opened this issue Sep 17, 2021 · 4 comments · May be fixed by #214
Open

The indentation is incorrect in the OOP car example #201

lanephillips opened this issue Sep 17, 2021 · 4 comments · May be fixed by #214

Comments

@lanephillips
Copy link

The first full script in this tutorial https://py.processing.org/tutorials/objects/ (the one with two cars going different speeds) will fail to run if copied and pasted into the Processing IDE. Some lines are not indented properly.

This works:

class Car(object):
    # The Constructor is defined with arguments.
    def __init__(self, c, xpos, ypos, xspeed):
        self.c = c
        self.xpos = xpos
        self.ypos = ypos
        self.xspeed = xspeed

    def display(self):
        stroke(0)
        fill(self.c)
        rectMode(CENTER)
        rect(self.xpos, self.ypos, 20, 10);

    def drive(self):
        self.xpos = self.xpos + self.xspeed;
        if self.xpos > width:
            self.xpos = 0

myCar1 = Car(color(255, 0, 0), 0, 100, 2)
myCar2 = Car(color(0, 255, 255), 0, 10, 1)

def setup():
    size(200,200)

def draw(): 
  background(255)
  myCar1.drive()
  myCar1.display()
  myCar2.drive()
  myCar2.display()
@tabreturn
Copy link
Contributor

Thanks for spotting that! I've corrected this and created a pull request (#202)

@horstjens
Copy link

the pull request was merged over a half year ago but the website https://py.processing.org/tutorials/objects/ still shows the incorrect indentation. Is there a way to publish the most recent version of the website with the corrections included?

@Arghyahub
Copy link

Please assign me this issue.
I would like to contributing to the indentation issue addressed by @horstjens .

@Arghyahub Arghyahub linked a pull request Jan 31, 2023 that will close this issue
@Arghyahub
Copy link

Can anyone Merge my pull request please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants