Black Hole Launcher
April 11, 2019
With the release of the first picture of a black hole this week – I decided a new project was in order. Gotta jump on the hype train, after all.
The only problem was I thought of this on Monday, and the picture was coming out Wednesday.
It was going to be a rush order.
I already had a fair bit of the tech in order, with my other General Relativistic projects, so it was doable. And indeed it is done — Black Hole Launcher.
I figured I’d boil it all down to just throwing rocks around a black hole. Simple to play around with for a few minutes, or longer if you got really into it. Eventually scope-creep came in (just a bit!) and I added light beams, and a variable mass for the black hole, etc. But it still stayed delightfully minimal. (A new thing I’m striving for in my projects).
So go ahead, give it a try. See if you can get a rock to orbit. Can you detect any precession? How about light beams, can they orbit?
And a quick, more general note on TestTubeGames. Right now, I’m exploring making smaller, quicker projects… so keep an eye on this space for new things. I’ve also built a new Discord server for folks that want to chat a bit more and get an inside scoop, which you can find here.
Thanks for your support!
-Andy
Hollow Planets
October 1, 2018
I got a great question from someone who’d been using GSim – let’s call them B.A.
To paraphrase: can you make a ‘hollow’ planet in the simulator, and test out how gravity would work inside it.
This ended up being a more interesting challenge than I realized, so I figure I’d share my response with all of you:
…
Ah, good question – I had to think about that one a bit. The short answer is, yes.
Right now, if you have a single star and put an asteroid inside it… it will get absorbed. *But* if you place a static star, then put a *planet* inside it (while the collisions are turned off), then it won’t get absorbed, and it will move around affected by the gravity of the star.
In that case, though, the star isn’t treated as hollow, but instead as having a constant density. So just like if you drilled a hole all the way through the earth, where you’d fall down, feeling the varying effects of gravity as you did.
I don’t think that’s what you mean by hollow object, though. To create something truly hollow, which would have all its mass on an outer shell, we’ll have to get more creative.
At first I tried making a ring of smaller stars, to act like the outer shell of an object. The code is here:
//Gravity fun at TestTubeGames
_settings(gravity: r^-2);
_addCircle(vt: 0, r: 150, num: 400, col: 1, t: 0, m: 10, lcol: 0, noGrav);

400 small static stars, arranged in a ring
If you try that, and throw in a few asteroids, you’ll notice that this doesn’t behave like you’d expect at all. Turns out, we made a flat ring, not a 3D shell, and they behave quite differently.
If you have the full version of the sim (the downloadable one), then you can set the simulation to be calculating in 2 dimensions, using the Physics menu, and that kind of helps — though introduces the issues that come along with calculating physics in different dimensions.
Well…
Then it struck me that a more straightforward(?) way to do this would be to create a star with negative mass… and put that *inside* the star with positive mass. (Negative mass is just a fun theoretical thing you can explore in the sim… but it’s very helpful here). If the two have the same density, then the negative mass and positive mass in any overlapping areas would cancel out to zero. With a slightly lower mass negative star overlapping a positive mass star, then, we can create a hollow object.
Here’s some code to try it out:
//Gravity fun at TestTubeGames
_settings(gravity: r^-2, x: 2.522413, y: 1.124918, zoom: 18.72843);
_add(m: 10000, col: 2, lcol: 3, pic: 0, noGrav, x: 0, y: 0);
_add(m: -9900, col: 16, lcol: 3, pic: 0, noGrav, x: 0, y: 0);

That thin yellow shell, if you can see it, is the surface of the hollow star.
Make sure collisions are off, then fling some asteroids* in there. You should be good to go.
*due to an issue with the way density is calculated, stick with asteroids for this test for now. Planet behavior inside a hollow object is a bit broken.
-Andy
Feel Bad Friday: DF37
May 26, 2017
It’s been a bit quiet around here – I’ve cut down on my blog posts and twitter activity a bit. *But* that doesn’t mean I won’t play a good ol’ Feel Bad Friday for you all!
NealCruco just shared DF37 in the forums with us, and this level does not disappoint. Take a watch below.
Thanks to NealCruco for sharing the level! To play this level (and more) you can check out the Level Creation Megathread in the forums.
-Andy
Gravity Simulator on Greenlight
December 8, 2016
After last week’s successful launch of The Electric Shocktopus (woo – it’s really out!), I’m wasting no time in getting my next game up there.
Gravity Simulator has always been a mainstay on this website – no matter what else I make, this project seems to dwarf the others in terms of traffic, eyeballs, engagement, and bug reports. So let’s see what happens when we get this one in front of Steam!
First thing’s first, we’ve got to get this thing through Steam Greenlight:
Greenlight, for the uninitiated, is a system where people vote for whether or not games should get up on Steam. Think Kickstarter, but where people just donate a vote instead of money. Which is a horrible analogy. (What next: “Twitter is like a cookbook where the recipes are people, and the ingredients are tweets.”)
Annnnyyyyway, keep your eye on this space for GSim hopefully following in Shocktopus’s tentaclesteps and making it way up on Steam soon.
-Andy
Shocktopus out on Steam!
December 1, 2016
Well there ya go, it happened! Shocktopus is up on Steam!
You can check out the Steam page here, or see the (at the moment) quiet community page for the game here. Ah.
If you’ve got the game already, through the Humble Widget, let me know and I can pass a Steam key along to you.
A Shocktopus History – Part 4
November 29, 2016
(The Electric Shocktopus is coming to Steam on November 30th (be there or be 1/r^2), so I figured it was a good time for a history lesson. To learn more, check out the first, second, or third parts of this series.)
It’s worth remembering that I didn’t start out to make a Steam game, or even a PC game.
Flashy Origins
When I started development on TES in 2013, my two platforms I’d built for were iOS (Agent Higgs, Slide Rule) and Flash (Velocity Raptor, Gravity Simulator).
After having just built an iPhone game, I wanted this next one to be web-based Flash game. Web games are great! They get a wider reach, hit more eyeballs, not to mention they are a better fit for a platformer – where you can use the arrow keys to run and jump around.
So that’s what I built. And by February 2014, the Flash game was done.
The way money works in Flash games is through advertising and sponsorships. You get a sponsor to pay you to have their name blasted on the front of your game, and then you get to give out the game for free. Everyone wins.
I went to a match-making site for developers and sponsors, but I couldn’t find a sponsorship I liked. I let the game sit on the auction site for months before deciding I needed to take another tack.
What went wrong with Flash? Well, for one thing, the industry has had the rug pulled out from under it. With the decline of Flash, there’s a lot less money to go around for Flash games. My expectations may also just have been wrong – in retrospect, I don’t think the game was polished enough at the time. And I think there’s something to be said for the niche nature of this game. It’s a fun platformer, yes, but a big part of the allure of the game is the physics accuracy. You are truly simulating electromagnetism in the game. And for a sponsor who’s just looking for games, the fact this one is educational and scientifically accurate might not be a selling point at all.
What to do?
With Velocity Raptor – I simply released the game online, for free. No sponsor. No advertising. I haven’t seen a penny off of it. Which was fine, it was a labor of love I did while I still had a day job. I just wanted to get my first game out there. I couldn’t do the same thing again with The Electric Shocktopus.
But it took nearly a year to figure out what to do next. In the meantime, I moved on to other projects.
Unity to the Rescue?
In November 2014, I announced that I was bringing Shocktopus to Unity. It was time to leave the Flash world behind, once and for all.
Unity is a cross-platform game development tool, which means you can build a game in it, and export it to iOS, or web, or as a downloadable PC/Mac/Linux game, etc. And it’s a whole lot more powerful than Flash. I had been learning to user Unity in late 2013, and had been building Bond Breaker in it, and enjoying the results. It was clear to me that Shocktopus’s future lay there, too.
The major reason, aside from ‘more power’? I could easily make a standalone, non-web version of the game for players to download. It could be bigger, badder, better, and something I could charge for, unlike a Flash game. And I could still make a web version – a lite or demo version – if I wanted.
It wasn’t easy to switch over to Unity – it basically required a rebuild of the game. But by February 2015, it was done. I released the game publicly through a Humble Widget on my site.
It was technically in Beta mode, since I knew there were minor tweaks I’d like to do, but there it was. I went back to working on other projects – and having a baby.
—
As a historical side-bar, I’ll note this is the time I started up the Feel Bad Friday videos, which have been going on (off and on) ever since.
—
Steam Greenlight
But selling it on my own site only gets me so far. I knew I had to try to get the game up on Steam. I prepared the materials, built a new trailer, and posted my Greenlight campaign in December 2015. It got a nice flurry of feedback, which was very useful. And then it quieted down. And then I waited. Again.
See a trend? The Electric Shocktopus has had a fair bit of downtime.
But then, in August 2016 (what’s 8 months between friends?), I heard back that Shocktopus had made it through Greenlight! Celebration ensued!
And also, questions. What do I do now? How do I release a game on Steam? What are trading cards – and how do I make them?!
Steam Release
Which brings us to present day. The game is getting released on Steam tomorrow, November 30, 2016, which Shocktopus gets released on Steam. It’s been a long journey, years in the making, and while I’d be foolish to state it’s over, it feels like a nice goal for the game to have reached.
Until, that is, I make a VR version of it.
(Thus concludes the history lesson! Here, have a cookie.)
A Shocktopus History – Part 3
November 22, 2016
(The Electric Shocktopus is coming to Steam on November 30th, so I figured it was a good time for a history lesson. To learn about the first inspirations for this electromagnetic game, see the first or second parts of this series.)
The Physics Strikes Back. (Wait… I guess… Revenge of the Griffiths?)
Right from the get-go, I knew I wanted The Electric Shocktopus to have both electricity and magnetism. And they both seemed so easy to simulate. That’s why I picked this branch of physics, after all. Let’s start with the second one first…
Magnetism
In that first, blocky prototype from January 2013, the game already included magnetic fields – though, unlike with electricity, I defined the fields directly (instead of calculating them). Certain tiles were field arrows pointing *into* your screen, and other tiles that were field arrows pointing *out of* your screen. Simple as that. As you moved through those fields, you’d feel a force from them, turning you the appropriate direction.
But by May 2013, I’d bumped that up a notch, by including current tiles. And as you recall from elementary school, playing around with electromagnets, electric currents can create magnetic fields – which I calculate using the Biot-Savart Law. It’s a bit mathy, but pretty straightforward to calculate.

If the magnetic fields above are *out* of the screen, and the fields below are *in*… which way are those negative charges moving?
Phew! Not bad – we can check magnetism off the list. And we all know that electricity is even simpler…
Electricity
No. No, no, no, no, no, no.
Simulating electric fields started off so easily. So easily. There were electric charges, and I calculated the fields using Coulomb’s Law. An easy equation, and simple to calculate, even with a bunch of charges on the screen.
But. I got greedy. I wanted to add conductors. And that’s where the wheels came off a bit.
Conductors are materials where electrons are free to flow, the charges can move and rearrange themselves. And they do so in complicated ways that depend on what’s around them. There’s no equation you can use to determine how they affect the electric field.
But there is an algorithm you can use. A set of steps ironically called the Relaxation Method. (Aaahhhh….) You break up the space into squares – which, nicely, my tile-based game already does – and then you guess the voltage for each spot. Pick zero, say. You then cycle through all the tiles, changing the voltage depending on what’s around them (charges, conductors, voltage, etc)… repeating this process for all the squares. This gets you a slightly better guess for the voltage. Then you repeat, cycling through all the squares, slowly but surely getting closer and closer to the true answer – converging on the array of voltages for all the squares in the space. And from that, you can get the electric field.
But there are problems with this. For one thing, you need a boundary – an edge all the way around the screen with a well-defined voltage. Which is something I didn’t have… and couldn’t easily add. For by adding in a ring of grounded conductors around the whole level, I’d be changing the result. It’d warp the very fields I was trying to calculate. And losing accuracy, you may know, is something I don’t take lightly! (I don’t have the space here to describe how I *solved* this problem, but if you’re interesting in getting into the weeds with the calculations, let me know, another blog post may be in my future.)
Another problem I had with the Relaxation Method was dimensions. I figured that, since my game was 2D – I could do the calculations in 2D. The screen is 30×24 tiles – so rounding up to allow for some off-screen border, that’s around 1000 tiles that I’d need to run through the calculations. Turns out, that’s fairly manageable, if you write the code well.
And after I added the conductors into the game in May 2013, I went along for some time, not realizing there was a problem. But there was a big one, that had to do with the third dimension – which it turns out I could not ignore. It took me until August 2013 to discover that one, and I summed up the problem and solution here. By having to do the calculations in 3D (with about 30x as many tiles, or cubes, to consider), it slowed the calculations down a lot. Gone was the hope to have the levels calculate the fields in real-time. Charges and conductors would have to be set in place.
By this point, I had the theme in place, the title and place, the physics in place – though hadn’t entirely solved that conductors problem, as it turns out. And I had a bunch of levels in the game. Surely I must almost be at a finished game. Right?
(Tune in next week for a look at the stumbling blocks TES hit coming to market…)
A Shocktopus History – Part 2
November 15, 2016
(The Electric Shocktopus is coming to Steam on November 30th, so I figured it was a good time for a history lesson. To learn about the first inspirations for this electromagnetic game, see the first part of this series.)
We left off last time with the first playable (by me, at least) prototype of The Electric Shocktopus, called, at the time, Magnetoad.
Puns and animals in my titles. Guess I can’t resist ’em.
Pinning Down the Theme
I knew Magnetoad wouldn’t last forever as a title. What other characters would you expect to hop around and hold on to walls? Perhaps, a Monkey?
That was the working title (and title screen) of the game for a month or so. I had sprites (a cute little running monkey), and bananas for the monkey to pick up. It was on its way. But, there were two problems. I wasn’t a big fan of the title. Where’s the pun? Who would recognize the game as being about electromagnetism? Bah. And second, as someone pointed out to me – not knowing I was working on this game yet – “Monkeys are so cliche. Every game is about monkeys!”
Uh-oh.
It was moments after that interaction that the title of the game came to me. In one glorious pun. It was time to throw out all that art, because I was working on The Electric Shocktopus!

He looks kinda like a hand with eyes.
And by March 2013, the game’s title and theme were set. Except for a few assets here and there that needed to be replaced… (unless octopuses like bananas, maybe?)
With some punching up, by May 2013, the game had a bunch of levels, new art, and was being playtested left and right.

Recognize this level? (May 2013)
The level pictured above made it into the final version of the game, in fact.

Recognize this level? (November 2016)
Do you notice the difference between those two images? Yes, yes, the second one looks a *whole*lot*better*, sure. But there’s another difference perhaps even more important, lurking in the physics.
(Tune in next time to discover how the physics simulation of the game has had to change over time…)
-Andy
A Shocktopus History – Part 1
November 8, 2016
With the upcoming Steam release of The Electric Shocktopus, it seems like a nice time to reflect on the long, winding history of this game. For before we could get to B,
we had to start at A:
The Prelude
In July 2012 – I released Agent Higgs, my first iOS game. It was a relatively quick dev cycle, just a few months, and I was looking for my next project. And I decided to leap in head-first and make the Quantum Mechanics game I always wanted to. I even posted a sneak peek! But… after prototyping it, I had to shelve the game. I was having too much trouble mixing the content into a fun, educational game. (It remains my white whale to this day.) Something that’s inherently chance-based doesn’t necessarily make for good puzzles, while at the same time quantum mechanics (with no precise positions or momenta, say) resists an easy visual representation. I decided I needed to save it for later.
I then turned to prototyping an evolution simulator, and you can play around with the prototype of that here. Stick creatures walking along, evolving and getting better with each generation. I wanted to turn it into a game, but again, had to shelve it after testing out several prototypes that didn’t click with me. A simulation was straightforward, but building a game around something like evolution, where the whole point is that it happens on its own, free of some outside influence… (and taking a long time to see changes, to boot)… didn’t make for an easy game.
So I was looking for a winner. Looking for a game concept I knew I could deliver on. And in January 2013, I had it! Electromagnetism!
It fit the bill. For starters, it was visual – you can draw the field lines right on the screen and show how individual particles move around. It was useful – lots of people learn about electricity, which means it wasn’t too esoteric of a topic. And most importantly, it made for fun gameplay. You, the character, are an electric charge, running around a world of fields. You get to repel and leap high into the air, fling yourself through fields, and curve around magnetic fields. A game of both thought and skill.
I present to you that game:
Ah. Well, then. The first version of the game, with possible trademark issues… and maybe, just maybe in need of some polish?
But the core parts of the game were there, if a bit blocky:
You, the character (a toad, clearly), on the left side. Black platforms to jump around. And the blue and green electric charges, creating those arrow-less field lines. The game worked, roughly. And even at this stage, I was having a blast playing around with it. Navigating an electric field was, dare I say, fun. A few weeks into development, and the heart of the game was there in early 2013. But it was far from finished…
(Tune in next week to learn what happened to Magnetoad)
-Andy
Shocktopus Steam Release – Nov 30th
November 3, 2016
Ah, The Electric Shocktopus. A game with a storied history here at TestTubeGames – not to mention one that’s given me some wonderful afternoons of frustration. And now, for its next journey – Shocktopus will be coming to Steam!
The release date – November 30th.
The game will have Steam-integrated achievements, Trading Cards, emoticons, you name it. I’m going all-in Steam (after I read up and figure out what all those things are…) Keep your eyes watching here, as I share the latest developments.
And if you missed it from a few days ago — here’s Shocktopus’s Halloween costume (hope he’s not letting his Greenlight success go to his head…)
-Andy