Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Welcome screen #17

Open
3 tasks
jugglinmike opened this issue Sep 25, 2014 · 0 comments
Open
3 tasks

Welcome screen #17

jugglinmike opened this issue Sep 25, 2014 · 0 comments
Milestone

Comments

@jugglinmike
Copy link
Collaborator

Right now, the game starts immediately after you visit the page. We want to
display a title screen and let the user decide when the game should begin by
clicking a "Start" button.

You might have noticed that by now, the Director constructor has a lot of code
in it! As we implement this new feature, you'll see that the code in the
constructor shrinks as well. This is normal; usually, constructors have just
the "set up" code for a class. It's only because we started this project from
scratch that things kind of got out-of-hand.

The moment you create an instance of the Director class, it (1) sets up all the
variables it needs (the different counts, the DOM element, and the Mole
instances), and (2) begins the game (appending all the Mole elements to the
container, scheduling all the moles to show, and setting a countdown for the
end game).

The first set of operations can stay put--all that stuff kind of defines the
Director--it wouldn't be useful without it. The second set, though--that's
actually code that concerns starting the game. We should delay that until the
player is ready to start.

  • director.js
    • Define a start method on the Director prototype. Move all the logic
      that has to do with starting the game from the Director constructor into
      this function.

    • In the Director's constructor, set the innerHTML of the el to a
      title screen. This can be as simple (and ugly) or complex (and beautful) as
      you like. Just make sure it has a <button> somewhere.

    • After setting the innerHTML, grab the <button> element using:

      this.el.getElementsByTagName('button')[0]

      ...and then call addEventListener on that.
      We want to attach a click handler function that simply calls the new
      start method.

@jugglinmike jugglinmike modified the milestone: Game state 1 Sep 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant