// A parent class intended to represent any type of element that can scroll along // the staff (e.g. notes, speed changes, etc) // HOOK: Extend this class to create your own scrolling element types abstract class ScrollElement { protected int m_x, m_y; protected boolean m_hit, m_miss, m_dead; protected Staff m_staff; public ScrollElement(Staff staff, int newX, int newY) { m_staff = staff; m_x = newX; m_y = newY; m_hit = false; m_miss = false; m_dead = false; } public int getX() { return m_x; } public int getY() { return m_y; } public void setX(int x) { m_x = x; } public void setY(int y) { m_y = y; } // HOOK: // Add in these functions with appropriate values even // if not using some of them in the new, extended version // (that way you can keep everything compiling and just add // your extensions). public abstract boolean isNote(); public abstract boolean isSpeedChange(); public boolean offScreen() { return m_x > Config.gameWidth; } public void advance() { if (m_x <= Config.boundaryX) { hitBoundary(); return; } m_x -= m_staff.getScrollSpeed(); } // HOOK: Override to define when the element is "dead" or otherwise done public boolean removeMe() { return (m_dead || m_miss); } // HOOK: Override to define when element is still in play (i.e. can have actions taken against it) public boolean inPlay() { return !(m_dead || m_miss || m_hit); } // HOOK: Override in your element to take a specific action when it the player // successfully pressed the correct key associated with this element // (if applicable) public void hit() { m_hit = true; // maybe we could hook up a cool animation here // or play a sound... } // HOOK: Override in your element to take a specific action when it reaches the other // side of the screen public void miss() { m_miss = true; // maybe we could hook up a cool animation here // or increase the game speed... } // HOOK: Override to define what happens when element reaches boundary on screen public void hitBoundary() { m_dead = true; } // HOOK: Override to make your custom drawing behaviour public void draw() { // Do nothing } }