Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1352

Re: Reseting the ball after changes

From Michael Adedeji <yankosmgt@gmail.com>
Newsgroups comp.lang.java.help
Subject Re: Reseting the ball after changes
Date 2011-11-15 16:34 -0800
Organization http://groups.google.com
Message-ID <ce0fcc32-bd6f-4e32-a749-ecfe61f7dd08@n14g2000vbn.googlegroups.com> (permalink)
References <1bebffda-d16a-4cb0-b443-6fab7306b8fc@g21g2000yqc.googlegroups.com> <nospam-545B37.11514815112011@news.aioe.org>

Show all headers | View raw


On Nov 15, 4:51 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <1bebffda-d16a-4cb0-b443-6fab7306b...@g21g2000yqc.googlegroups.com>,
>  Michael Adedeji <yankos...@gmail.com> wrote:
>
> > I have done the menu, but I have problem with reseting of the ball,
> > everytime I change the size or the speed of the ball, it kind of
> > change the way the sounds works. I kinda figure out that I need to
> > reset it everytime I change the size or the speed of the ball.
>
> Exactly, you're changing the (implicit) model's state behind the view's
> back.
>
> > Does anyone have an idea how I could go about it.
>
> I'd reiterate my earlier suggestion on MVC [1]; it's time to re-factor.
> As an alternative, the example cited adjusts the Timer's rate, rather
> than the velocity's norm. A similar problem arises when the simulated
> boundary is resized; the model has a corresponding setWalls() method.
>
> [1] <https://groups.google.com/d/msg/comp.lang.java.help/u2r-L6H_kD4/t2Q16...>
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>

Hey John Matthews, how can i connect timer with this code?? the color
is flashing different color same time, but i want it to change color
like every 3seconds or so...
private static final float N = 64;
private final Queue<Color> clut = new LinkedList<Color>();
Fill it with a suitable gamut:
for (int i = 0; i < N; i++) {
    clut.add(Color.getHSBColor(i / N, 1, 1));
}

And cycle through it:
public void paintComponent(Graphics g) {
    ...
    g.setColor(clut.peek());
    g.fillOval(...);
    clut.add(clut.remove());
    ...
}

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Reseting the ball after changes Michael Adedeji <yankosmgt@gmail.com> - 2011-11-14 05:14 -0800
  Re: Reseting the ball after changes "John B. Matthews" <nospam@nospam.invalid> - 2011-11-15 11:51 -0500
    Re: Reseting the ball after changes Michael Adedeji <yankosmgt@gmail.com> - 2011-11-15 13:14 -0800
    Re: Reseting the ball after changes Michael Adedeji <yankosmgt@gmail.com> - 2011-11-15 16:34 -0800
      Re: Reseting the ball after changes "John B. Matthews" <nospam@nospam.invalid> - 2011-11-16 00:17 -0500
        Re: Reseting the ball after changes Michael Adedeji <yankosmgt@gmail.com> - 2011-11-16 02:32 -0800
          Re: Reseting the ball after changes "John B. Matthews" <nospam@nospam.invalid> - 2011-11-16 10:37 -0500

csiph-web