A Programmer Walks Into a Dance Party, Then…

It could be a bad joke or it could be bad code.

“Programming isn’t about what you know; it’s about what you can figure out.”

— Chris Pine

At this point in the early, early stages of my journey to learn the basics of programming, quotes like that one from the author of Learn to Program give me hope that I’m on the right track. When I learned simple markup languages some years ago, like HTML, I relied heavily on raw memorization a lot. It makes grappling with the conceptual areas of programming a lot trickier to wrap my mind around.

Regardless, I shall learn to wrap my text properly and wrap my mind around crazy ideas like classes and functions. Though I’m still sorting out the precise ways certain lines impact others, I’ve managed to make things move. It is a bit exciting for a simple writer like me to see something I created jumping into motion — my usual words are quite lazy and don’t want to get off of the sofa, nevermind start dancing.

This week, I made a little dance party solely out of code.

Animation by Author

Here’s a .gif rendering of this wild little project. My full code is living in the basement of the p5.js website. If you’d like to see the horrors of how I Frankensteined this together, look no further. As a part of my Creative Coding course at NYU Tandon, I took the “dance party” prompt very literally and got some little stick people jirating like crazy.

This was my first proper taste of object-oriented programming. While this is simple and only features one class, I am amazed at the flexibility that object orientation affords programmers. In every other creative pursuit I’ve ever done, whether it be writing or simple illustrations, creating multiple versions of something takes a fair bit of work.

I’ve never been able to dynamically change what I created with just a few taps on a keyboard.

It’s remarkable how one can go from an empty dance floor…

Screenshot by Author

To a total mosh pit just be defining the number let numDancers =175;.

Screenshot by Author

Truth be told, I still feel like I’m so new to creating variables, functions, and classes that this little creation is a true Frankenstein. It’s a conglomeration of coding tutorials, modified stick figures, and spotlights borrowed from programmers far more skilled than I.

While I had to modify everything to make the different elements play nice together and do what I envisioned, this still felt more derivative than I anticipated it to. I tip my hat to every valiant code sacrifice that was made to let me piecemeal this together.

At this point, I’m still approaching every idea as a puzzle I need to find the pieces for.

Animation by Author

In the coming weeks, I want to buckle down and practice more. I want to experiment a little more with coding for the sake of coding. I hope that if I explore some of these essential functions and abilities of p5.js a little more deeply, I’ll be able to properly grasp the way everything works and interacts with each other.

To summarize my process here, I first found a stagnant stick figure. I changed the way the body was built to use xpos and ypos and move the arm angles to random increments to make it look like they’re dancing. I changed it to a class to make it a manipulatable object. The original stick person code used radians, which just didn’t work well for the type of animation I was going for.

Next, I experimented with getting the background to change colors as if these little stick folks were in a club with a wild light show happening. There certainly isn’t much social distancing going on in this code, but I was able to use an if statement and a counter to slow down how rapidly the background colored changed. At first, it was quite seizure-inducing.

I’m learning largely through tinkering.

My not very foolproof process of “let’s poke the numbers and see what happens until I figure out what the numbers mean” is still underway. I’m getting a better sense of what does what each time I delve into code and try manipulating it, but it is a slow learning process.

As I mentioned above, I pulled code for the spotlights from another existing project I found out on the expanse of the internet. To make this a little more my own, I edited the attributes of the lights, the size, the positioning, and I added a second one. After all, what’s a dance party with only one spotlight?

I’m hopeful that with more practice, I won’t need to take such a puzzle piece approach. Perhaps it’s just the writer in me, but I want to reach a point where I can develop more elements from scratch.

Moving forward, I want to maintain a learner’s mind.

“Do not fear failure but rather fear not trying.”
― Roy T. Bennett

Though this isn’t technically a quote about programming, this is the mindset I’m using to approach learning all these different concepts. I’m guilty of being a perfectionist at times, but I’m also logical enough to know that anything creative is never truly complete.

Writer and poet from Neptune. Instructional designer in NYC. Grad student at @NYUTandon studying Integrated Digital Media.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store