Advertisement
PhilDrummer

Assignment_7 02 GHOST.e

Nov 19th, 2014
3,463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 0.94 KB | None | 0 0
  1. note
  2.     description: "Adds a ghost and moves it."
  3.     author: "Philipp Schaad"
  4.     date: "19.11.2014"
  5.     revision: "1.0"
  6.  
  7. class
  8.     GHOST
  9.  
  10. inherit
  11.     MOBILE
  12.  
  13. create
  14.     make
  15.  
  16. feature -- Create
  17.  
  18.     make (s: STATION; r: REAL_64)
  19.  
  20.         do
  21.             radius_length := r
  22.             orbit_station := s.position
  23.             create orbit_radius.make (r, 0)
  24.             position := orbit_station + orbit_radius
  25.         end
  26.  
  27. feature -- Constants
  28.  
  29.     speed: REAL_64
  30.             -- Speed of the ghosts
  31.         do
  32.             Result := 20
  33.         end
  34. feature -- Attributes
  35.  
  36.     orbit_station: VECTOR
  37.             -- Orbit station held as a vector
  38.  
  39.     orbit_radius: VECTOR
  40.             -- Orbit radius held as a vector
  41.  
  42.     radius_length: REAL_64
  43.  
  44. feature -- Calculate
  45.  
  46.     position: VECTOR
  47.             -- Ghosts Position
  48.  
  49.     move_distance (d: REAL_64)
  50.             -- Distance to move
  51.         local
  52.             angle_turn: REAL_64
  53.         do
  54.             angle_turn := d / radius_length
  55.             orbit_radius := orbit_radius.rotated (angle_turn)
  56.             position := orbit_station + orbit_radius
  57.         end
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement