def on_draw(self): arcade.start_render() arcade.draw_text_2("Game Over!", 320, SCREEN_HEIGHT / 2, arcade.color.BLACK, 40, bold=True) self.Back.draw_button() self.Replay.draw_button()
def on_draw(self): arcade.start_render() self.play.draw_button() self.back.draw_button() arcade.draw_text_2("User Guide", 425, 550, arcade.color.BLACK, 20, bold=True) self.messageDisplay()
def draw_button(x, y, button_width, button_height, colour_default, text, colour_hover, colour_press): if x + (button_width / 2) > mouse_x > x - (button_width / 2) and \ y - (button_height / 2) < mouse_y < y + (button_height / 2) and \ mouse_press: arcade.draw_rectangle_filled(x, y, button_width, button_height, colour_press) elif x + (button_width / 2) > mouse_x > x - (button_width / 2) and \ y - (button_height / 2) < mouse_y < y + (button_height / 2) and \ not mouse_press: arcade.draw_rectangle_filled(x, y, button_width, button_height, colour_hover) else: arcade.draw_rectangle_filled(x, y, button_width, button_height, colour_default) arcade.draw_text_2(text, x-25, y-7, arcade.color.BLACK, 12, bold=True)
def on_draw(self): arcade.start_render() arcade.draw_lrwh_rectangle_textured(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, self.backdrop) arcade.draw_rectangle_filled(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 50, SCREEN_WIDTH, 100, (127, 212, 23, 127)) arcade.draw_text_2(f"score:{self.score}", 100, SCREEN_HEIGHT - 100, arcade.color.WHITE, 15, align="center") self.Barriers.draw_wall_up() self.Hero.draw_hero() self.Barriers.draw_wall_down() self.Hero.bulletDraw()
def draw_button(self): textLenght = len(self.text) deducX = 25 if textLenght == 5: deducX = 25 elif textLenght > 5: times = textLenght - 5 while times > 0: deducX += 5 times -= 1 else: times = 5 - textLenght while times > 0: deducX -= 5 times -= 1 arcade.draw_rectangle_filled(self.center_x, self.center_y, self.width, self.height, self.color) arcade.draw_text_2(self.text, (self.center_x - deducX), (self.center_y - self.height * 0.15), self.text_color, font_size=15) #Top arcade.draw_line(self.center_x - self.width / 2, self.center_y + self.height / 2, self.center_x + self.width / 2, self.center_y + self.height / 2, self.shadow_color1, 2) #Left arcade.draw_line(self.center_x - self.width / 2, self.center_y + self.height / 2, self.center_x - self.width / 2, self.center_y - self.height / 2, self.shadow_color1, 2) #Right arcade.draw_line(self.center_x + self.width / 2, self.center_y + self.height / 2, self.center_x + self.width / 2, self.center_y - self.height / 2, self.shadow_color1, 2) #buttom arcade.draw_line(self.center_x - self.width / 2, self.center_y - self.height / 2, self.center_x + self.width / 2, self.center_y - self.height / 2, self.shadow_color1, 2)
def messageDisplay(self): arcade.draw_rectangle_filled(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 500, 420, (110, 100, 20, 50)) arcade.draw_text_2("Controls :", 300, 470, arcade.color.WHITE, 20) arcade.draw_text_2("To move your hero use the", 300, 420, arcade.color.WHITE, 20) arcade.draw_text_2("arrow keys. ", 300, 370, arcade.color.WHITE, 20) arcade.draw_text_2("To attack use the 'A' key to attack", 300, 320, arcade.color.WHITE, 20) arcade.draw_text_2("Goal :", 300, 270, arcade.color.WHITE, 20) arcade.draw_text_2("Dont be killed !!!", 300, 220, arcade.color.WHITE, 20)