Class: AsciiParadise::AnimatedPacman
- Includes:
- Math
- Defined in:
- lib/ascii_paradise/animations/animated_pacman.rb
Constant Summary collapse
- YELLOW_AND_RESET =
#
YELLOW_AND_RESET
#
"\033[1;33m\033[?25l"
Constants inherited from Animation
AsciiParadise::Animation::RUN_N_TIMES
Instance Method Summary collapse
-
#initialize(run_already = true) ⇒ AnimatedPacman
constructor
# === initialize ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
Methods inherited from Animation
#ascii_files?, #dataset?, #delay?, #display, #display_the_frame, #do_clear?, #do_use_colour_spray, #do_use_disco_inferno, #do_use_half_colours, #do_use_rainbow_colours, #guess_filename, is_animated?, #is_animated?, #load_animated_ascii_files_from_this_directory, #load_ascii_files, #load_ascii_files_and_determine_the_dataset, #load_dataset, #mediumpurple, #parse_dataset_from_this_control_file, #reset, #return_filename, #return_the_name_to_the_proper_animation_directory_of_this_animated_component, run, #run_n_times?, #run_with_this_dataset, #run_with_this_dataset_while_waiting_for_keypress_events, #set_dataset, #set_delay, #set_run_n_times, #set_use_ascii_files_from_this_directory, #show_frame_at_this_position, #show_to_the_user_how_to_operate_the_keypress_interface, #sleep_with_the_default_delay, #use_disco_inferno?
Methods inherited from Base
animation_dir?, #animation_directory?, #clear_screen, #colour_parse_this_string, #debug?, #do_not_run_already, #do_not_use_clear, #do_use_random_colour, #do_wait_for_keypress_event, e, #e, #enable_debug, #is_animated?, #menu, #project_base_dir?, #register_sigint, #remove_trailing_ansci_escape_code, #report_how_many_animated_components_exist, #reset, #return_basename_of_this_file_without_the_extension, #return_random_colour, #rev, #royalblue, run, #set_use_this_colour, #sfancy, #sfile, #show_available_components, #show_help, #simp, #slategrey, #sort_files, #static_dir?, #steelblue, #swarn, #use_colours?
Constructor Details
#initialize(run_already = true) ⇒ AnimatedPacman
#
initialize
#
26 27 28 29 30 31 |
# File 'lib/ascii_paradise/animations/animated_pacman.rb', line 26 def initialize( run_already = true ) super() run if run_already end |
Instance Method Details
#run ⇒ Object
#
run
#
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ascii_paradise/animations/animated_pacman.rb', line 36 def run print CLEAR_COMMAND+YELLOW_AND_RESET # This will also turn the stuff to yellow. z = 0.0 dz = 0.05 loop { z += dz # Add the 0.05 difference to z. dz = -dz if ( z < 0.0 || z > 0.2) print "\033[0;0f" (-10..10).each {|y| s = ''.dup # This will be the string that will be displayed. (-39..39).each {|x| s << ((x/2) ** 2 + y ** 2 < 11 ** 2\ && atan2(y,x/2) < PI * (1.0 - z) \ && atan2(y,x/2) > -PI * (1.0 - z) ? '@':' ') } puts s } sleep 0.03 } # ';reset # Get cursor back :) end |