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

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

0 Members and 1 Guest are viewing this topic.

Chuckleluck

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #15 on: April 13, 2012, 05:21:29 pm »
Looking good!  :)
Though here's a list of a couple of bugs I've found:
  • When you run too far against a block, you can't jump
  • Block placement/destruction is a little off the mouse (usually 1 block below where my cursor is)
Keep up the good work!  Looks very good so far.   ;D

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #16 on: April 18, 2012, 01:53:21 am »
Thanks for reporting the bugs!  I'm completely redoing everything from collisions to world loading, so hopefully those bugs will be gone with the next update.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #17 on: April 20, 2012, 12:08:01 am »
Hey all!  As you may have noticed, I don't have an update out.  This is due to my choice to upgrade to sfml 2.0.  I didn't think it would be too difficult, but it turns out it's more difficult than I thought.  For some reason, I'm having issues with loading textures/images and returning them from functions.  I have a couple questions.
1. Is it possible to draw an image directly to a sprite in sfml 2.0?
2. Is it possible to return a texture/image from a function (I'm thinking resource manager)?  I've tried but it returns a white texture.
3. What would the best way to draw the world to the screen?  I have it divided into three chunks with a texture for each (in my world class).
Any answer would be much appreciated!

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #18 on: April 22, 2012, 06:21:53 pm »
Hey everyone, just a quick update of my progress so far. 

Here's what works:
Moving around the world (no player yet)
Loading chunks continuously (pretty much forever in each direction)
Resource Manager

Here's what doesn't work yet:
Player (I just haven't taken the time)
Collisions (no player to collide with yet)
Placing/removing blocks

After I get those last few things, I'll release an update.  You can expect it by or on Tuesday. It'll be version 0.1.0.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10777
    • View Profile
    • development blog
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #19 on: April 22, 2012, 11:18:55 pm »
I'm not sure if you still need answers to those questions but I'll answer anyway.
1. Is it possible to draw an image directly to a sprite in sfml 2.0?
In SFML 2 the sf::Image got sort of replaced by sf::Texture. You now should only use sf::Image if you're doing pixel manipulation, otherwise use sf::Texture. That's mainly because the conversion from a sf::Image to a sf::Texture isn't very efficient.

2. Is it possible to return a texture/image from a function (I'm thinking resource manager)?  I've tried but it returns a white texture.
It sure is BUT if you create the texture inside that function, it will only be valid within that function and get destroyed as you leave the function. To get around this, you either have to create the texture with the new keyword but you'll have to delete the resource again on your own (just google RAII and shared_ptr to learn how to handle the basics of resource management) or you declare a member variable in which you load the texture which then will be accessable from outside this function.
For resource management I can only suggest to use the one from Thor. It will save you a lot of work and it's safe regardiong memory leaks etc (at least should be, right Nexus? ;)).

3. What would the best way to draw the world to the screen?  I have it divided into three chunks with a texture for each (in my world class).
Not exactly sure what you mean by 'world'.
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 #20 on: April 27, 2012, 12:59:43 am »
Sorry for not having an update on Tuesday, but I was having issues with block placement and removal.  I was having a bit of trouble detecting which chunk you are clicking in, but I worked it out!  I also added a thing where the player's arm points at the mouse.  On top of that, I added some code so that the player changes direction when you push left/right!
Working:
Player movement
Block placement/removal (only dirt currently but that'll be easy to fix)
Player's arm tracking the mouse
Player direction change
Random world generation

Not working:
There is a glitch that sometimes shows up when you start out moving left where the loaded chunks jump to the right.  (Note: For some reason it's only when you start out moving left.  If you can look through my code and find why, it would be much appreciated.  If not, then it might be a while until I have a fix.)
There is a bug that displaces the chunks incorrectly if you push up/down at the start or right when the left of the screen is on a border of a chunk. (Note: This is due to the way I'm saving/loading chunks.  I'll fix it in the next update.)
Collisions (Note: This will be the next update after I release the multiple block/indicator update)

 I can release an update today, or I could wait until I have the multiple blocks and the block indicator working (probably tomorrow or next day).  What do you want me to do?

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #21 on: April 29, 2012, 08:30:41 am »
Okay, everyone, here is version 0.1.0!  It is a complete rewrite of the previous version from scratch.  If you have programming experience, any advice on my coding skills would be appreciated!  I have a lot of improvements over the previous version.  Here they are:
-New world  size with random generator
-Correct block placement
-Player arm points at mouse
-Five blocks to place/remove (dirt, grass, stone, cobblestone, and wood)
-Uses wasd keys to move and 12345 to choose block type.
-Uses SFML 2.0

The next version 0.1.1 will have a new collision system, hopefully more accurate than before.  I have some ideas that I think will be really good for it, so hold tight!

Download link:
https://legacy.sfmluploads.org/file/132
((I apologize for any inconvenience, but I cannot upload a mac package until I can figure out how to install sfml 2.0 on my mac.  The source code is included should you wish to compile it yourself.  Once again, I apologize for any inconvenience.))

iHope

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: 2dCraft (Minecraft 2d port)
« Reply #22 on: April 29, 2012, 08:56:38 am »
If you need any help to install sfml 2.0 to mac, I'm glad to help you.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #23 on: May 06, 2012, 06:47:52 pm »
@iHope: I hadn't noticed there was a .pkg installer available but I got it now.  Thanks anyway though! 

@everyone else: My next update won't contain collisions.  I tried to get them to work but it didn't work and I didn't have the patience to fix it at the moment so the next update will contain an inventory.  The one after that will have collisions.

tanmanknex

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: 2dCraft (Minecraft 2d port)
« Reply #24 on: May 18, 2012, 02:43:13 am »
I have great news!!!  I have (finally) gotten around to finalizing version 0.2.0!  There's some really cool features I added and some pretty major changes I've made. 

Changelog:
Added inventory support
Added the "hotbar"
Added two more block types: sand and brick
Added collisions (mostly, still a little buggy)
Added the option to switch between flying and walking
Added gravity and jumping (spacebar)
Many file system cleanups:  Source is in src folder, images are in a resources folder, and the world is in it's own folder.
I also removed all the old files that aren't being used anymore.  The whole folder should now look neater in general.

Controls:
Left click to remove block
Right click to place  selected block
1-9 to change selected block
E to open inventory
E/[esc] to close inventory
[tab] to switch between flying and walking
flying:
  W, A, S, D to move
walking:
  A, D to move
  [space] to jump

Known Bugs:
Sometimes when the player collides while walking/jumping, it freezes the game.
If you start going left first, the world glitches and jumps once.  After that it's fine.
If the world glitches (previous bug) and places you behind a block, the game freezes.  This is also why in this version you cannot place a block within a 64 pixel radius around the player.  I'm going to do something to make it handle it better in a later version.
Sometimes gravity seems immensely strong and pulls the player down instantaneously.

Download Links:
https://legacy.sfmluploads.org/file/136
This contains a codeblocks file that is completely updated, along with all the source and resources.  It also contains an xCode project file, but it hasn't been updated in quite a while, so not all of the necessary files are included and there are some that have been deleted since then.  I'll try to get around to fixing that today, but it might be a little while.

Thanks for following this project!  I'm sorry for taking so long for an update, but it's nearing the end of the school year and I've had AP tests.  Feel free to make any suggestions to me regarding code, features, bugs, or anything else!  If you have any questions, feel free to post them here and I'll do my best to answer them as soon as I can. 
Thanks again,
Tanmanknex