Hi Erik,

I'm not sure this is a correct answer, but it works on my pc. :)
WindowsXP and Shoes-0.r925

Shoes.app do
   @img = image(400,400)
   @img.fill black
   animate do
       @img.rect(10, 10, 20, 20).show
   end
end

Regards,
ashbb




On Fri, Sep 5, 2008 at 8:30 AM, Erik Weitnauer <[EMAIL PROTECTED]>wrote:

> On Wed, Aug 27, 2008 at 6:17 PM, _why <[EMAIL PROTECTED]> wrote:
> > On Wed, Aug 27, 2008 at 10:00:58AM -0400, Nick Quaranto wrote:
> >> Hi everyone, over the past few days I've been working on a clone of
> Snake
> >> for Shoes. The game is definitely working, and I'd appreciate any
> feedback
> >> that you're willing to give. I'm also running into some slowdown issues
> as
> >> players get snakes that are pretty huge, and the game seems to run
> slower as
> >> someone keeps on playing it. If anyone can help with these issues I'd
> love
> >> to pull your changes :)
> >
> > Hey, great work!  I have a few suggestions for how you can speed
> > things up.
> >
> > Probably the way to make things the fastest is to draw on to an
> > image surface.  This ends up faster because you don't wind up
> > creating a bunch of Ruby objects for every shape you draw.
> >
> > Basically, here's how to do it:
> >
> >  1. In app.rb, change `Field.new(self)` to
> >     `Field.new(image(400, 400))`.
> >  2. In field.rb, change [EMAIL PROTECTED] black` to
> >     [EMAIL PROTECTED] "#000"`.
> >
> > That just creates a 400px by 400px image surface for you to paint
> > on.
> >
> > Now, as alluded, the real reason it's running slow is because Ruby
> > objects are piling up.  All the old rectangles are still sitting
> > around every time the snake is drawn.  These need to be cleared out.
> > (Unless you use an image surface, as shown above.)
> >
> > So, basically, if you stick with the technique you're using right
> > now, you'll need to call [EMAIL PROTECTED] every time you repaint and
> > then redraw all the shapes from there.
> >
> > _why
> >
>
> Hi,
> I just started with shoes some days ago and I would be glad if anybody
> could help me about how to get the painting on an image surface to
> work. I tried with the following code, but it doesn't seem to do what
> I expected:
>
> Shoes.app do
>    @img = image(400,400)
>    @img.fill black
>    animate do
>        @img.rect 10, 10, 20, 20
>    end
> end
>
> What am I doning wrong?
>
> (I want to draw 1000s of tiny boxes / pixels per animation cycle
> later, so this is why I am trying to use an image surface for it.)
>
> Thanks,
> Erik.
>

Reply via email to