SHARE
TWEET

Untitled

a guest Nov 19th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def draw_ninja(pos,width):
  2.     #draw a ninja as requested such that pos is the righ-down position of the ninja
  3.     #and width is the size of the bounding box of the ninja (and should be used to determine
  4.     #the unit size of the squares in the bounding box
  5.     c=width//6
  6.     w=get_value_of("_w")
  7.     print(pos)
  8.     """
  9.     corps=create_rectangle(pos,c,c,(255,0,0))
  10.     jambe1=create_rectangle(pos,c,c,(255,0,0))
  11.    
  12.     bandeau=create_rectangle(pos,c,c,(255,0,0))
  13.     """
  14.     jambe2=create_rectangle((pos[0],pos[1]),c,c,(0,0,0))
  15.     """
  16.     casebandeau1=create_rectangle((pos,w["height"]-c*6),c,c,(255,0,0))
  17.     casebandeau2=create_rectangle(pos,c,c,(255,0,0))
  18.     oeil=create_rectangle(pos,c,c,(255,0,0))
  19.    
  20.     draw_rectangle(corps)
  21.     draw_rectangle(jambe1)
  22.    
  23.     draw_rectangle(bandeau)
  24.     """
  25.     draw_rectangle(jambe2)
  26.     """
  27.     draw_rectangle(casebandeau1)
  28.     draw_rectangle(casebandeau2)
  29.     draw_rectangle(oeil)
  30.     """
  31.     return
  32.    
  33. def draw_stick(pos,lenght,thickness):
  34.     #draw a vertical stick of a given thickness such that the bottom of the stick is at position pos and
  35.     #it goes up until the given lenght
  36.     return
  37.  
  38. def draw_platforms(min_gap, min_platform_width, platform_height):
  39.     #draw two platforms of height platform_height
  40.     #the first platform starts from the left border of the window and is exactly of width min_platform_width
  41.     #there is a minimal gap of min_gap between the two platforms
  42.     #moreover the second platform has a random size respecting the min_platform_width and the fact that
  43.     #a minimal gap of min_gap with the right border of the window should exist
  44.     #The second platform has a 10x10 square right in the top middle to indicate the perfect lenght for the stick
  45.     #The function returns the position of the top right corner of the first platform and the perfect distance for the stick
  46.     return ((0,0),0)
  47.  
  48. def draw_score():
  49.     #draw a random number in [0,10] at the top-center of the window
  50.     _w=get_value_of("_w")
  51.     s=randrange(0,10)
  52.     score=create_text(str(s), (_w["width"]/2,0), (255,0,0), 20, textanchor="topmiddle")
  53.     draw_text(score)
  54.     return
  55.    
  56. def draw():
  57.     #should not been modified
  58.     _state=get_value_of("_state")
  59.     if _state=="init":
  60.         print("init")
  61.         set_value_of("_w",initialize(randrange(200,600),randrange(400,600),'Ninja'))
  62.         set_value_of("_state","draw")
  63.         set_value_of("_cpt",0)
  64.         return
  65.     if _state=="draw":
  66.         set_value_of("_cpt",get_value_of("_cpt")+1)
  67.         if get_value_of("_cpt")>5:
  68.             set_value_of("_state","destroy")
  69.             return
  70.         w=get_value_of("_w")
  71.         fill_window((255,255,255))
  72.         (p,d)=draw_platforms(w["width"]//10,2*w["width"]//10,w["height"]//10)
  73.         draw_ninja(p,w["width"]//10)
  74.         draw_stick(p,d,w["width"]//100)
  75.         draw_score()
  76.         return
  77.     if _state=="destroy":    
  78.         uninitialize()
  79.         return
  80.  
  81.  
  82. def main_app():
  83.     set_value_of("_state","init")
  84.     repeat_process(3000,draw)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top