from scene import *
import sound
import random
import math
A = Action
class MyScene (Scene):
def setup(self):
self.carlist=[]
self.imglist=[`img1.png`,`img2.png`,`img3.png`,`img4.png`,`img5.png`,`img6.png`,`img7.png`,`img8.png`,`img9.png`,`img10.png`,`img11.png`]
x=100
y=300
self.a=self.spawn_car(x,y-199)
self.b=self.spawn_car(x+199,y-199)
self.spawn_car(x+398,y-199)
self.spawn_car(x,y)
self.spawn_car(x+199,y)
self.spawn_car(x+398,y)
self.spawn_car(x,y+199)
self.spawn_car(x+199,y+199)
self.spawn_car(x+398,y+199)
def spawn_car(self,x,y):
car=SpriteNode(random.choice(self.imglist))
#self.car.anchor_point=(0,0)
car.position=(x,y)
self.add_child(car)
self.carlist.append(car)
return car
def did_change_size(self):
pass
def update(self):
if self.a.bbox.intersects(self.b.bbox):
print(1)
print(self.a.bbox.intersection(self.b.bbox))
```for car in self.carlist:
act=A.repeat(A.rotate_by(math.pi/2,1),-1)
car.run_action(act)```
def touch_began(self, touch):
pass
def touch_moved(self, touch):
pass
def touch_ended(self, touch):
pass
if name == `__main__`:
run(MyScene(), show_fps=True)
“`display_width=800
display_height=600
black=(0,0,0)
white=(255,255,255)
red=(255,0,0)
green=(0,255,0)
purple=(238,130,238)
x=0
y=200
car(x,y-199,0)
car(x+199,y-199,0)
car(x+398,y-199,0)
car(x+597,y-199)
car1=car(x,y,0)
car2=car(x+199,y,4)
car(x+398,y,0)
car(x+597,y)
car5=car(x,y+199,0)
car(x+199,y+199,0)
car(x+398,y+199,0)
car(x+597,y+199)
“`