def draw(self): bacon.push_transform() bacon.translate(self.x, self.y) bacon.rotate(self.angle) bacon.draw_image(self.image, -(self.image.width / 2), -(self.image.height / 2)) bacon.pop_transform()
def on_tick(self): bacon.clear(0, 0, 0, 1) if self.controller: bacon.translate(bacon.window.width / 2, bacon.window.height / 2) bacon.translate(self.controller.left_thumb_x * 100, self.controller.left_thumb_y * 100) bacon.rotate(self.controller.right_thumb_x) bacon.scale(self.controller.right_thumb_y + 1, self.controller.right_thumb_y + 1) bacon.draw_image(kitten, -kitten.width / 2, -kitten.height / 2)
def on_tick(self): bacon.clear(0, 0, 0, 1) bacon.push_transform() bacon.translate(kitten.width / 2, kitten.height / 2) bacon.rotate(math.pi / 4) bacon.draw_image(kitten, -kitten.width / 2, -kitten.height / 2) bacon.pop_transform() bacon.draw_string(font, 'Hello', 20, 30)
def on_tick(self): bacon.set_blending(bacon.BlendFlags.src_alpha , bacon.BlendFlags.one_minus_src_alpha ) bacon.clear(0, 0, 0, 1) bacon.translate(0,0) for layer in self.stars: for star in layer: star.draw() bacon.draw_string(font, "star count: " + str(self.star_count), 10, 25 )
def draw(self): self.pre_draw() # save current transform bacon.push_transform() # scale bacon.scale(self.scale_x, self.scale_y) # rotate bacon.rotate(math.radians(self.angle)) # move self.x += (self.velocity[0] * bacon.timestep) self.y += (self.velocity[1] * bacon.timestep) if(self.wrap_object_movement): if(self.x < 0): self.x = bacon.window.width elif(self.x > bacon.window.width): self.x = 0 if(self.y < 0): self.y = bacon.window.height elif(self.y > bacon.window.height): self.y = 0 bacon.translate(self.x, self.y) # save current rgba values bacon.push_color() # set new color + alpha value if self.is_blinking: # if sprites alpha is greater than or equal to 1 then set alpha value to negatie if(self.alpha >= 1): self.alpha = 1 self.blink_speed = -(self.blink_speed) # -0.5 # if the pirate sprites alpha is lesser than 0 then set alpha value to positive elif(self.alpha < 0): self.alpha = 0 self.blink_speed = abs(self.blink_speed) # 0.5 # blink! self.alpha += (self.blink_speed * bacon.timestep) bacon.set_color(self.color[0], self.color[1] , self.color[2] , self.alpha) self.draw_object() # reset color bacon.pop_color() # reset transform bacon.pop_transform() self.post_draw()
def draw(self): # save current transform bacon.push_transform() # move bacon.translate(self.x, self.y) # scale bacon.scale(self.scale_x, self.scale_y) # rotate bacon.rotate(math.radians(self.angle)) # save current rgba values bacon.push_color() # set new color + alpha value bacon.set_color(self.color[0], self.color[1], self.color[2], self.alpha) # draw image bacon.draw_image(self.image, -(self.image.width / 2), -(self.image.height / 2)) # reset color bacon.pop_color() # reset transform bacon.pop_transform()
def on_tick(self): bacon.clear(0, 0, 0, 1) bacon.translate(kitten.width / 2, kitten.height / 2) bacon.rotate(math.pi / 4) bacon.draw_image(kitten, -kitten.width / 2, -kitten.height / 2)