4 ms·
At one point, I saw a huge switch statement comparing the value of "col" to a list of twenty or thirty long hexadecimal numbers and returning objects like "Lock
by Estragon 15y ago
At one point, I saw a huge switch statement comparing the value of "col" to a list of twenty or thirty long hexadecimal numbers and returning objects like "LockedDoor". Is that kind of thing common in game development? It looks like a nightmare to maintain, but maybe that doesn't matter in a 48 hour competition?
Also, what is the engine that's rendering the maze for him? Is it a publically available library?
- ianl 15y agoIts how he loads level data from image file using RGB values
- shabble 15y agoI noticed a snippet fairly recently (last hour or so) using alpha values as an ID for switches and the things they're connected to (doors, etc). So technically, it's RGBA values :)
- Sodaware 15y agoI think that's the map loader. Rather than writing a special map format, it reads the map from a standard image, with each colour defining a different type of block. This makes it easier to make a map in a short space of time (great for contests), although as you said it makes it's not really maintainable in the long run.
- ForrestN 15y agoI don't know if this is part of the rules, but it appears he's using a minimum of existing libraries. For example, he hand drew the font earlier, and spent a great deal of time at the beginning getting the basic 3d system to work.
- DougBTX 15y agoHexadecimal numbers are a common way to represent colours, he can probably copy paste the colour numbers back and forth between code and an image editor. Using an existing image editor as a level editor must save time. It would get more complicated when you want to reference a specific thing on the map, eg particular behaviour for this locked door.
- leon_ 15y ago> Is that kind of thing common in game development? No. But I wouldn't see notch as a prototype game developer.
- davidsiems 15y agoThere's a pretty big difference between making something playable and making something scale-able. When you've got 48 hours to make something playable scaling gets thrown out the window.
- Impossible 15y agoThe huge switch statement is probably because that's the easiest thing to do with a simple 48 hour game. There is no point in wasting time writing clean maintainable systems with a lot of glue code when you're writing a simple game in 48 hours that you are the only developer of and will probably never look at again after the compo. Even in a larger commercial game it wouldn't be too hard to maintain that stuff (maybe clean it up by defining constants). I've written similar code for LD48 map loaders. There is a good chance that the "engine" that's rendering the maze for him is something he wrote during the competition. Its not too hard to write a simple maze renderer using OpenGL or even an oldschool raycast software renderer like wolfenstein's pretty quickly. All final LD48 entries must submit source as well, so once Notch is done you could take a look at what he's doing. Probably not anything you can easily turn into a library or reuse :).
- rch 15y agoOne thing I've noticed is that he tends to put a little extra energy into the quality of everything - say 20% more than the minimum. And I mean Everything - from consistent naming and semantics to the visual touches (like the color of the cloud over the moon). This fractional boost to the quality of so many components really adds up.
- rayval 15y agoAlso, the switch statement is easy to add incrementally and change. Every so often, he'll go back to it and add some new values and a couple of lines of code.
- barrkel 15y agoThe engine he is using, he wrote yesterday. It should be available after the game is finished.