Modifire

Working on a new game. For now, it’s a Minecraft clone, but it’s going to end up as something unique. I’ll answer questions about anything, but I’d like to keep the code closed for now. I can’t really work on it as much as I’d like until Christmas, so don’t expect to see much change until Jan or Feb.

Alpha 0.01
youtube.com/watch?v=uQE3PfKe_J4

My friends want me to work on the netcode so they can play it together online. Started to work on that. Added Ralph as the player character, along with other changes

Alpha 0.02
youtu.be/kOZgrCB24fo

Not bad imho :slight_smile: how big is your world?

I’m not sure what the size is in that video, but the dev build is 64x64x24. I know that doesn’t sound big, but it ends up being 98,304 ‘blocks’. Once I get accustomed to flatten strong, I can make the world bigger. Currently, there would be too many geoms if I made it bigger. Within the next week or so, I hope to setup a website where people can play it embedded in the browser.

EdBighead - I was wondering if you could go into some detail on how you’re doing this? Your world looks decently sized and the performance you’re getting is very solid.

Would you mind sharing how you’re building your world a little bit? I’m trying to do something similar, and have an ongoing thread in the scripting issues sub forum:

[Minecraft style terrain generation (new issues))

Maybe you can see what I’m doing differently and offer some advice based on how you’ve tweaked performance?

edit: On my old-ish macbook pro I get about 12 fps when the entirety of my terrain is in view. It’s 9 10x10x10 chunks. I’m not using individual models, I’m using the procedural cube tutorial for generating my cubes and then parenting them all to a single node and calling flattenStrong(), as it’s the only way I can get a decent frame rate.

The downside of this method is that I’m redrawing the whole chunk when the terrain is manipulated; are you doing something similar?

I was planning on releasing the source for the game in increments. (e.g. when I’m on version 0.3, I’ll release 0.1, and then when I get to 0.4, I’ll release 0.2, and so on) Unfortunately, I only just decided to do this, and I didn’t save past source code, so it might be a bit before I start this; however, later today I’ll try to get the environment code online somewhere so everyone can look at it.

That would be really cool. My big bottleneck right now is generating terrain. So the more examples I can look at for how to do that, the better off I know I’ll be. :slight_smile:

Here are the environment files

mediafire.com/?1ol4clv68ac4cce

To make it interesting and use the 2D perlin noise, you’ll want to uncomment line 19 of EnvironmentGenerator.py . Currently, I’m creating flat worlds for the purposes of testing networkin stuff.

The idea is this:

First, create a 3D array of all the blocks, where each block has an id that corresponds to its type. (0 is air, 1-255 is blocks). Then create the geometry. To do this, we group the blocks into 4x4x4 chunks. Each block in a chunk looks to its neighbors to determine if any of its faces is adjacent to air (if it is, it needs to be drawn). So we create geometry for all of the visible faces. When we add or remove a block, we set all of its neighboring blocks to ‘dirty’. During the update tick of each frame, if any chunk has a dirty block, we redraw the chunk. The larger the chunks, the longer it takes to redraw it. For me, a 4x4x4 takes about 4ms to redraw.

This could be optimized by grouping adjacent and parallel face geometries (e.g. if you have a chunk with a flat plane on top, instead of drawing 16 individual squares, you group them all as 1 square). This would increase your fps. This is what Minecraft does. Also, if you’re having trouble rendering all of the chunks, you can flatten strong the geom node, but you won’t be able to add or remove blocks.

Thanks! I’ll need to dig through this. I think I have been on a very similar track as you, except I haven’t made it as far on optimizing things.

I’ve got my work cut out for me.

Hmm, I am pretty new to python (my job dictates that I know PHP and Perl quite well, so python has really thrown me for quite a loop!)

I was wondering if you might be able to explain the whole:

@staticmethod()

I tried looking it up in the python manual but as far as I was able to get it said it was similar to calling a static method in C++ or Java (neither language I’m familiar with). I was wondering if since you’re using it so liberally throughout your code base you might be able to give me a short description of what it does and why you’re using it?

Thanks!

The @staticmethod decorator is python’s way of declaring a function to be static. In java it looks like this:

public static void doSomething(){
// code
}

I’m not sure how experience you are with Object Oriented Programming, but static methods are methods that belong to a class (or module) that you feel should or can be called without needing an instance of the class the method belongs to.

As to why all of the methods of BlockGeometryGenerator.py are static, I guess I just felt like doing it that way. Or started with one static method and then made them all static. There is probably a right answer to whether they should be static, but in this case it would work either way. I may change them to be not static, if I feel it would make the code ‘better’.

Thanks! That’s actually really helpful. I have not ever used static methods like that before as with things like PHP, if you just want a function you can include a file with the functions you want to call and not have it tied to a class at all (making some arbitrary coding standards at work dictate I code this way, actually). Thanks again!

Version 0.03 Alpha is up to play if you’re interested. Feature wise, little has changed - I’ve been working on getting it ready for networked multiplayer. So only offline mode works. You may not find it very interesting yet.

modifire.net/

I was wondering if you might be able to post a sample bit of code that I would need to run just the environment you posted earlier. I’m trying to reverse engineer what you have but I’d kind of like to see it in action. Based on the performance you’re getting in the web player this is for sure something I need to dig into more; but I kind of wanted to just start out by getting it running.

If I’m reading it correctly, I should just create a file and import Environment.py into it and create an object out of that…I’m still working on figuring it all out. So I’ll post again if I am able to get it up and running.

e: Also, the mouselook in the browser is incredibly difficult to use. I end up just spinning in circles.

Or maybe instead of that, you might be able to explain more in depth what changes you had to make to this example:

[Creating a tiled mesh at runtime)

To get it to be 3D instead of a 2D plane? That’s really what I’m digging through your code to figure out, anyway.

edit: I may have an idea figured out. Basically, I’m going to create a new set of files and start with the way you’re generating geometry. I’ll send it to an outfile, then see how you’re reading it. THen I’ll start building the world by bringing in single “groups” of functions at a time. E.g. functions that can’t be segregated due to inter-dependence.

Regarding the browser - if you click once in the window, it will capture your cursor and work properly. I haven’t yet looked into disregarding mouse movement if the game isn’t focused.

If you create an environment object, it should just work. I’ll try to create a demo program this weekend.

Here’s the self contained example

mediafire.com/?cecxmsey5q8ecs5

It uses the default mouse control and the camera starts at the bottom left corner, so you’re going to have to move a bit to see the environment.

Awesome! I really appreciate it. I went through the previously uploaded code and just started stripping out as much as I could to get it working. I learned a lot about how you’re doing this, but there were some includes that you didn’t include and I wasn’t sure what they were supposed to do, or what data to include. Like in the init for Environment.py, there was a “game” argument that I was just throwing a text string into :slight_smile:

Thanks again!

I accidentally deactivated my account, so I’m posting from this one, but it’s still EdBighead.

Version 0.05 Alpha is up. modifire.net Multiplayer works. Client-side prediction is done. If you want to host a server and your machine is behind a router, you will have to Port Forward the following ports:

5555
5558
5559
5560

There is a bug that causes a client to crash if it attempts to load the map at the same time as another player, so be wary of that.

If you run into bugs or crashes, please reply with the log which is located at

C:\Users\YOUR_USERNAME\AppData\Local\Panda3D\log\p3dsession.log

Let me know what you think.

Controls:
WASD - Movement
Space - Jump
Left click - Destroy a block
Right click - Place a block
F5 - Third person view mode

That’s awesome! I’ve always loved Minecraft. But when you fall off, you just keep falling forever. I don’t know if you have added respawning or not though. I also have a question… How do you add the texture onto the block? I can import my character, but the texture won’t show up. I love your game though! I’m hoping it gets popular so I can go on multiplayer with somebody :slight_smile:

@werts15
Thanks! I’m hoping to eventually get some sort of server page so people can see who is hosting a server and then connect to it.

Thanks for reminding me about falling forever, I’ll post a fix for it in the next version.

When you say ‘How do you add the texture onto the block? I can import my character, but the texture won’t show up.’ What exactly do you mean? Do you see the blue and green blocks? Do you see the model for roaming ralph if you go to 3rd person view?