Spent a few hours reading up on OpenGL this winter holliday. Haven’t messed around with it for 11 years.
What’s was most interesting was optimizing compile times. Using VIM and a bat-script for compilation made it pretty much instant.
Well. I realized that even if it’s nice to have basic knowledge, I find it boring. And also realized that OpenGL is considered more or less ‘deprecated’ now as a cross platform graphics api (since Mac no longer supports it). I wasn’t aware of that as a more or less established status before. If you are interested in graphics programming, then you should look into webgpu instead, it seems.
But this will be it for now. Time to go back to my beloved AsciiBrain project again.
Haven’t posted in a while, so let’s do something about it! Big time!
Here’s a summary of all that’s happened to asciibrain (that I haven’t yet posted about) during at least the past 1,5 years. Quite a lot, this is still very much a live passion project for me.
Migrated the project to CMake and tried compiling it on my ancient linux netbook. Had to shrink the window, other than that it worked fine!
Here you’ll also see a glimpse of my ascii smoke and text layout code…
White laptop to the left is running Lubuntu and the laptop to the right is running Windows 11.
I love particles in ascii, and started prototyping on a first-look on a fire/explosion type of effect. So far it’s hard coded to explore the kind of style I’m after and see what the requirements are… Here’s the process it went through!
First try. Yellow to black. Delay per cell based on distance from center with a small offset to not have it ’too symmetric'.
Second try. Red to yellow to black.
Third try. Kick up the offset and make it longer.
Fourth try. LoL, explosion should start with yellow then fade to red (doh). Added in smoke and lowered that offset again.
Fifth try. Minor changes and tweaking. I really liked this one!
Here it is together with a fire-trail and damage implementation, how it currently looks in the game.
In order to proceed with all features, I figured I need to know how my UI should look and behave. Sat down and tried to do a mockup. Damn design is hard and time consuming (I just want to code). Well, I’m happy enough with how this turned out.
Although it is a bit too much Demeo rip-off right now. Don’t worry too much about it, I’ll move away from that soon enough =)
I needed to refactor my rendering pipeline for improved flexibility (adding a speed improvement in the process). But sometthing went a little wrong resulting in the following images…
This might be one of the coolest bug of my entire career!!
Tiny update this time.
TICK is the number of milliseconds for main update loop
BUFF is when we process our graphics buffer and create the SDL commands to draw it
REND is when SDL actually renders to screen (it’s so high because of VSYNC)
The first value is actually quite high right now, because I’m very wasteful and calculate shadowcasting and A* every frame even when nothing changes.
Haven’t written about this in a while, but there is a ton of new stuff going on…
(oh, and those red dudes are not ascii… did some experimentation but did not really like it)
…more to come, I promise =D
Been working a couple of evenings on this little Super Mario Run-clone for my kids to play with. It’s obviously quite early in development, but they love it anyway!
Godot has a pretty decent physics system, but as usual I prefer to do the physics myself. Starting to feel pretty good.
Been a while since I worked on this one. But I have some very intriguing ideas, so I wanted to pick this up again. New features since last time:
More to come…
Been talking with my kids for quite some time that it would be fun to make a game together, Now Edda has started actively talking about it, so during the holidays I went ahead and made one.
Funny thing is that Sigrid is the one who made the graphics so far. It’s placeholder though, as she wants her graphics for another game (not supposed to be a jumping crab!!!)
Starting to refactor systems. Split out the enemy wave manager into a ship builder class (build and configure enemies based on type), spawn position solver, and a waveManager (that decides WHEN to spawn WHAT ship). Turns out I need to put more effort in the last part, while the two former worked pretty well.
Did a new enemy type as well. A re-make of the shotgun turret from pewpew5 (that never made it into the game).
It is supposed to be a bullet hell after all =D
Finally got some time for this old prototype again!
Added one more enemy (you can glimpse him in the gif), strolling around and planting mines to hinder your movement!
Turns out that having enemy bullets (and mines) be solid color really messed up your sense of depth. And that is super important in this game! So I changed it to simple lit. Sense of depth is improved, but it looks really ugly now! I need an artist to fix this… =(
There is a known problem that occurs when you try to have a large number of objects moving towards the same exact point… they will meld together and in the end seem like a single object.
In Ripple I avoided this problem by making sure we did not have enough flying/following enemies on screen at the same time. However, I have a case now where I want a ton of theese… a swarm of enemies.
Funny thing is that the math for moving an object towards a point is dead simple. Does some kind of scatter function have to be incredible complex? Or can we do it in an almost as simple way? I had a theory I wanted to try, here’s the psuedo code.
for each enemy in enemies
if enemy == me: continue
if distance D is less than minAllowedRadius R
move me away from enemy in opposite direction by distance D
Looks glitchy. Figured out pretty quick that we push by distance D, which means that if minAllowedRadius is 25 and you touch the outer rim of it, distance will be 24, and you will be pushed 24 units instead of 1 unit. And the opposite, if your are 1 unit away you will only be pushed one unit. We obviously need to push it 1 unit in the first example and 24 units in the second.
Whoa! That looks amazing! I did not expect it to be that fluid!!!
Here is the final psuedo code
foreach enemy in enemies
velocity = (playerPos - enemy.pos).normalize * speed
lookAt = velocity.angle() // update lookAngle before calculating scatter
pushback = new Vector2(0,0)
var newPos = enemy.pos + velocity
foreach checkScatter in enemies
if (checkScatter = enemy) continue
otherTowardsMe = newPos - checkScatter.pos
if (otherTowardsMe.squaredMagnitude < minAllowedRadiusSquared)
// Too close to someone!
otherTowardsMeMagnitude = otherTowardsMe.magnitude
// need to adjust amountToPushBack, or we get gif number 2
amountToPushBack = minAllowedRadius - otherTowardsMeMagnitude
pushback += otherTowardsMe / otherTowardsMeMagnitue * amountToPushBack
enemy.pos = newPos + pushback
As you might (or might not) notice is that I use the squaredDistance and squaredMagnitude in the first check, where we see if we are in contact. This is to avoid using squared root in the inner loop (that would be a lot of square root calculations).
However, if we do have a hit we calculate the actual magnitude, so we can adjust the amount of pushback. I store it in a variable as I need it twice.
There might be even more optimized ways to do this, but doing a sqrt for N^(N-1) seemed a bit too expensive.
Oh… and this was also my first attempt at using Godot engine. Is was actually really pleasant! I might actually start using it instead of Unity for experiments and personal prototypes… at least for a while, as a test!