Skip to content

Fix: Python Indentation on website fixed #201 #214

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Tutorials/objects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -515,36 +515,36 @@ <h3>Arguments to the __init__ method</h3>In the above examples,
# Even though there are multiple objects, we still only need one class.
# No matter how many cookies we make, only one cookie cutter is needed.
class Car(object):
# The Constructor is defined with arguments.
def __init__(self, c, xpos, ypos, xspeed):
# 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):
def display(self):
stroke(0)
fill(self.c)
rectMode(CENTER)
rect(self.xpos, self.ypos, 20, 10);

def drive(self):
def drive(self):
self.xpos = self.xpos + self.xspeed;
if self.xpos > width:
self.xpos = 0
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)
size(200,200)

def draw():
background(255)
myCar1.drive()
myCar1.display()
myCar2.drive()
myCar2.display()
background(255)
myCar1.drive()
myCar1.display()
myCar2.drive()
myCar2.display()

</pre>

Expand Down