the opposite of a gun

[open in p5.js]

gun_opposite_2.gif

In his poem, “The Opposite Game,” Brendan Constantine describes the experience of teaching antonyms to kids—translating each word of Dickinson’s famed “My life had stood a loaded gun,” verse into opposites.

My Your
Life Death
Had stood Will sit
A Many
Loaded Empty
Gun ?

But what is the opposite of a gun?

I became obsessed with this poem after my friend N shared it this morning. I must have read it over a half-dozen times since.

(Sometimes the best refuge against the news is poetry.)

~~~~
In the poem, the school kids tackle this question in earnest:

Flower, says one. No, Book, says another. That’s stupid,
cries a third, the opposite of a gun is a pillow. Or maybe
a hug, but not a book, no way is it a book. With this,
the others gather their thoughts

The discussion goes on and on.

Well, maybe. Maybe it’s everything we said. Maybe it’s
everything we didn’t say. It’s words and the spaces for words.
They’re looking at each other now. It’s everything in this room
and outside this room and down the street and in the sky.

It’s everyone on campus and at the mall, and all the people
waiting at the hospital. And at the post office. And, yeah,
it’s a flower, too. All the flowers. The whole garden.
The opposite of a gun is wherever you point it.

The opposite of a gun is wherever you point it. Such a good line.

In fact, the the whole poem is just so beautiful, through and through. Read it!

By the end of it, you’ve just imagined this world entirely made of NotGuns; the retrospective possibility and wholeness of that world…

All the life and beauty that might have filled an inverse-gun-space.

I wanted to use my newfound p5 object wizardry to invert guns into whatever the opposite of guns is: “Flower,” “book”…

~~~~
object classes (guns & notGuns)

Here is a gun.

Screen Shot 2017-10-05 at 12.26.04 AM.png

Here are a few examples of notGuns, some from the poem, some my own.

Screen Shot 2017-10-05 at 12.25.42 AM.png Screen Shot 2017-10-05 at 12.25.36 AM Screen Shot 2017-10-05 at 12.25.46 AM.png Screen Shot 2017-10-05 at 12.26.08 AM.png

I wrote functions to draw each type of notGun, giving each drawing a this.x and this.y.

Screen Shot 2017-10-05 at 12.31.29 AM.png

Some of the finnicky object shapes got divided into two functions.

~~~~
mouse detection

One major challenge I faced was getting a mouse detection to work. I experimented with calling “checkMouse()” in different parts of the code. It seemed straightforward, but it didn’t work when I put it in my main gun-drawing loop.

Screen Shot 2017-10-05 at 12.31.49 AM.png

My console log revealed uncooperative logic. I printed the distance amount and debugged.

Screen Shot 2017-10-05 at 12.40.26 AM.png

~~~~~
storing values per object
Another challenge was limiting behaviors to specific stored objects in the arrays. I realized that every time I clicked to make a random notGun, the other notGuns would re-draw based on the random number I passed through.

In other words, there could only be one type of object at once, and they would all randomly change on mousePressed().

Screen Shot 2017-10-05 at 12.26.20 AM.png

I realized that I had to put this in the constructor of the object, so that it doesn’t change with every for() loop through the array list.

~~~~
background change

My last wish was for something subtle and “ta-da”-feeling to happen after all guns become notGuns. I tried for a background change; I wanted it to fade more and more green as the majority of objects in the “guns” array returned “isGun() == false.”

I really struggled with this and putting this together with duct tape. Not the logic I wanted per se, but it works!

Screen Shot 2017-10-05 at 12.32.00 AM.png

Once all guns have been transformed into nonGuns, the background turns green and peaceful.

Screen Shot 2017-10-04 at 10.43.11 PM.png

~~~~
bonus round: POISSON?! 🐟

This part was kind of extra-extra credit, for myself. Originally I really wanted to position the sprites in a more regular (but still slightly random) grid. I tried to generate the guns in a 2D array, but ended up with three for() loops and something was whack with that.

J forwarded me something called Poisson Disk Sampling. It’s a really legit thing—there’s even a Very Serious Paper explaining how this works. This would have given me exactly the effect I wanted.

You can read watch Dan Shiffman talk about it here.

I tackled this twice, and failed both times to even get points to appear. Skill-wise, it’s a little out-of-my-league, for now. I would like to try again sometime though. 💪

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s