top | item 17828187

Craft: A simple Minecraft clone written in C using OpenGL shaders

578 points| sbjs | 7 years ago |github.com | reply

154 comments

order
[+] powerbook5300CS|7 years ago|reply
Fogleman has some really cool side projects in a variety of areas written in a variety of languages... and I noticed he’s got two kids! As a new father, how is this possible? Really boring/easy day job?

Having a daughter is an amazing experience that is rewarding in its own right but something that really scares me about fatherhood is not being able to do any deep work for the rest of my life.

Doing deep work is another part of living I really enjoy and I’m somewhat petrified that I’ll never experience it again. Maybe it doesn’t matter.

[+] fogleman|7 years ago|reply
Fogleman here. Funny to see an old project in the #1 spot (again?).

I hesitate to comment about this being productive while having kids thing, but some people seem to be implying that I must never spend time with my kids. It's far from the truth. A week ago my son (age 5) and I went camping in the backyard. Coincidentally, he and I have just recently started playing the real Minecraft together on our own private server - every evening lately. (I had never actually really gotten into the real Minecraft before, believe it or not.) We've been playing lots of Thinkfun games like Rush Hour and Shape by Shape. I actually still lay with my son while he falls asleep every night. My daughter (age 7) and I walked to the playground and played for a while there yesterday. We go out and check my vegetable garden daily, and my daughter likes to play "baseball" (plastic bat and ball) in the backyard with me. I work from home currently which is nice because there's no commute and I can see my kids a lot. We have "dance parties" in my home office where there's lots of open floor space. I could go on of course.

I fully understand the sentiment that time is short when it comes to spending time with your kids before they are grown.

There are plenty of folks without kids who aren't super productive too - so the whole thing seems a false dichotomy to me.

Frankly I don't even feel like I work that hard. Maybe "hard" is the wrong word. A lot of people are constantly busy and have no free time. Yet they don't seem so productive? I'm the opposite of that, somehow.

I know I'm under no obligation to defend myself - but there you go.

[+] treespace8|7 years ago|reply
Since my daughter was born, I no longer have free time for meaningful side projects.

She is almost 9, and I measure my free time in minutes.

What I do have is: - A great relationship with my daughter - A great relationship with my wife - A daughter who is kicking ass in every area of life, and is having a fun, enjoyable childhood. (Unlike my own) - I have not missed out on a thing. I have no second thoughts on my parenting. - I sleep great - Stress free home. - Homecooked meals everyday. (We both cook)

There should be tons of time in the future for me to go back to side projects. But the time I have to raise a family is limited.

[+] nomel|7 years ago|reply
> Maybe it doesn’t matter.

Having a few people pass on me the last few years, and realizing I missed my first kids early childhood from poor work/life management at my dream job, I don't think it matters.

You'll never eventually regret spending time with someone you love, but you may regret that writing <some program> made you miss out on that time.

Maybe I'm getting old, or just burning out, but my kids are quite literally disappearing in front of my eyes, slowly turning into young adults. Trading them for some cash and some now obsolete product/device seems less and less "worth it".

I'm not sure where that balance between myself, my kids, and money is, but it seems like a "pick two" type scenario, but in this case you have one short chance before the kids are no longer kids.

[+] jpfed|7 years ago|reply
She's not going to need quite as much attention when she's in elementary school, and much less attention when she's in high school.

When she is in high school, starting to pull away from you, I hope you can look back without regret about how you chose to spend your time.

In software development, we talk about context switching in humans like a cache that might take 30 minutes to warm up. But just as a computer has many levels of persistent state, so do humans. It's not a perfect analogy. And this isn't going to be what you want to hear. But speaking as a fellow dad, this is what I did and what I wish I'd done sooner.

Take your todos- your plans about side projects, open source contributions, everything to do with coding other than your day job- and evict it from your mental cache, put it in a swap file, archive it to tape. Keeping that stuff fresh in mind is wasting space that could be spent on what is needed now.

I have a stepdaughter, a son, and a daughter. I wish I could have been more present for my stepdaughter. I wish I could go back in time and hold my then-toddler son. At least I'm here for my daughter.

Years from now, all my kids will be grown up enough that I can work on side projects. As much as it would be cool to write a game or a programming language or whatever, I don't want that time to come too soon.

[+] gameswithgo|7 years ago|reply
It is really hard to do deep work with kids, unless you have a spouse who is willing to do 100% of parenting and house upkeep, or can afford a nanny
[+] originalbryan2|7 years ago|reply
I've got twin 3 year olds. Took a while to accept the fact that I have no time to do "things" anymore. And like another commenter, I measure free time in minutes. First time I got 30 minutes to myself (9 months into parenthood) I nearly wept.

I'm at a point now that I'm happy to spend time with them and, after numerous false starts (that were crushed by repeat month long illness moving from person to person, random sleep problems/night terrors lasting weeks, etc) have abandoned all outside aspirations. And I'm ok with that.

I do suspect things will lighten up in time. Perhaps I'll entertain side projects one day in the future.

[+] beaconstudios|7 years ago|reply
my money's on him spending an hour or two every morning or evening, when the family are still in bed. I've learned recently how much more productive you can be by spending small time consistently compared to large time inconsistently (ie starting new projects full of excitement).
[+] Rattled|7 years ago|reply
I don't know how old your kids are, but if they're younger than 3 it gets easier. Never is extreme, you will surely have time for side projects at some point, but if you really care about it make it a goal to be part of your working day. That could be by expanding the scope of your current role, or cutting your working week to work for yourself a few days a month.
[+] TaylorAlexander|7 years ago|reply
I am one of those people who is very productive with side projects. I operate a YouTube channel and website and I design 3D printed robots which I am building all the time.

It does take a lot of energy. People often are surprised I can do it, and say “ah you must not have kids”. Which is true, I don’t have kids.

And I know that having kids means devoting a significant amount of your attention to them.

Still, I feel like I will continue to crank out new projects even once I have kids. I’m sure my time spent on those projects would drop, but I doubt I’d stop entirely.

I have friends who have no kids who don’t work on projects like I do. I think some people are just wired to churn and others aren’t. I have a friend who struggles to get much done on weekends, while I am kind of non stop moving. I think it’s a personality thing.

[+] legohead|7 years ago|reply
I have 2 kids. They go to bed at 8:30. I stay up until 11, which leaves plenty of time to do my own stuff. I am usually too tired though and watch movies. Plus I still need to pay attention to the spouse :) But occasionally I work on my side projects/ideas.
[+] dilap|7 years ago|reply
he works at formlabs, which doesn't look easy and DEFNLY doesn't look boring!

he also does carpentery and neat plotter art.

pretty impressive guy. very inspirational!

[+] daeken|7 years ago|reply
I have an 8 month old and I'm more productive now than I have been in ages, both in terms of side projects and day job.

My wife and I both stay at home and split baby duties roughly 50/50; we alternate nights, then split the day pretty evenly. We also each get one day a week that is free of baby duties, so we can relax.

I usually tend to use her naps as an opportunity to work on side projects, so I get a good solid 2 hours or so every day, plus any time I take after she goes to sleep for the night. These bounded, contiguous blocks of time focus me in a way that I find very helpful for productivity. I'm getting a ton done, spending a lot of time with my kid, and loving it all.

[+] guildan|7 years ago|reply
What I find is really helping is if one of the parent is at home. You can do so more things that way during family time and personnel time. Oh sure you say goodbye to restaurant, travels and other "expansive" things, but it's really crazy how I prefer that lifestyle.

It helps that I commute too so I have some free time for leisure, so back at home I don't need/want to pass as much time on "wasteful" activities.

[+] souprock|7 years ago|reply
Well, he only has two. I have 1.1 decachildren. Most blokes don't have more than ten kids, but if we need that extra push over the cliff...Eleven. One louder.

I managed to be an open source contributer with kids. It slowed down shortly after the 4th and 5th kids (twins) were born, and it mostly stopped when I got to about 7 kids. I maintained Linux's procps package, added Tux Paint features, helped with the OLPC XO, did some Linux kernel changes, and other minor stuff.

I wouldn't say I have a "Really boring/easy day job", but it does offer flexible hours and no expectation of going beyond 40 hours per week, and my commute is only 3 minutes by car or 15 to 20 by foot. (the job post: https://news.ycombinator.com/item?id=17442484)

It helps to be in a place with low cost of living, so only one income is required. That gains back some time.

[+] t0mislav|7 years ago|reply
Times when you will have plenty of time will come back fast. :( Kids will start to play more alone or with friends, less with parents, soon they will also grew up, and you will remember the days when you were everything for them.
[+] watwut|7 years ago|reply
I have found that long hours at work or work that makes you very tired (or is very engaging) are bigger obstacles then kids. If the day job is easy, then you can have own projects in the evening. If the day job is tiring, then you cant.

Kids require your time, but if you share duties with spouse, that alone does not make out-of-work projects impossible.

[+] z3t4|7 years ago|reply
Programming can be very relaxing, you forget about the real world for an hour or two. If you have children you can take turns. And let the kids get used to fall asleep alone, it will feel like torture at first, but when they get used to it you will get an extra hour of free time every evening.
[+] k__|7 years ago|reply
One of my professors would work two jobs, have two kids and do a major amount of side-projects at university.

He told me his secret was that he only needs to sleep 5h a night.

[+] Karrot_Kream|7 years ago|reply
For folks who want something a bit less pedagogic and more fun to play as a game, I highly recommend Minetest [1] which gives you a programmable layer on top of the base Minetest engine to make Minecraft-like game modes.

[1]: http://minetest.net/

[+] tills13|7 years ago|reply
Reminds me of spending countless hours messing around in ComputerCraft. So much fun.
[+] sytelus|7 years ago|reply
My 5 year old kid is addicted to minecraft and there is no way to prevent violence (you can always keep killing animals even in Creative + Peaceful mode). The problem is that 5 year old have little context on consequence and they really get intrigues in exercising new power they have. I'd like a pre-schooler mode which actively discourages any violence. May be if you try to kill something, an alien would descend and take away all your assets. So only thing you can ever do in Minecraft is just build something :). If someone can add this feature, it would be AWESOME!
[+] nitwit005|7 years ago|reply
If that sort of thing bothers you, I'm not sure it's possible to make a version that totally avoids it. Even breaking blocks is "enjoying destruction". I certainly enjoyed smashing all the bricks in Mario when I was little.

That said, I suspect most 5 year olds can figure out that virtual cube pigs aren't real, and that there's no consequence to punching them with virtual cube arms.

[+] BillBohan|7 years ago|reply
You might want to try the free game Minetest [1]. It is very similar to Minecraft but the basic version, minetest_game, has no animals. You can add mods that give you animals if you want them but they are not necessary. There are hundreds of open source mods to choose from or you can write your own mods in Lua. I learned Lua by examining the mods that come with the game and changing them. You can play in a mode where you can't take any damage. Multiplayer games can enable or disable PvP.

[1] http://minetest.net

[+] dietr1ch|7 years ago|reply
On Zelda you have little incentive to attack the Cuccos (chicken).
[+] srcmap|7 years ago|reply
This is very cool. I got it build/running in < 3 minutes in Linux.

My boy love Minecraft. I like to use this as base to teach him more about programming.

Any suggestion on small projects that can be addon / mod use this code as base.

I am thinking a series of coding exercises that can be hack/add on to this:

Add a command/mod to:

1) Draw line, Square, Triangle. 2) Draw Circle, Ellipse, Cone, Cylinder 3) Build Car, Airplane 4) Build Space Ship 5) Putting picture of his own face on the block.

... Any other suggestions?

Each small projects take about 1-2 hours build on skill sets that learn before. It should be simple and fun to do with goals of encourage kids to learn programming.

My boy finished all the CS classes in Khan Academy and seems to enjoys them.

If anyone else has strong interested in this, I will see if I (we - group of us) can develop this as a new Khan Academy CS class and contribute it to KA.

[+] _bxg1|7 years ago|reply
Very cool. The beauty and draw of Minecraft have always come from the way it emerges from such simple elements. Reimplementing it in any language would be quite fun, I'd think. It's almost the new Doom.
[+] ilaksh|7 years ago|reply
As someone who built a Minecraft-like project (but I was careful not to call it a Minecraft clone because it was missing many core features) in JavaScript several years ago and a fan of actual Minecraft, I feel I need to say something.

This is not a Minecraft clone. 99% of the projects out there that claim to be Minecraft clones are not close enough to be called clones either.

The real draw of Minecraft comes from a number of core features, most importantly the crafting and the survival needs that motivate the crafting and building. Minecraft would not have become a hit if it was just a creative sandbox alone. This project has neither of those aspects of the game. Another thing missing is the diversity of biomes. And another thing-- all of the underground features like caves and mines are missing.

So it doesn't have Mine or Craft, don't call it a clone. You wouldn't call something an IBM clone if it was missing core features of that computer.

I think people do the part with just the blocks and rudimentary generation and call it a clone, it's almost like they are giving themselves credit for recreating Minecraft when they haven't even implemented 1/3 of the features, and they didn't even recognize the most important ones.

[+] sbjs|7 years ago|reply
I don't understand how 3d games are written or know what shaders are, so this is complete magic to me, and I'm surprised it's only 5k lines of C code!
[+] bena|7 years ago|reply
Shaders are basically transformations performed by the graphics card. Or sometimes not. It gets real vague at times because like a lot of things there are no hard lines.

You take a point and figure out if it needs to be colored differently based on certain criteria. Like if it was in shadow, or if it's being hit by a bright light, or you just want a sepia tone across everything. You can even shift everything. Take the screen and distort it according to some kind of function. Like make it all wavy.

3d games are no more or less conceptually different than 2d games in a lot of regards. There are more things to track and be aware of, but you're effectively doing a lot of the same things.

If you've ever messed around with making 2d games, you can even begin simple experimentation by just making another layer of depth. Like LittleBigPlanet, it's ostensibly a 2D game presented with 3D graphics. But it allows you to shift between 3 layers to give you some depth.

[+] diamondo25|7 years ago|reply
Drawing cubes is basically one of the first things you do when starting with 3d rendering. Shaders are scripts that the GPU uses for translating your input (a cube in 3d data and your 'camera' and some more vectors) to viewport/screen coordinates. You can do a lot with it [0].

The classic OpenGL 1 framework had no shaders and a static pipeline. Its straightforward in doing things but reduces the amount of fancy things you can do. Maybe check out a guide like here[1].

[0] http://www.adriancourreges.com/blog/2016/09/09/doom-2016-gra...

[1] http://www.glprogramming.com/red/

[+] sergiotapia|7 years ago|reply
Interesting choice of sqlite, what's the story on concurrent updates these days? Last I tried to use it for a project was in 2009 and even at a measly 3 concurrent people, sqlite had trouble with data lock errors.

How does sqlite mesh well with Craft multiplayer?

[+] pwaai|7 years ago|reply
is there a realistic mining/digging simulator? I love minecraft but sometimes I wish I was digging a real mine with buttresses
[+] partycoder|7 years ago|reply
This has a much brighter future than Minecraft on Linux or Mac (completely neglected after Microsoft acquisition).
[+] everyone|7 years ago|reply
I'm assuming this runs about a jillion times faster than actual Minecraft? They should re-write minecraft like this; its performance has always been so awful.
[+] a_r_8|7 years ago|reply
I fondly remember looking through this a few years ago as it was one of the first posts I found at the top of HN
[+] enriquto|7 years ago|reply
The screenshot is an infuriatingly aliased image, wouldn't it be easy to fix?
[+] simplify|7 years ago|reply
I am in awe at how the executable is less than 1mb to download.
[+] nautilus12|7 years ago|reply
Can microsoft come after him for this?
[+] bachmeier|7 years ago|reply
They could sue Github's parent company for hosting it.