Example #1
0
	def __init__(self, driver, **kwargs) :
		AetherModule.__init__(self,driver,**kwargs)

		# convenient access to pymunk functions
		world = pymunx(gravity=(0.0,0.0,0.0))
		self.world = world

		# add the walls
		tl, tr, bl, br = (0,0),(self.dims[0],0),(0,self.dims[1]),(self.dims[0],self.dims[1])
		walls = ((tl,tr),(tl,bl),(tr,br),(bl,br))
		wall_shapes = []
		for w in walls :
			wall_shapes.append(world.add_wall(w[0],w[1],elasticity=1,friction=.5))
		self.wall_shapes = wall_shapes

		# add balls
		ball_shapes = []
		for x in range(10) :
			x,y = randint(0,self.dims[0]),randint(0,self.dims[1])
			ball_shapes.append(world.add_ball(Vec2d(x,y),radius=7,density=0.1,inertia=1000,elasticity=0.9,friction=0.1))
			#ball_shapes.append(world.add_ball(Vec2d(x,y)))
			dx,dy = randint(-1000,1000),randint(-1000,1000)
			ball_shapes[-1].body.apply_impulse(Vec2d(dx,dy),(dx,dy))
		self.ball_shapes = ball_shapes

		# add the circle the mouse will follow
		self.cursor_ball = world.add_ball(Vec2d(self.dims[0]/2,self.dims[1]/2),density=100,radius=25,elasticity=0.9,friction=0)
Example #2
0
	def __init__(self,driver,*args) :
		# need to call parent class' init method explicitly in python
		AetherModule.__init__(self,driver,*args)

		self.world = pymunx(gravity=(0.0,0.0,0.0))

		# add the walls
		#tl, tr, bl, br = (0,0),(self.dims[0],0),(0,self.dims[1]),(self.dims[0],self.dims[1])
		#walls = ((tl,tr),(tl,bl),(tr,br),(bl,br))
		#wall_shapes = []
		#for w in walls :
		#	wall_shapes.append(self.world.add_wall(w[0],w[1],elasticity=1,friction=.5))
		#self.wall_shapes = wall_shapes

		chime_pts = ((0,0),(10,0),(10,50),(0,50))
		self.chime = self.world.add_poly(chime_pts)
		self.chime.body.position = (self.dims[0]/2,self.dims[1]/2)

		# add the circle the mouse will follow
		self.cursor_ball = self.world.add_ball(Vec2d(self.dims[0]/2,self.dims[1]/2),density=100,radius=25,elasticity=0.9,friction=0)
Example #3
0
	def init(self):
		self.checkerboard = pygame.image.load(self.file_path('checkerboard.png'))
		self.checkerboard = pygame.transform.scale(self.checkerboard,self.dims)

		pygame.init()
		pygame.font.init()
		self.debug_print("Font initialized: "+str(pygame.font.get_init()))
		self.font = pygame.font.Font(None, 36)
		self.min_area_pos = (2,0)
		self.thresh_pos = (0,self.dims[1]-38)

		self.sprites = pygame.sprite.Group()

		self.draw_shadow = True

		# convenient access to pymunk functions
		world = pymunx(gravity=(0.0,0.0,0.0))
		self.world = world

		# add the walls
		tl, tr, bl, br = (0,0),(self.dims[0],0),(0,self.dims[1]),(self.dims[0],self.dims[1])
		walls = ((tl,tr),(tl,bl),(tr,br),(bl,br))
		wall_shapes = []
		for w in walls :
			wall_shapes.append(world.add_wall(w[0],w[1],elasticity=1,friction=.5))
		self.wall_shapes = wall_shapes

		# add balls
		ball_shapes = []
		for x in range(10) :
			x,y = randint(0,self.dims[0]),randint(0,self.dims[1])
			ball_shapes.append(world.add_ball(Vec2d(x,y),radius=7,density=0.1,inertia=1000,elasticity=0.9,friction=0.1))
			#ball_shapes.append(world.add_ball(Vec2d(x,y)))
			dx,dy = randint(-1000,1000),randint(-1000,1000)
			ball_shapes[-1].body.apply_impulse(Vec2d(dx,dy),(dx,dy))
		self.ball_shapes = ball_shapes

		# add the circle the mouse will follow
		self.cursor_ball = world.add_ball(Vec2d(self.dims[0]/2,self.dims[1]/2),density=100,radius=25,elasticity=0.9,friction=0)