Live data from Hacker News

Handmade Hero: C game from scratch

handmadehero.org

51–60 of 60 posts

Re: Handmade Hero: C game from scratch

#51

"If you want to make an apple pie from scratch, you must first create the universe." ~ Dr. Carl Sagan. Is he using an existing processor / memory / motherboard? Is he using an operating system? Is he using a compiler, editor, IDE? Is he using a standard library? Is he using any 3rd party libraries? Just because he isn't using an engine doesn't mean it's made "from scratch".

I've been playing around with bare bones assembly on Raspberry Pi. (Actually just following the baking pi tutorial.[1]) Maybe I should work up to a game from that level. That would be fun. I could go from Assembly to maybe a simple Forth interpreter (possibly the easiest language to implement from bare bones), and build tools and subroutines on top of that.

[1] http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/

Re: Handmade Hero: C game from scratch

#52
post #45

Lost interest when it became Windows-only. Writing C on Windows is a nightmare and the chance of portability plummets if you aren't targetting a POSIX system from the start.

Taken directly from the website: Will the game support multiple platforms? Yes! Windows will be the first platform, since it is currently the most common gaming platform, but the series will later cover (at least) Mac, Linux, and Raspberry Pi. Portability will be a major topic in the series, so all the code will be structured to demonstrate how to write code that is easy to port to new platforms.

I realize that he's promised eventual support for sensible systems, but it's _much_ easier to write code that is portable from day one than to port something later. Everyone who's not using Windows will miss out on the majority of the project, too, having to wait until it's decided that portability is a concern.

Re: Handmade Hero: C game from scratch

#53
post #12
post #11

[deleted]

> I though it was C, but in the video OP starts with C++? Very few people, even programmers, seem to know the difference. Some even claim to program in C/C++, which is about as meaningful as Java/Javascript or Java/C#. All those Foogols look alike anyway. ETA: I have no idea if we watched the same video. The commenting style in the first video on the top of the page was used in C decades before C++ existed, though, a…

> Very few people, even programmers, seem to know the difference. Some even claim to program in C/C++

At least in game development, you will usually use a sort of "C, with classes" approach. You use a C++ compiler and the class, and namespace keywords, but shun the rest of the C++ features like exceptions, virtual functions, and the STL for most of your code.

At that point, it's not really C and it's not really C++...

Re: Handmade Hero: C game from scratch

#54
post #39

Earlier quoted context omitted.

Good luck writing anything but C89 with visual studio. This project sounds amazing and I'm going to probably try it but Microsoft has abandoned C for a while now so visual studio is a complete turn off for this use case.

I'm reasonably certain that this has started to change in MSVC 2013. They have stated that they have improved the C99 library support and unless I'm mistaken they have finally permitted mixed code and declarations.

They have implemented the C99 parts required by C++14 standard, plus few extra parts required by some well known open source projects. It remains open if they will ever implement the rest in MSVC++.

However, VS 2015 will have clang integration.

Re: Handmade Hero: C game from scratch

#55

Earlier quoted context omitted.

He's going to write his own renderer, he's not using SDL or anything. He's going to be opening his own windows and drawing to them directly. The chance at portability is extremely slim, and on top of that those of us who use saner operating systems won't get to enjoy it for a long time.

SO the portability effort is - opening a window and drawing? How is that difficult. Writing his own renderer means its pretty easy to be portable. He'd have to make a special effort to include platform code in what's normally a pure-math engine, right?

I think you might be surprised how much code it takes to open a window and draw to it in C without using something like SDL.

Re: Handmade Hero: C game from scratch

#56
post #55

Earlier quoted context omitted.

SO the portability effort is - opening a window and drawing? How is that difficult. Writing his own renderer means its pretty easy to be portable. He'd have to make a special effort to include platform code in what's normally a pure-math engine, right?

I think you might be surprised how much code it takes to open a window and draw to it in C without using something like SDL.

It takes some boilerplate code that can be googled. Irrelevant how much; it takes little effort.

Re: Handmade Hero: C game from scratch

#57
post #55

Earlier quoted context omitted.

SO the portability effort is - opening a window and drawing? How is that difficult. Writing his own renderer means its pretty easy to be portable. He'd have to make a special effort to include platform code in what's normally a pure-math engine, right?

I think you might be surprised how much code it takes to open a window and draw to it in C without using something like SDL.

[deleted]

Re: Handmade Hero: C game from scratch

#58
post #4

The programmer behind this, Casey Muratori, has been helping out Jonathan Blow (Braid) on his new game, The Witness, and blogging about it. For the more experienced game devs out there, the series is a fantastic read: http://mollyrocket.com/casey/ (starting post 6). Many of the insights apply to software engineering in general, not just game dev.

The series is pretty good overall, but his endless tirades against OOP (many of which are specious) drained much of my enthusiasm for his blog. Regardless, it's still good reading and this new game project is a great idea.

Re: Handmade Hero: C game from scratch

#59
post #6

Earlier quoted context omitted.

Lots of gamers can tell when a game is a "Unity" game for example (due to lots of built in shaders and effects). I'd agree using an engine is a wise choice but make the decision very carefully. It can save a ton of time, but you still have to put in a lot of work to not let the engine dictate too much about the look and feel of the game.

The point I was trying to make is that developing a game from scratch is a labor-intensive way to make a game. You have to consider file paths, resource management, texture packing, file formats, parsers, and hardware. You have to think about abstract things like event processing, concurrency, simulation, reacting to inputs, etc. A mountain of work goes into lighting up a pixel on the screen. Doing it from scratch is…

Absolutely right. I've gone through the dark times of wondering how to get the linker to stop exploding on me. And when speaking about developing a game engine, it's not just the work required to create feature X, it's the entire ecosystem. Making a sound play or wiring up PhysX is not difficult. Making fifty modules work correctly with each other is the foundation and is not easy or quick. Then there are editor tools, with modern engines providing a full editor suite that would take a team years to make. In the case of Unity, you get correct play-in-editor as well as truly live editing, which allow for incredibly rapid iteration (part of the true secret of efficient game development is being able to go from your shower "ah ha!" moment to a working prototype as quickly as possible). Then there's their asset store with a proliferation of not only art and sound but valuable scripts and entire systems or engines. And while I'm making my game, the middleware company is making my tech better by fixing bugs and adding features, with nearly-push-button support for over a dozen modern hardware platforms to boot.

I can see lots of reasons to develop a game engine from scratch, but they become less compelling every year.

Re: Handmade Hero: C game from scratch

#60

If he knows he will be porting the game, why does he not abstract away the OS layer and perhaps even the graphics library? Then implement it behind some interface with for example SDL2 and OpenGL depending on platform. Would not that save lots of time and ensure it works cross-platform from the start? To me, it just seems that you re-invent the wheel by not doing this.

He will abstract it. His style is to implement first, then figure out the abstraction, not the other way around. Plus he's done this before and probably has an abstraction in mind which will make that style work even better.
Post reply on HN