Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: 2dCraft (Minecraft 2d port)  (Read 18595 times)

0 Members and 1 Guest are viewing this topic.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
2dCraft (Minecraft 2d port)
« on: March 30, 2012, 05:24:22 am »
Hello there!  As many of you know, Minecraft is a three dimensional game where you can craft and build a world of your own.  I enjoy this game, but think that one extra dimension is a bit too confusing for me ;).  I was going to rewrite it in C++ using the Allegro libraries, but I could never get them set up correctly across my multiple platforms, and it started having issues on the platform it originally worked on.  One of my friends showed me SFML, and it worked out of the box and was cross platform so I'm sticking with it.  Basically, with this version of Minecraft, I'm following the original changelog (found here: http://www.minecraftwiki.net/wiki/Version_history) as closely as I can.  So far, I have a small world working where you can place and remove blocks of different types.  You can also move a player image (not fully working) around by using the left and right arrow keys to move and the space bar to jump.  I'll update this later tonight with an OS X app and a Linux executable.  I may or may not upload the source, depending on what you guys want. 

So, in summary, this is working:
Five different block types (dirt, grass, stone, cobblestone, and wood).
Changing selected blocks (no indicator) using numbers 1-5.
Placing and removing selected block.
Loading a world from a text file.
Moving a player image and jumping (Kind of.  It's my current focus).

And the next version will have this:
Indicator for selected block type
Better player movement

Thanks for reading!  If you have any questions, feel free to email or pm me.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #1 on: March 30, 2012, 05:34:30 am »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11053
    • View Profile
    • development blog
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #2 on: March 30, 2012, 10:50:24 am »
Since I'm not on linux nor Mac OSX I can't try one of your applications but I'm still left wondering how it would look like in 2D. Is it just top down or is it really just 2D?
Can't you provide a screen shot?  :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #3 on: March 30, 2012, 11:49:07 am »
This sounds pretty sweet! :D Sadly I'm on windows too so I can't test it, and source code would be great to look at, just to see how you did it :)

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #4 on: March 30, 2012, 04:14:25 pm »
Redistributing Linux binaries that are linked against shared libraries is only a good idea if you provide packages for the most common distributions (.deb for Debian and derivates, RPM etc.). Otherwise, to make the process easier, link statically so the user don't has to bother with it.

I'm missing the SFML 1.6 libraries. Would be nice if you could upload it linked statically, as I don't plan to install anything prior to SFML 2.0 anyways. ;)

iHope

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #5 on: March 30, 2012, 04:23:38 pm »
I just tested this and well, it looks very good. Of course there are bugs etc. but it looks Minecraft. Map generator is actually pretty sweet, I even played around with it. I hope you understand my english enough :D

Tip: You should put how to use map generator and controls to this thread.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #6 on: March 30, 2012, 08:40:58 pm »
Thanks for the feedback so far!   Someone mentioned that I should link the libraries staticly?  How would I do that?  I'm using Code::Blocks to develop, if there's IDE specific steps. I've been programming for less than a year so I don't have a lot of experience with that.  This is the only real project I've shared online, so any suggestions would be very welcome.  I have a better version I'll upload later today that changes several things.  I'll post it along with the source code later today.

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #7 on: March 30, 2012, 08:42:58 pm »
Thanks for the feedback so far!   Someone mentioned that I should link the libraries staticly?  How would I do that?  I'm using Code::Blocks to develop, if there's IDE specific steps. I've been programming for less than a year so I don't have a lot of experience with that.  This is the only real project I've shared online, so any suggestions would be very welcome.  I have a better version I'll upload later today that changes several things.  I'll post it along with the source code later today.

Hey, to link them statically, change in the linker options the:

-lsfml-graphics
-lsfml-window
-lsfml-system
-lsfml-audio

to

-lsfml-graphics-s
-lsfml-window-s
-lsfml-system-s
-lsfml-audio

Then that will link it statically :)

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #8 on: March 31, 2012, 12:25:27 am »
So here is version 0.0.2:
OS X:
https://legacy.sfmluploads.org/file/119
Linux:
https://legacy.sfmluploads.org/file/121
Windows:
https://legacy.sfmluploads.org/file/123
Source:
https://legacy.sfmluploads.org/file/120

Changelog:
New:
To move, you now use A and D for left and right and [space] to jump like you do with the original Minecraft
You can choose which type of block to place by pushing [1-5] on your keyboard.

Fixes:
You can left click to remove a block and right click to place.  You can no longer place a block over another block.
Collisions work much better, though still aren't perfect.

If anyone would like to compile this for windows and upload it I wouldn't have any problems with that.  Any tips on how to do things better would be much appreciated!!!

Edit: There is a problem with the linux version and the source code where when the space bar is pressed it closes.  It is fixed in the OS X version and will soon be fixed in the others.  Sorry for any inconvenience!
Edit 2: Fixed in all three files!
Edit 3: Added windows binary thanks to eXpl0it3r!
« Last Edit: March 31, 2012, 04:16:17 pm by tanmanknex »

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #9 on: March 31, 2012, 12:28:16 am »
One more thing, I tried to link the libraries statically using what aBallofWin posted, but it says that it couldn't be found.  Any suggestions?  If not, then I suppose I can just compile a version for sfml 2.0 as well, though that'd just be one more thing to do for each post.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11053
    • View Profile
    • development blog
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #10 on: March 31, 2012, 12:44:25 pm »
Okay since you now provided the source code I was able to build the stuff on my own, but only with quiet some work.
I didn't want to try SFML 1.6 since most of the applications won't run anyway on my AMD GPU so I rewrote it to use SFML 2.0 which was easy for the SFML part, but hard for the global variables. (Laurent you should disable shared context!)
Here you go with the source for SFML 2.0. It also contains a binary for Windows x64 static linked, but be aware the code is pretty much hacked together so it would work!
https://legacy.sfmluploads.org/file/123

Since the top post still misses a screenshot I created a not very spectacular one:


Now for the codebase...
  • You should clean up everything and define nice class interfaces.
  • Try to avoid global variables. In SFML 2.0 you won't be able to have SFML related graphics stuff as a global variable.
  • Implement a resource manager or get the one from Thor.
  • Do not use arrays if you can just as easily use std::vector.
  • Try not to hard code as much as you can and if you do make it expandable easily. E.g. for the materials use an enum.
  • Try to keep the events and input handling centralized. Don't check for inputs in the World and the Entity class etc.
  • The mouse picking stuff and positioning is faulty (for diffrent resolutions).
  • Keep the work up!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #11 on: March 31, 2012, 04:36:51 pm »
@eXpl0it3r:
Thanks for the binary and screenshot!!!  As for the code base, thanks for these suggestions!  I haven't been programming very long and I only started this project like four days ago, so the feedback on how to code is helpful. 
Clean up meaning what exactly?
How would you suggest I get rid of the global variables?  I was thinking maybe to have a global function that returns an image? 
I'll look into a resource manager a little bit in the future.
How would I use std::vector instead of an array?  Do you mean for the map layout and stuff?
What did I hard code besides using numbers for materials?
I'm going to fix the separate inputs sometime soon, that's just how it worked out because I had the world working then added entities.
Why is the mouse stuff faulty?  What happens?  I haven't noticed any problems except on my old junky computer which can barely handle a text editor and/or a compiler.
Thanks, I will!

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #12 on: April 02, 2012, 10:06:33 pm »
Okay, so for the new version (probably to be released tomorrow or wednesday), I will have completely rewritten the game.  It will be version 0.0.2a and will have the following changes:
The player no longer moves around the level; the level moves around the player.
Better memory usage.
New chunk generator.
Thanks again to eXpl0it3r for the suggestions!

iHope

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #13 on: April 03, 2012, 01:56:02 pm »
New update sounds pretty sweet! It's nice that you want continue this project :)

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #14 on: April 05, 2012, 06:59:20 pm »
I apologize for not having an update yesterday but I was having issues with the random chunk generator.  That's right, the world is no longer just one file!  I have updated it so that the world moves around the player.  I'm going to be out of state for the next week (Spring Break!) but hopefully I'll have a fully working version 0.0.3 when I come back. 
0.0.3 will have:
-Random chunk generator
-Moving world
-Ability to load world from files
-Much larger walkable distance and higher ceiling for the level
-Possibly a surprise ;)
Thanks for your interest in my continuation of this project, it's why I'm still working on it!

 

anything