Minecraft-like World

Everything related to 3D programming
Kelebrindae
Enthusiast
Enthusiast
Posts: 151
Joined: Tue Apr 01, 2008 3:23 pm

Minecraft-like World

Post by Kelebrindae »

Hi,

I've made a little minecraft clone. Sorry I've took so long before posting it here, but I was trying to pinpoint and fix a bug that was preventing it to cross-compile on x86 and x64... (see here: http://www.purebasic.fr/english/viewtop ... =4&t=60433

The "game" is in a very early stage:
- The world is procedurally generated on-the-fly as you walk around, and saved when you quit.
- You can dig and build, but there's still very few block types available.
- Water and lava exist, but are not really managed (they don't flow).
- Only one biome (rolling hills).
- No monsters or animals, but there's still bugs aplenty... :P

Code and resources are in the zip below, because the sources are too big to fit in a forum post :(
http://keleb.free.fr/codecorner/downloa ... clone2.zip

Controls:
- Left-click to dig / right-click to build;
- E/R to select a building block;
- G to switch on/off ghost mode (you can fly and pass through walls)
- Ctrl and arrows to jump and move.

Use the "#VIEWDIST" (line 43) constant to adjust the drawing distance if FPS are too low, and don't forget to turn the debugger off.

A last precision: I've used an octree structure to store the chunks' datas in memory (see an exemple code here: http://www.purebasic.fr/french/viewtopi ... 13&t=14123) ; I'm not sure it's an optimal solution and it could easily be replaced by standard arrays[x,y,z]...

Have fun! :wink:

Image
Image
Image
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Minecraft-like World

Post by STARGÅTE »

very nice clone of minecraft and nice demo for pure basic 3D.
And thx for the source code.

Some notes: Some times the word is rendered to slow or no longer, so the exe chashes.
Here the last screen befor it crashes:
Image
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Minecraft-like World

Post by Shield »

Pretty sweet, thank you for sharing! :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Minecraft-like World

Post by Derren »

Guess I need Pb 5.3?
"Line 802: ClipOutput() is not a function, array, list, map or macro."

edit: no, your header says 5.21, I have 5.22 LTS
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Minecraft-like World

Post by applePi »

thanks Kelebrindae , i like the procedurally generated things
it works in pb 5.30. regarding line 3 of the source it said "PB version: 5.21". the ClipOutPut seems not part of 5.21 but it is part of 5.30
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Minecraft-like World

Post by DK_PETER »

@Kelebrindae
That is some nice work you've done. :shock:
I've only skimmed the code for now and it's truly some advanced coding.
I won't even pretend to understand your code. It surely requires a LOT
of examination and isolated testing, before it will make any sense to me. :lol:

Well done and thank you. :wink:
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Minecraft-like World

Post by Derren »

ok, I installed PB 5.3. After asking for a seed the program crashes with the usual non-descriptive Windows error message.

ogre.log: http://pastebin.com/CnGVNeLC but I'm pretty sure only the last few lines are relevant
...
04:04:48: Parsing scripts for resource group Internal
04:04:48: Finished parsing scripts for resource group Internal
04:04:48: Creating resources for group Internal
04:04:48: All done
04:04:48: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource cursor.png in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
04:04:48: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource sky_fr.jpg in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
04:04:48: Error loading texture sky_fr.jpg. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource sky_fr.jpg in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Minecraft-like World

Post by applePi »

try running the octreeWorld_v2-7.pb which are inside the folder mineclone, most likely you run the octreeWorld_v2-7.pb which are outside mineclone which are not related
as DK_PETER said it is an advanced example with issues related to computer science subjects, i have no idea how it works. may be in the future
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Minecraft-like World

Post by c4s »

In my opinion it's hard to build something because you don't really know where the block will go. Also inside a cave it's stuttering a lot. But apart from that very impressive work you've done there - I'd love to see this getting improved as it seems to have great potential!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Minecraft-like World

Post by Derren »

applePi wrote:try running the octreeWorld_v2-7.pb which are inside the folder mineclone, most likely you run the octreeWorld_v2-7.pb which are outside mineclone which are not related
as DK_PETER said it is an advanced example with issues related to computer science subjects, i have no idea how it works. may be in the future
Thanks, yeah it seemd logical to run the top most code and not something from a subfolder^^

@c4s: Yeah, the building is a lot different from minecraft. The distance between you and the block your place is pretty much always the same (which means you can place blocks in the air). It's a bit tough to get used to, when you're used to minecraft, but once you figure it out, you can build.

Well, the controls are kinda weird. I prefer WASD,Space instead of Cursor/Arrow and Ctrl/Shift or whatever, especially since you cycle through building blocks with 'E'
Kelebrindae
Enthusiast
Enthusiast
Posts: 151
Joined: Tue Apr 01, 2008 3:23 pm

Re: Minecraft-like World

Post by Kelebrindae »

First, thanks a lot for your kind comments! :D

Second: Sorry for the problems you encountered, you are absolutly right...
This is more a test project that got out of control and took me way too much time, actually. I was just wondering how the whole "procedurally generated block world" was working, and if it can be done in PB => that's why it lacks a bit of polish...

@Derren:
I screwed up when I've done the zip file: When I added the sources, I didn't checked they were in the correct folder. I've fixed it and uploaded the correct version, with the pb files at the right place and all. Sorry! :oops:

I understand the controls may seem a little awkward if you're more accustomed to the "WASD" pattern. Fortunately, it's easy to modify: the "KeyboardPushed" are all located from line 2000 to line 2055, and are sufficiently commented so you know what to change.

@AppliPi:
Yes, it's v5.30 only, due to ClipOutput and other small things; the headers comments are fixed too.

@c4s:
The stuttering can (perhaps) be fixed by adjusting the #VIEWDIST constant. And yes, the digging/building mechanisms are somewhat unpractical; G-Rom told me so already, and I totally agree. I didn't play Minecraft a lot (just once or twice) and I only know it by watching my kids use it...

@All:
Well, I'm really sorry, but I don't think I'll update the code anymore: As I said, it was more a test than anything else, and it would need a lot of time and modifications to make it work really right (it's more "messy" than "advanced coding"). But I'll gladly answer any question if anyone want to reuse this code or any part of it. :)
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Minecraft-like World

Post by DK_PETER »

Kelebrindae wrote:First, thanks a lot for your kind comments! :D
(it's more "messy" than "advanced coding"). But I'll gladly answer any question if anyone want to reuse this code or any part of it. :)
I'm not a Minecraft dude..Waaaay too old for that - even my kids are too old (highschool). :lol:
Just a small note: Messy code IS certainly 'advanced code'. :mrgreen:
Your code ain't that bad and you've created some nice tricks to make it work.
Your macros and some of your procedures threw me off guard, when I first skimmed your code.
You've shown, that creating something big isn't a problem at all for PB and that is a VERY good thing. :wink:
It's nice to see ideas and problem solving realized in (for me) unexpected ways.

Best regards
Peter
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Minecraft-like World

Post by djes »

DK_PETER wrote:I'm not a Minecraft dude..Waaaay too old for that - even my kids are too old (highschool). :lol:
I know a lot of people older than that playing around with Minecraft (no life?). Did you try ? I did and I understand why, even if I really don't have (and don't want to take) the time. :)
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Minecraft-like World

Post by DK_PETER »

djes wrote: I know a lot of people older than that playing around with Minecraft (no life?). Did you try ? I did and I understand why, even if I really don't have (and don't want to take) the time. :)
Hey Djes.
I'm forced to play it, since I work with teenagers on a daily basis. My own kids don't play it.
The kids I work with are cheating like crazy - flying around - building large objects with a constant full inventory. :mrgreen:
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Minecraft-like World

Post by djes »

DK_PETER wrote:
djes wrote: I know a lot of people older than that playing around with Minecraft (no life?). Did you try ? I did and I understand why, even if I really don't have (and don't want to take) the time. :)
Hey Djes.
I'm forced to play it, since I work with teenagers on a daily basis. My own kids don't play it.
The kids I work with are cheating like crazy - flying around - building large objects with a constant full inventory. :mrgreen:
Yes, it's interesting, isn't it ? As if this feeling of cheating was something giving value to the play. However, everybody is cheating, so it's not cheat anymore ! But it's not as simple. Some times ago, I bought a card play to my child, where everybody was forced to cheat. He hated that ! But he loves minecraft... :?
Post Reply