The World Wide Web is big and scary, and sometimes you need the recommendations of others to guide your way to webpages worth watching. Here, therefore, are some cool links to cool things that you might want to, cool-ly, inspect.
Sandi Metz - Nothing is Something (keynote speech at RailsConf 2015) Should be interesting and educational for all the programmers out there. Sandi talks about how to tackle object oriented programming problems, and the Null Object pattern, the idea of the Active Nothing. It’s Ruby-focused, but practical Object-Oriented Design lessons are applicable across most languages. Her speech from the previous year is more about ‘life’ than programming, but it is very, very worth a watch.
Woodland Secrets Ep. 54: Katherine Cross – This was a great episode, with Merritt Kopas and her guest, Katherine Cross, holding a long, in-depth conversation on the subjects of sociology, work, gamification, and online discourse. Katherine’s writing on society, culture and games is well worth exploring. Go and check it out.
You may have heard of 99% Invisible, the excellent design podcast. Episode 212: Turf Wars of East New York, contains some excellent historical insight into the widespread issue facing American cities (and other cities around the world) of gentrification, 20th-century shifts in inner city residential demographics, and how inextricably knotted up it all is with US racist and ethnic tension.
Landlords and real estate investors saw opportunity in the desperation of immigrant populations. They would come to hone two profit-driven tactics that would subsequently shape neighborhoods around the country: fear-induced white flight and predatory lending.
I tend to complain about the Civilization games whenever they come up. I really want to love them (and other 4X games), but every installment has some elements that just feel wrong, making the overall experience long, boring, frustrating and unfulfilling.
Civilization VI was just revealed by Firaxis and pegged for an October release, and the way the designers say they’re shaking up the formula has really piqued my interest: every change mentioned in Rock, Paper, Shotgun’s details splurge and PC Gamer’s addresses a problem I have with Civilization V (and, by extension, the others).
I’m not getting hyped, or anything sticky like that, but I think about strategy games a lot - particularly the elusive and mysterious creature that is the 4X-I-Find-Enjoyable - so I am getting intrigued.
The coursework for Applied Game Technologies1 lets you make more or less what you want, but what you make has to be a game and use either red-blue anaglyph stereoscopic 3D on PC or augmented reality on the PlayStation Vita. I chose the second option.
I’ve been working on an old-fashioned raycast-rendering system that uses Box2D’s b2World::RayCast method to draw the world instead of casting rays against a grid the way Wolfenstein 3D does it.
Where I left off I’d just managed to get a limited generic system up and running. Every fixture (shape) in the b2World was rendered as a wall. Nothing could be partially transparent, nothing could appear behind anything else, there was no support for differently-coloured walls, and there were no sprites. In the intervening time I’ve enabled these capabilities.
In this case, ‘raycasting’ refers to an old-school rendering algorithm used in early ‘pseudo-3D’ games such as Wolfenstein 3D. This tutorial provides a good overview of how it’s normally implemented in its simplest form: for each column of pixels on the screen. The world is represented as a 2D grid of integers in which the number 0 is empty space and anything else is a wall. Each ray iterates over the grid until it intersects a wall, whereupon you use the distance from the camera to the wall to draw a vertical line of pixels on the screen. Simple! Then you can add more on top, like texturing the walls and floor, ‘sprites’ which aren’t on the grid and always face the camera, etc.
(Reminder that I tend to add mouse-over text to my images.)
What if you want the freedom to have walls that aren’t grid-aligned, though? It’s easy enough to write functions which test for intersection between line segments (rays) and arbitrary polygons and circles, but when the number of objects in your world grows large, unless you want to raycast against every object in your scene hundreds of times each frame, you’re going to want to sort those objects into some kind of spatial partition. This will take a fair bit of your time, energy and sanity.
The good news is that Box2D already sorts every fixture (shape) in its world into a spatial partition. This is great because it saves us the effort of doing so, and gives us access to all the other cool stuff Box2D does. The b2World::RayCast function is fast and easy to use - so why not try using it to render the Box2D world from a first-person perspective?
Download the demo program (Windows only) from here. Controls are in the readme that should be included in the .zip or on the readme on the front page of the GitHub repo where you can view all the source code.
Next I’m going to add sprites. I think I’ve figured out how to do it in my head and just need to put my thoughts into code. The nice thing is that I should be able to render sprites in the same pass as I render the walls – in my old grid-based raycaster the walls are rendered and the sprites are handled afterwards. On the other hand, to handle partially-transparent sprites (and walls) I’ll have to continue rays beyond their first intersection-point, which complicates things somewhat.
Texturing the walls is going to take more time to solve. On a grid it’s easy to figure out how far along the wall the ray intersection-point is, here not so much. I’m going to be doing a lot of head-scratching, and I fear the solution I come up with in the end will be sub-optimal. Won’t know until I try, though!
The images below demonstrate the difference made by calculating the ray direction and intersection-point distance in different ways. If I were going to explain this here I’d want to use some diagrams. Maybe later, huh?
Further reading:
The 108th issue of Computer Gaming World from July 1993, featuring this quote about the 7th Game Developer’s Conference, is pretty cool to read: