Advertisement
otorp2

godot red circle

Apr 16th, 2020
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. extends Node2D
  2.  
  3. var x = 1
  4.  
  5. func _ready():
  6.    
  7.     pass
  8.  
  9. func _draw():
  10.     #draw_circle(Vector2(50,50),20,Color(255,0,0));
  11.     x=x+10
  12.     var center = Vector2(300, 300)
  13.     var radius = 200
  14.     var angle_from = -4*x
  15.     var angle_to = x
  16.     var color = Color(1.0, 0.0, 0.0)
  17.    
  18.     draw_circle_arc(center, radius, angle_from, angle_to, color)
  19.     print(x)
  20.     pass
  21.  
  22. func draw_circle_arc(center, radius, angle_from, angle_to, color):
  23.     var nb_points = 34
  24.     var points_arc = PoolVector2Array()
  25.  
  26.     for i in range(nb_points + 4):
  27.         var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90)
  28.         points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
  29.  
  30.     for index_point in range(nb_points):
  31.         draw_line(points_arc[index_point], points_arc[index_point + 1], color,2)
  32.  
  33.  
  34.  
  35. func _process(delta):
  36.     update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement