SortaCraft! [0.8 Alpha]
tussiez

UPDATE 10/13/2021

It's been almost one year since SortaCraft was released.
Hang in there, SortaCraft 2 is still coming!
Preview - https://sortacraft2.sortagames.repl.co/

ORIGINAL POST

This is my take on a Minecraft clone! This game was built with Three.js and JavaScript Modules, Web Workers and Service Workers.

NOTE

This page will not be updated until I release Survival Mode.

Coming Soon: Beta!

How To Play

Click on the crosshair to lock your pointer
W A S D to move around
Scroll to change block
Space to go up
Right click to place, left click to break

UPDATE 12/1-4/2020

Baconman321 has collaborated with me on this project and has cut the loading time of chunks in half! Minor optimizations have also been made.

12/3/2020
I have also reintroduced realistic lighting and optimized shadows to the game, making cave exploration, terrain, and buildings more visually interesting. A better offline cache system and versioning is in the works, along with sprinting (which I may warn you, is quite buggy at the moment). There is also a new menu you can access by pressing `. This menu allows you to change the material type of all chunks, and will greatly improve performance on lower-end devices.

12/4/2020
The game has been optimized further, and the "plastic" look has been removed. Offline support is being worked on.

Q and A

  • The game is REALLY slow. Can you make it faster? Press ` (backtick) to change the graphics setting.
  • How do I change block? Scroll up and down.
  • It's so hard to look around. A: Make sure your pointer is locked(click)
  • It's so hard to place/break. A: It is a bit difficult to break/place on a touchpad. Try a mouse.
  • Why is it taking so long to place/break blocks? A: Please use a different computer.
  • Why can you jump so high? A: I'm lazy
  • Why is the sand biome all slabs? A: I need to fully implement half blocks

Image Gallery

You are viewing a single comment. View All
Baconman321

You should use a service worker so this works entirely offline. Also, you can make it a PWA. It's not that hard, maybe takes like 15-20 minutes to set up if you do it correctly. I can help you if you don't want to do it yourself. Also, I really need to congratulate you on this. First of all, I suck as a web designer, and a game designer is no different for me. Also, the use of implementing a chunk loading system like the actual minecraft system is genius! I am also ecstatic that you used the advantage of web workers (since they offer another interpretation thread, meaning you can do complex calculations in them without affecting the main page performance). I would love it if you could make the chunks a bit more large, but let's be honest. JavaScript is slow, and the language they use for the actual minecraft (Java) is most likely faster (since it's strongly typed). If you could do that without affecting my performance... I don't know what I would do this is so great anyways, I sit back and play it and I notice all the complex features added to this. Also, one of your javascript files is like 2k lines of code, so that must have been a lot of work. I made a program with 2k lines of code, but it was more consisting of redundancy. This is great man!
Also I recommend adding shadows (as it's kinda hard to see things without them), torches, bigger biome sizes, less cave systems/bigger systems but less appearing, and music. Personally, I think the music would be really hard to obtain, since the minecraft music is copyrighted, and it wouldn't be minecraft without it (I know it's a minecraft spin-off, but still). However, if you have gone this far with this awesome work of art, you can almost certainly go farther. I believe in you!

tussiez

@Baconman321 Thank you so much!
I’ve seen a JavaScript Minecraft clone by Khan Academy, and it runs blazingly fast. This is most likely because almost all of the game code is GLSL. I think the Three.js library is slowing it down. Maybe in the future, I could skip the library and port most of the code including the big parts such as the terrain generator and voxel engine, as the engine generates the geometry data itself, and Three.js inserts it into the geometry. I’ll look into PWA and the service workers soon. The comment on chunk size - I’ve used 16 by 16, or maybe 64 by 64. I believe 64, I need to check. My target platform was the school Chromebooks, and they were already struggling with the game. My original goal was cubic chunks, this works half the time as I need to brush up on my math. The Bedrock edition of Minecraft runs much faster than the Java version, since a massive amount of the code that used to run on the CPU is now on the GPU, which is why crazy render distances are possible.

Baconman321

@tussiez Yeah, you seem to know much more game design than me (cry, even though I don't care for game design...yet). Honestly, PWA is something I just made, so I don't think it would be too hard. I could help you with the service worker part too if you need some help. I like how you implemented the chunk worker. But, how does it generate half a tree, then when you generate it again it generates the other half? Do you store the data about half of something being generated? Or... I don't know I'm lost. There's so many things I want to know about this since it's sooooo cool about how chunk loading works. Also, try working on despawning certain chunks but store them so they appear later. And I'm on a chromebook too so off. Yeah, as long as it doesn't load a chunk, the framerate is at about 60.

tussiez

@tussiez I think creating a new version without Three.js and just WebGL would be a fun project.
I’ve gone through multiple revisions of this game, some starting all the way since last year. I’ve learned a lot about JavaScript during this project, and because of this the code has gotten a bit inconsistent. This could be fixed in a rewrite.

The first revision of this game didn’t have Web Workers, and was freezing up when I loaded in chunks. After adding a Web Worker, I realized that the data load from the worker itself was also causing the game to hang. Because of this, I created a clever cache system that lazy loads the lazy loaded chunks, to prevent lag. In a future revision, I could add an option that can customize the loading speed (The Web Worker generates the chunk blazingly fast, however the processing of the output does take some time) so you could get a faster load if you have a powerful computer. An automatic version of this could be done too.

Baconman321

@tussiez What do you mean by lazy loading? Like load the whole game but only show parts of it (or at least load major parts)? Also, the game doesn't load unless you have a certain flag enabled in chrome://flags (for my chromebook at least; you should mention that on the mainpage).

tussiez

@Baconman321 Yeah... oof
Yeah, I would like to learn some more about PWA, so I will gladly accept your help. Oh, partial trees was a very interesting problem to solve. I used to allow trees inside the chunk, so they don’t generate half trees however it made tree clusters impossible. If you look in the code, there is an additional worker called geometrydataworker. This worker handles the geometry data generation, reducing the lag on the main thread. When chunk data is processed, the voxels are set in a global multi-chunk VoxelWorld, and this is where the geometry data is generated. This means every once in a while, half trees are generated (one chunk overrides the other) and sometimes they don’t happen and tree clusters work perfectly.
Yeah, I tuned the loader for the Acer R11 Chromebook. Around 50-60 FPS.

To put it simply, the chunk data is global, not relative.

Baconman321

@tussiez So essentially it stores information about the trees, then when it generates the other chunk it loads the full tree? (Remember I am totally new to this, but I squeal with delight at this genius idea of chunk loading).

tussiez

@Baconman321 Huh.. chrome:// flags is blocked on my Chromebook and I don’t have issues. Are you talking about hardware acceleration?
As in lazy loading
The web workers generate the terrain pretty fast, the problem is they load so fast that the main thread can’t catch up. To fix this, the data is stored for later instead of processed immediately.

tussiez

@Baconman321 Correct!

Baconman321

@tussiez Ah. Yeah, for me you have to enable experimental javascript. I wonder if it's enforced by your network admin, so maybe that's why. Yeah, the whole chunk thing is complex but amazing. I don't know why more games don't use it!

Baconman321

@tussiez Oh, and also add running! And doors... and glass.

Baconman321

@tussiez Invite me to your project so I can help you with offline capabilities and PWA please. I would love to collaborate with you and show you all about service workers (all that I know)! I'm available from 11-12 and 2-3 CST (central daylight time). If that doesn't work, I can just make you a service worker and put comments in describing how everything works. It would be an honor to help you out with this genius project! :>

tussiez

@Baconman321 Missed the shadows part of the comment :)

I’ve tried cascading shadow maps before on the game, and they do work (and really well). I don’t know if the implementation is still in the code (just commented out) or not, the problem I was having with the shadow map was that lighting wasn’t updating with shadows (lights wouldn’t work). And yes, I should be able to fine tune cave systems as it’s an easy task. Thank you for the feedback!

tussiez

@Baconman321 Sure! I can add doors (as you can see, I was messing with voxels and sand is now a slab) however glass has been an interesting problem. This has always been an issue with voxel games, as it requires a custom z-index and more computational power. I could probably do this in WebGL in a future version though

tussiez

@Baconman321 Sorry about late reply, I’ve been busy recently
And yes, I’ll try to invite you soon! I’ll let you know if I’m available tomorrow (most likely yes)
Thank you once again for your help!

Baconman321

@tussiez No problem. Remember, I'm available 12-1 and 2-3 Central Standard Time. Again, if we can't work it out, I can always add comments to the program to show how it works!

tussiez

@Baconman321 Got it! I will also be available! We can start with a forked Repl (so in case we mess anything up really badly, it's easier to reset). I think we can skip offline for now, as I'm thinking about writing a new version of this game (once again) that may have some new optimizations. You can still tell me how to do it though :)

Baconman321

@tussiez Ok. I have to do some stuff (school). I'll be available in about an hour and 15 minutes (sorry). Also, if you know about repl history, it's really easy to use in case you mess up. Either way, ok.

tussiez

@Baconman321 1 - same!
2 - sure! It's shared

Baconman321

@tussiez I'll let you know when I'm ready. Also, service workers don't mess with the main stuff. If anything happens, you can just clear your cache. Service workers work on a seperate thread and all, I'll tell you more when I'm ready.

tussiez

@Baconman321 Got it!

Baconman321

@tussiez I can work now. I'm joining your main game. Just let me know when you are there and ready.

tussiez

@Baconman321 I'm there

Baconman321

@tussiez I am ready when you are (meet me in ur repl). until 3 P.M CST at least.

Baconman321

@tussiez I'm in your repl if you want to come. I gotta test and fix some things that I found aren't working.

tussiez

@Baconman321 Got it!
I'm in class at the moment.

Baconman321

@tussiez Oh, ok. Let me know when you don't have class.

tussiez

@Baconman321 I'm available now

Baconman321

@tussiez Can we do this at 1.PM CST? I'm kinda busy (school). I'm available 1-2 PM CST (not 2-3 today), or at least, I believe I am.

Baconman321

@tussiez Ok I can do it now. I'll meet you there.

tussiez

@Baconman321 Sorry about the late reply, I've been really busy recently. I'm available anytime today (hybrid)

Baconman321

@tussiez Ah. Let's do 11-12 CST

Baconman321

@tussiez I'm available right now. I'll meet you in your repl.

tussiez
tussiez

@Baconman321 Sorry for the late reply, I'll be there in a minute. Helping my friend with a clicking game

Baconman321

@tussiez Ok, I'm available now if you want. The world is super dark so you may want to fix that.

tussiez

@Baconman321 Sorry, was catching up on homework again... I was working on adding shadows back and also sprinting is broken for some reason

tussiez

@tussiez Available after 2 CST

Baconman321

@tussiez Ok. I will go in and fix the caching issues (cuz it doesn't work offline now that you added threejs to the project, I'll fix that).

tussiez

@Baconman321 Got it!

Baconman321

@tussiez I believe I am available until 3PM CST. If you want, I can help (I think I found out the problem to a thing or two).

tussiez

@Baconman321 Got it! I've seen that SortaCraft works on HTTP only
I'm in a Zoom meeting at the moment, but I'll join soon

tussiez

@Baconman321 May not be available today at a scheduled time as I have a lot of schoolwork :)

Baconman321
tussiez

@Baconman321 When the cache updates, you'll see that the day/night cycle may have been fixed

I disabled the shader's lights
(The day/night script has brightness already programmed, so it should work now)

Baconman321

@tussiez Ok. As always I am available 11-12 and 2-3 CST. I found out you can put stuff on the GPU, so maybe we can do that (more on that later when we can meet).

Baconman321

@tussiez I'm available right now.

tussiez
tussiez

@Baconman321 Got it!

tussiez

@Baconman321 We might be able to get sundials to work..
(light direction)

Baconman321

@tussiez Ok. I'm on now. Also, I have no idea what that is XD (remember I don't do game design).

Baconman321

@tussiez Ok I fixed a few minor things in the service worker. Also, you might be happy to hear that I added a little version display at the bottom left of the screen in newgame.html.

Baconman321

@tussiez I'm available right now.

tussiez

@Baconman321 Oof.. you'll know eventually

tussiez

@tussiez Thanks for the version display! It'll be helpful

tussiez

@Baconman321 Got it. On every other day I'm in class from 5 to 1 CST

Baconman321

@tussiez Ok, so you're on now? I'm available 2-3 CST then. (And 11-12 CST when you can do that).

tussiez

@Baconman321 2-3 CST

tussiez

@tussiez Class ends ~2 pm for me

Baconman321

@tussiez K. See ya there!

Baconman321

@tussiez I am ready when you are!

tussiez

@Baconman321 Sorry I wasn't available yesterday, however I am available at 11-12 CST

tussiez

@tussiez I'll be polishing up lights (light direction, fixing light blocks)

Baconman321

@tussiez K. Not 2-3 CST? (I have some other things to fix on your game too; when we meet I have an idea so that I can keep up with what your making).

Baconman321

@tussiez I'm available when you are.

Baconman321

@tussiez I'm available right now if you need me!

Baconman321

@tussiez I'm available now.

tussiez

@Baconman321 Got it! I'm in class until 2 CST

Baconman321

@tussiez Ok cya then!

Baconman321

@tussiez I'm ready :D

tussiez

@Baconman321 Me too
Finishing up a repl I did in half an hour
https://linedraw.tussiez.repl.co/

Baconman321

@tussiez If you're available, I think I know the problem to the gravity thing :D

tussiez

@Baconman321 Sure! Working on adding colors to LineDraw

Baconman321

@tussiez I don't think I'll be able to help at 2-3 CST. I am really tired today, so if I have time after I attempt to rest, I'll let you know. Otherwise, see you on monday!

tussiez

@Baconman321 That's fine - see you on Monday!

Baconman321

@tussiez I slept. It's not enough to refresh me long-term, but now is fine. XD just as you read this and respond, I wake up from napping. I am available for about 15 minutes. Other than that, yeah see you tomorrow (I'll help if you're available now).

tussiez

@Baconman321 Woops! I took a break from the computer but that's good to know!

Baconman321

@tussiez Technically I'm available today (unless my dad turns off internet cuz he doesn't know I have it ;) )

Baconman321

@tussiez IDK if you're on now, but I'm available rn.

tussiez

@Baconman321 Home now.
I'm feeling a bit sick, so you're free to work on the game if you'd like, but I'll take today off

Baconman321

@tussiez Ok. I need your help with the gravity thing anyways, so I'll wait.

tussiez

@Baconman321 I should be free 2-3 CST if you want to try getting falling to work. Actually, your part is working great - I just need to fix my code.

Baconman321

@tussiez Ok. I think we should make a math webworker too, since that would be the part that takes up quite some computing power.

tussiez

@Baconman321 Yeah
This might be your answer: geometrydataworker.js
However we might move the math code into the GPU.. I'm not sure

Baconman321

@tussiez We should use WASM, since it's a compiled language it will run much faster than Javascript (which is JIT or just in time interpreted).

Baconman321

@tussiez Ok I'm ready...

Baconman321

@tussiez I'm ready...

tussiez

@Baconman321 I enjoyed my snow day yesterday :> I'm available today at 2-3 CST

Baconman321

@tussiez Ok, I recalled a method that is sure to speed up your game if you use a lot of new operators. Garbage collection! More on it later when we talk...

tussiez

@Baconman321 Yay! See you then!

Baconman321

@tussiez I'm ready.

Baconman321

@tussiez I'm available now if you want. Let's get that game to work :D

tussiez
Baconman321

@tussiez I'm in. Are you there?

tussiez

@Baconman321 I have to go now, but I'm available at 2-3 CST

Baconman321

@tussiez Oh ok...

Baconman321

@tussiez I'm available now if you want to me to help you get the game working :D

tussiez

@Baconman321 Here.Making cookies

tussiez

@Baconman321 Sorry I wasn't available, was out

Baconman321

@tussiez I'm tired so I'm going to lay down for a little. I'll let u know when I'm available.

tussiez

@Baconman321 That's okay! I'll be doing HW in the meantime

Baconman321

@tussiez I'm not going to today. I think it's just my medication. My mom didn't give it to me for a few days since she had to get a refill, and my body kinda got used to being without it, so when I got it I was really tired (same scenario with last time I was tired last last friday)

tussiez

@Baconman321 Ah thats OK!

Baconman321

@tussiez I can help now if u want!
Edit: OK NVM I can help at 1 CST

tussiez
Baconman321

@tussiez Also ur repl AUTH doesn't work... Oh well, Let's do that after we get sortacraft working and all :D

tussiez

@Baconman321 Yeah, it's having issues however it seems to work on me

Baconman321

@tussiez Also u quoted me ^W^

tussiez
Baconman321

@tussiez On the mainpage :D

Baconman321

@tussiez I'm ready if you want to.

tussiez
Baconman321

@tussiez Ready to help :D

tussiez
tussiez

@Baconman321 I'm there

Baconman321

@tussiez Want to work on sortacraft?

tussiez

@Baconman321 Missed this comment, woops
I’m free tomorrow

Baconman321

@tussiez I'm available if you want to collab now.

tussiez

@Baconman321 Sure! I'm writing Mastermind

Baconman321

@tussiez What's "mastermind"?

tussiez

@Baconman321 A board game

Baconman321

@tussiez If you want I'm ready now :D

tussiez

@Baconman321 Slept in - I'm probably available @ 2-3 CST

Baconman321
Baconman321

@tussiez K ready?

tussiez

@Baconman321 Sorry I have to do something outside

Baconman321