Esempio n. 1
0
    def draw(self, origin, scale):
        springX, _ = self.state

        pushMatrix()
        translate(*origin)
        #Wall
        x, y = self.wall_pos * scale
        w, h = self.wall_dims * scale
        vertical_wall(x, y, w, h, 10, right=True)

        #Floor
        x, y = self.floor_pos * scale
        w, h = self.floor_dims * scale
        horizontal_wall(x, y, w, h, 20, top=True)

        #Spring
        x, y = self.spring_pos * scale
        w, h = (self.spring_dims_rest + [springX, 0]) * scale
        horizontal_spring(x, y, w, h, 10)

        #Bob
        x, y = (self.bob_pos_rest + [springX, 0]) * scale
        w, h = self.bob_dims * scale
        rect(x, y, w, h)
        popMatrix()
 def draw(self, origin, scale):
     springX, _ = self.state
     
     pushMatrix()
     translate(*origin)
     #Wall
     x, y = self.wall_pos * scale
     w, h = self.wall_dims * scale
     vertical_wall(x, y, w, h, 10, right=True)
     
     #Floor
     x, y = self.floor_pos * scale
     w, h = self.floor_dims * scale
     horizontal_wall(x, y, w, h, 20, top=True)
     
     #Spring
     x, y = self.spring_pos * scale
     w, h = (self.spring_dims_rest + [springX, 0]) * scale
     horizontal_spring(x, y, w, h, 10)
 
     #Bob
     x, y = (self.bob_pos_rest + [springX, 0]) * scale
     w, h = self.bob_dims * scale
     rect(x, y, w, h)        
     popMatrix()
 def draw(self, origin, scale, colors):
     spring_x1, _, spring_x2, _ = self.state
     
     pushMatrix()
     translate(*origin)
     stroke(255)
     #Wall
     x, y = self.wall_pos * scale
     w, h = self.wall_dims * scale
     vertical_wall(x, y, w, h, 10, right=True)
     
     #Floor
     x, y = self.floor_pos * scale
     w, h = self.floor_dims * scale
     horizontal_wall(x, y, w, h, 20, top=True)
     
     stroke(colors[0])
     #Spring1
     x, y = self.spring1_pos * scale
     w, h = (self.spring1_dims_rest + [spring_x1, 0]) * scale
     horizontal_spring(x, y, w, h, 10)
 
     #Bob1
     x, y = (self.bob1_pos_rest + [spring_x1, 0]) * scale
     w, h = self.bob1_dims * scale
     rect(x, y, w, h)        
     
     stroke(colors[1])
     #Spring2
     x, y = (self.spring2_pos_rest + [spring_x1, 0]) * scale
     w, h = (self.spring2_dims_rest + [spring_x2, 0]) * scale
     horizontal_spring(x, y, w, h, 10)
 
     #Bob2
     x, y = (self.bob2_pos_rest + [spring_x1 + spring_x2, 0]) * scale
     w, h = self.bob2_dims * scale
     rect(x, y, w, h)       
     popMatrix()
    def draw(self, origin, scale, colors):
        spring_x1, _, spring_x2, _ = self.state

        pushMatrix()
        translate(*origin)
        stroke(255)
        # Wall
        x, y = self.wall_pos * scale
        w, h = self.wall_dims * scale
        vertical_wall(x, y, w, h, 10, right=True)

        # Floor
        x, y = self.floor_pos * scale
        w, h = self.floor_dims * scale
        horizontal_wall(x, y, w, h, 20, top=True)

        stroke(colors[0])
        # Spring1
        x, y = self.spring1_pos * scale
        w, h = (self.spring1_dims_rest + [spring_x1, 0]) * scale
        horizontal_spring(x, y, w, h, 10)

        # Bob1
        x, y = (self.bob1_pos_rest + [spring_x1, 0]) * scale
        w, h = self.bob1_dims * scale
        rect(x, y, w, h)

        stroke(colors[1])
        # Spring2
        x, y = (self.spring2_pos_rest + [spring_x1, 0]) * scale
        w, h = (self.spring2_dims_rest + [spring_x2, 0]) * scale
        horizontal_spring(x, y, w, h, 10)

        # Bob2
        x, y = (self.bob2_pos_rest + [spring_x1 + spring_x2, 0]) * scale
        w, h = self.bob2_dims * scale
        rect(x, y, w, h)
        popMatrix()