From the course: Code Clinic: Ruby
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Adding an indicator
- Now that we have a basic project started, in this movie we'll learn to read the mouse coordinates in order to add an indicator or cursor at that position. So I've added another file to my project called indicator.rb inside the lib directory. There's no changes to init.rb at all but I have made changes to pitch_maker.rb. I've told it that it ought to require that indicator file, so that's going to load up all of that code to make sure that's available and that's because the PitchMaker class is going to make use of it, so it needs to be required. So we're going to look down here and you'll see that initialize I'm going to create a new instance of the indicator class. And I'm going to pass it self. What I'm passing here is the Window, right? A Gosu Window, that's what a PitchMaker is, it's inherited from Gosu Window. I'm going to pass that Window into the Indicator. And that's important to always pass that into the objects when you're working with Gosu. Because it allows those objects…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.