Class: NeSpat::Executors::XXX
Constant Summary collapse
- SPEED =
200- RADIUS =
125- HEIGHT_TO_SCREEN_RATIO =
0.5- WIDTH_TO_SCREEN_RATIO =
0.125- UPPER_SEMICIRCLE_DISTORTION =
1.5
Instance Attribute Summary collapse
-
#base_x ⇒ Object
readonly
Returns the value of attribute base_x.
-
#base_y ⇒ Object
readonly
Returns the value of attribute base_y.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
- #default_speed ⇒ Object
-
#initialize(_) ⇒ XXX
constructor
A new instance of XXX.
- #left_lower_semicircle ⇒ Object
- #left_upper_semicircle ⇒ Object
- #left_wall ⇒ Object
- #right_lower_semicircle ⇒ Object
- #right_upper_semicircle ⇒ Object
- #right_wall ⇒ Object
- #upper_semicircle ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(_) ⇒ XXX
Returns a new instance of XXX.
12 13 14 15 16 |
# File 'lib/ne_spat/executors/xxx.rb', line 12 def initialize(_) super @base_x = mouse.screen_size[:x] / 2 @base_y = (mouse.screen_size[:y] * 0.75).to_i end |
Instance Attribute Details
#base_x ⇒ Object (readonly)
Returns the value of attribute base_x.
10 11 12 |
# File 'lib/ne_spat/executors/xxx.rb', line 10 def base_x @base_x end |
#base_y ⇒ Object (readonly)
Returns the value of attribute base_y.
10 11 12 |
# File 'lib/ne_spat/executors/xxx.rb', line 10 def base_y @base_y end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ne_spat/executors/xxx.rb', line 18 def call parts = [ left_upper_semicircle, left_lower_semicircle, right_upper_semicircle, right_lower_semicircle, left_wall, upper_semicircle, right_wall ] loop do parts.each do |part| part.each do |x, y| sleep(interval) mouse.move(x, y) end end end end |
#default_speed ⇒ Object
71 72 73 |
# File 'lib/ne_spat/executors/xxx.rb', line 71 def default_speed SPEED end |
#left_lower_semicircle ⇒ Object
42 43 44 |
# File 'lib/ne_spat/executors/xxx.rb', line 42 def left_lower_semicircle (RADIUS..-RADIUS).step(-1).map { |x| [base_x - x - RADIUS, base_y - Math.sqrt(RADIUS**2 - x**2).to_i] } end |
#left_upper_semicircle ⇒ Object
38 39 40 |
# File 'lib/ne_spat/executors/xxx.rb', line 38 def left_upper_semicircle (-RADIUS..RADIUS).map { |x| [base_x - x - RADIUS, base_y + Math.sqrt(RADIUS**2 - x**2).to_i] } end |
#left_wall ⇒ Object
54 55 56 57 58 |
# File 'lib/ne_spat/executors/xxx.rb', line 54 def left_wall (0..mouse.screen_size[:y]).step(2).map do |delta| [base_x - (delta * WIDTH_TO_SCREEN_RATIO).to_i, base_y - (delta * HEIGHT_TO_SCREEN_RATIO).to_i] end end |
#right_lower_semicircle ⇒ Object
50 51 52 |
# File 'lib/ne_spat/executors/xxx.rb', line 50 def right_lower_semicircle (-RADIUS..RADIUS).map { |x| [base_x - x + RADIUS, base_y - Math.sqrt(RADIUS**2 - x**2).to_i] } end |
#right_upper_semicircle ⇒ Object
46 47 48 |
# File 'lib/ne_spat/executors/xxx.rb', line 46 def right_upper_semicircle (RADIUS..-RADIUS).step(-1).map { |x| [base_x - x + RADIUS, base_y + Math.sqrt(RADIUS**2 - x**2).to_i] } end |
#right_wall ⇒ Object
60 61 62 63 |
# File 'lib/ne_spat/executors/xxx.rb', line 60 def right_wall (mouse.screen_size[:y]..0).step(-2) .map { |delta| [base_x + (delta * WIDTH_TO_SCREEN_RATIO), base_y - (delta * HEIGHT_TO_SCREEN_RATIO)] } end |
#upper_semicircle ⇒ Object
65 66 67 68 69 |
# File 'lib/ne_spat/executors/xxx.rb', line 65 def upper_semicircle radius = (mouse.screen_size[:y] * WIDTH_TO_SCREEN_RATIO).to_i y = mouse.screen_size[:y] - base_y (-radius..radius).map { |x| [base_x + x, y - (Math.sqrt(radius**2 - x**2) * UPPER_SEMICIRCLE_DISTORTION).to_i] } end |