[racket] Doing collision detection in universe.ss

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Nov 28 08:00:22 EST 2012

For what it's worth


is an implementation of the Scratch sprite and evaluation model plus a
textual language. It has all of the drawbacks of Scratch --- mutation,
race conditions, and busy waiting --- without the nice graphical
syntax! It has a collision detector that's much like John's, but I
spent some time making it go faster. There's also a notion of "lands"
within a program.

I wrote Scratchy as an example of building languages in Racket for this
year's RacketCon.[*] I dream about a phase 2 where I figure out how to
change the evaluation model to something good and/or connect with
`2htdp/universe', but I don't see that happening soon.

[*] At the suggestion of my son. He's a Scratch fan, though he quickly
    became frustrated by the lack of abstraction in Scratch, and I
    don't know whether to be happy or sad that he's a 12-year-old who
    understands the phrase "race condition". Scratchy has "lands" because
    he wanted something like that for his game.

At Wed, 28 Nov 2012 07:37:27 -0500, Yaron Minsky wrote:
> To be clear, I'm firmly interested in tinkering, which is why I'm
> using universe.ss and image.ss.
> I do think that a good design goal for Racket's kid-oriented libraries
> would be to be feature compatible with Scratch.  It would be great if
> there were good ways of doing everything that Scratch can do, from
> playing sounds to detecting collisions, to (more aggressively) on-line
> hosting of the final result.  I'd love it if Racket were strictly
> better than Scratch for someone who really can figure out how to
> program, but it's just not true now.
> y
> On Wed, Nov 28, 2012 at 7:11 AM, Hendrik Boom <hendrik at topoi.pooq.com> wrote:
> > On Tue, Nov 27, 2012 at 08:56:13PM -0500, Yaron Minsky wrote:
> >> I've been weaning my son off of Scratch in favor of Racket, and trying
> >> to get him to write interactive games using universe.ss and image.ss.
> >> I'm wondering if anyone has suggestions for how to do things like
> >> collision detection.  image.ss has these nice first-class images, but
> >> I don't see a good way of querying two images to see if they overlap.
> >>
> >> Has anyone else had luck in doing this?  universe has a nice
> >> programming model, but I've found it challenging to find simple ways
> >> of doing the kinds of things that Scratch makes easy.
> >
> > There are two arts to collision detection: figuring out whether two
> > images collide (which gets trickier when they're in motion) and
> > organising all your objects so you don't have to test very many
> > combinations of them.
> >
> > Both of these can get quite complicated, and are susceptible to
> > nontrivial, complicated, and often necessary efficiency improvements
> > depending on special properties of the game.
> >
> > A one-size-fits-all solution may be good enough for tinkering with, but
> > serious use may well need serious hacking.
> >
> > -- hendrik
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.