Skip to main content
Rollback to Revision 5
Source Link
Mast
  • 13.5k
  • 12
  • 54
  • 119
import turtle
import time

jedi_gif = "jedi.gif" #this was previously "/home/asus/Arief_tempo/images/random/jedi.gif", which is a mistake.. reminded by @Reinderien  
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] )
import turtle
import time

jedi_gif = "jedi.gif" #this was previously "/home/asus/Arief_tempo/images/random/jedi.gif", which is a mistake.. reminded by @Reinderien  
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] )
import turtle
import time

jedi_gif = "/home/asus/Arief_tempo/images/random/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] )
added 55 characters in body
Source Link
Redsbefall
  • 1.1k
  • 2
  • 10
  • 23
import turtle
import time

jedi_gif = "jedi.gif" #this was previously "/home/asus/Arief_tempo/images/random/jedi.gif", which is a mistake.. reminded by @Reinderien  
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] )
import turtle
import time

jedi_gif = "/home/asus/Arief_tempo/images/random/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] )
import turtle
import time

jedi_gif = "jedi.gif" #this was previously "/home/asus/Arief_tempo/images/random/jedi.gif", which is a mistake.. reminded by @Reinderien  
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] )
Tweeted twitter.com/StackCodeReview/status/1078757618598977536
added 37 characters in body
Source Link
Mast
  • 13.5k
  • 12
  • 54
  • 119
import turtle
import time

jedi_gif = "jedi"/home/asus/Arief_tempo/images/random/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] )
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] )
import turtle
import time

jedi_gif = "/home/asus/Arief_tempo/images/random/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] )
deleted 371 characters in body
Source Link
Redsbefall
  • 1.1k
  • 2
  • 10
  • 23
Loading
deleted 37 characters in body
Source Link
Redsbefall
  • 1.1k
  • 2
  • 10
  • 23
Loading
grammar and formatting
Source Link
Reinderien
  • 65.6k
  • 5
  • 70
  • 191
Loading
Source Link
Redsbefall
  • 1.1k
  • 2
  • 10
  • 23
Loading