The code creates a very simple/easy RPG game, with 2 classes `Jedi` and `Orc`. The data is visualized using `turtle`. Each class has a method of `attack` (`lightsaber_attack` for `Jedi`), which has an argument that must be either a `Jedi` or `Orc` instance. The `.health` attribute of the attacked one will be reduced by `.power` of the attacker. If `.health` is not positive, then the image of the character will disappear. By design, each character can attack itself. Simulation --- luke.lightsaber_attack( orc_1 ) luke.lightsaber_attack( orc_2 ) orc_1.attack( luke ) orc_2.attack( orc_2 ) Questions --- - How can I make the code to be easily understood by teenagers? (in a tutorial) - How can I make it more compact? - Are there any missing important features of Python's OOP that are important to be explained to students? (other than `super` and inheritance) Image Links --- - [jedi.gif][1] - [orc.gif][2] - [darkorc.gif][3] - [damaged.gif][4] Full code --- import turtle import time jedi_gif = "jedi.gif" orc_gif = "orc.gif" darkorc_gif = "darkorc.gif" damaged_gif = "damaged.gif" turtle.register_shape( jedi_gif ) turtle.register_shape( orc_gif ) turtle.register_shape( darkorc_gif ) turtle.register_shape( damaged_gif ) class JediLuke: def __init__(self): self.power = 300 self.health = 300 self.img = turtle.Turtle( shape = jedi_gif ) self.damaged_img = turtle.Turtle( shape = damaged_gif, visible = False ) self.img.penup() self.damaged_img.penup() def lightsaber_attack(self, enemy): self.img.setpos(enemy.img.pos()[0], enemy.img.pos()[1]) enemy.damaged_img.showturtle() enemy.health += - self.power time.sleep(1) enemy.damaged_img.hideturtle() if enemy.health < 0: enemy.img.hideturtle() self.img.setpos(200, 0) def change_pos(self, pos): self.img.setpos(pos[0], pos[1]) self.damaged_img.setpos(pos[0], pos[1] + 150) class Orc: def __init__(self, health, gif_image): self.power = 100 self.health = health self.img = turtle.Turtle( shape = gif_image ) self.damaged_img = turtle.Turtle( shape = damaged_gif, visible = False ) self.img.penup() self.damaged_img.penup() def attack(self, enemy): current_pos = self.img.pos() self.img.setpos(enemy.img.pos()[0], enemy.img.pos()[1]) enemy.damaged_img.showturtle() enemy.health += - self.power time.sleep(1) enemy.damaged_img.hideturtle() if enemy.health < 0: enemy.img.hideturtle() self.img.setpos(current_pos[0], current_pos[1]) def change_pos(self, pos): self.img.setpos(pos[0], pos[1]) self.damaged_img.setpos(pos[0], pos[1] + 150) luke = JediLuke() luke.change_pos( [200, 0] ) orc_1 = Orc( health = 400 , gif_image = orc_gif) orc_1.change_pos( [-200, 100] ) orc_2 = Orc( health = 200, gif_image = darkorc_gif ) orc_2.change_pos( [-200, -100] ) [1]: https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwit1aug3sLfAhVLqI8KHXkhDVQQjRx6BAgBEAU&url=http%3A%2F%2Fphotobucket.com%2Fgifs%2Fluke%2520skywalker%2520gif&psig=AOvVaw0FAdw5ahuUpluC-GQ9eF2D&ust=1546093763401668 [2]: https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=2ahUKEwj75dWp38LfAhUMPo8KHRpPBskQjRx6BAgBEAU&url=https%3A%2F%2Fgfycat.com%2Fstickers%2Fsearch%2Femotion&psig=AOvVaw1v2XvKNJ1bf269uBJjJuev&ust=1546093997773408 [3]: https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjgsPHS38LfAhUMbo8KHZc2AOIQjRx6BAgBEAU&url=http%3A%2F%2Fgramunion.com%2Ftagged%2Fturn%2520based%3Fn%3D1483708547&psig=AOvVaw0ANko0SvmFdD0NRue0I3X1&ust=1546094092497653 [4]: https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=2ahUKEwjD8IOF4MLfAhVINo8KHbO7DaUQjRx6BAgBEAU&url=https%3A%2F%2Fgifer.com%2Fen%2F3IsK&psig=AOvVaw1Jlevg6MxHqG_Xv4XBkeTg&ust=1546094231810744