Giter VIP home page Giter VIP logo

hopsoncraft's Introduction

HopsonCraft

Note: Game is undergoing redesign at the moment.

To see source as it was in ep 4 "Creating Minecraft", view here:

https://github.com/Hopson97/HopsonCraft/tree/e803ca5fbf51df134cfa7e87c14275c6c73fce8e

Note

When I made this, I was highly inexperienced at programming (Less than 2 years), and the code is mostly pretty messy and game crashes a lot.

I have kept it on my GitHub for historical reasons, seeing as I have videos about this on my YouTube channel.

Versions (As seen in the YouTube videos)

This game has gone through major rewrites and refactors overtime.

To see the source code as it was in episodes 1, 2 and 3 of "Creating Minecraft in C++/ OpenGL" videos, look at an older commit here:

https://github.com/Hopson97/HopsonCraft/tree/90a5d596d07dfe71b5dbf47ec76c0b0802ec9dfa

Dependencies

The project requires these libraries: SFML (minimum 2.4), GLEW 2.0+ (OpenGL 3.3+), and OpenGL Maths Library (GLM).

Compile using compiler flags:

Windows -> -std=c++14 -O3 -s -lglew32s -lglu32 -lopengl32 -lsfml-graphics -lsfml-audio -lsfml-system -lsfml-window

Linux -> -std=c++14 -O3 -s -lGLEW -lGLU -lGL -lsfml-graphics -lsfml-audio -lsfml-system -lsfml-window

All the libraries for Linux (At least, on Ubuntu) can be installed with

sudo apt-get install libsfml-dev

sudo apt-get install libglew-dev

sudo apt-get install libglm-dev

Contributing

An easy way to contribute is to look for the ///@TODO parts in the code. please actually test before doing a pull request.

You can view the code style in contributing.md

You can view useful implementation details in implementation.md

Also, checkout the TRELLO! https://trello.com/b/P8ZbobQH/hopsoncraft

Description

Simple Minecraft clone written using C++.

Screenshots

Trees

Mountain

Cliff

Credits

Design

Matthew Hopson, https://github.com/Hopson97/

Programming

Matthew Hopson, https://github.com/Hopson97/

Art

Matthew Hopson, https://github.com/Hopson97/

Special Thanks

Anton Golov, https://github.com/jesyspa

Zoltan Fazekas, https://github.com/zfazek

hopsoncraft's People

Contributors

developerpaul123 avatar esser50k avatar hopson97 avatar innerspirit avatar jesyspa avatar rchard2scout avatar yccgabriel avatar zfazek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hopsoncraft's Issues

Trees getting sliced

It is because of the line of code below the comment.

Section* Full_Chunk::getSection(int32_t index, bool)
{
    //This causes trees and other structures to sometimes not work correctly!
    if (index < 0 || index > m_sectionCount) return nullptr;

    while (index > m_sectionCount - 1)
    {
        addSection();
    }

    return m_chunkSections[index].get();
}

Trees basically rely on the section existing.

So, when it tries to get the section to set a block, and the section is non-existent, the section is returned as a nullptr, thus no blocks get set.

Cannot compile on MacOS

I tried to run cmake . on my mac, the follow error generated. it was running on the master branch

Gabriels-MacBook-Pro:HopsonCraft gabriel$ cmake .
CMake Error at CMakeLists.txt:42 (find_package):
  By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SFML", but
  CMake did not find one.

  Could not find a package configuration file provided by "SFML" with any of
  the following names:

    SFMLConfig.cmake
    sfml-config.cmake

  Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
  "SFML_DIR" to a directory containing one of the above files.  If "SFML"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/tmp/HopsonCraft/CMakeFiles/CMakeOutput.log".

When I tried to compile it on older commit, say the V1.0 tag.
The cmake . pass but make command failed with following error.

[  1%] Building CXX object CMakeFiles/game.dir/Source/Camera.cpp.o
/tmp/HopsonCraft/Source/Camera.cpp:17:38: error: non-local lambda expression cannot have a
      capture-default
    static Function_Toggle_Key lock([&]()
                                     ^
1 error generated.

Just wondering will there be a compilation guide?

freezing on world loading

Since the world loading has been concurrent from main thread, there have been occasional freezes during the world loading around the player,

Sound

You need to start the game multiple times on Linux to get it working. I ran Valgrind on it, turns out it's an audio problem. For some reason, the audio just doesn't work sometimes, it might even cause the game to crash. pls fix Hopson

Blocks are not placing

Placing a block seems to replace the block at a location rather than actually place it.

Detail roadmap, plan a milestone

I want to contribute to the project for me to get experience with C++.
Searching for TODO did not give many results, nor were they very clear on their purpose.

If there is something I could start working on than that would be great :)

Ceiling collisions

When the player walks UNDER a block, they need way too much room for some reason.

CMake does not copy Data folder when building out of tree

I'm excited to see a CMake file, it will make your project much less tedious to build! However, currently there is a problem where if I generate an out of source build in say a build folder, the CMake target does not copy the Data folder to the correct place and the executable fails with:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Unable to load block:Air

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I don't have much experience with CMake so I'm not sure how to fix this the right way.

Doesn't work on intel graphics

I get this when I try to run

Error compiling shader: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Random Crashes

Game seems to crash, still unable to find source of crash in debug mode.

GUI sometimes glitches

I have had some text appear transparent, and some images fail to load on random occasions.

Crash: Game closing after opening

When running the game, if the game is closed too soon, eg less than 6 seconds later, then it says that it has crashed.

Doesn't happen if allowing the game to run for a bit longer.

Stutter after 5mins of game play

I was playing and the game started to randomly stutter really heavily for about 20 seconds, before becoming smooth again.

May just have been something to do with my laptop doing something else, but the framerate of the game remained stable.

Stutter

Game randomly stutters at times.

Crashes on play

You need to fix this bro, I can't even play the game. I am on Linux, and whenever I press play(the second one) the game crashes giving me a sig fault. WTF BRO

Hitbox for blocks appears in wrong place

When looking a block, sometimes the hitbox does not appear, but rather renders on a block BEHIND the one you are looking at.

This can be better seen when looking at leaves.

Chunks Are Not Loaded Correctly Sometimes

Sometimes, it seems that only part of a chunk file is loaded from.

Extremity frustrating issue, seeing as it worked before and I cannot have fun on this game because of it, seeing as whatever I build will more than likely get corrupted or something.

CMake issues on OS X

When trying to compile on OS X, with cmake . and make afterwards, I get the following error:

In file included from /Users/Johannes/Downloads/HopsonCraft-master/Source/File/World_File.cpp:1:
/Users/Johannes/Downloads/HopsonCraft-master/Source/File/World_File.h:22:21: error:
      implicit instantiation of undefined template 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >'
        std::string m_baseName;
                    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note:
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
1 error generated.
make[2]: *** [CMakeFiles/game.dir/Source/File/World_File.cpp.o] Error 1
make[1]: *** [CMakeFiles/game.dir/all] Error 2
make: *** [all] Error 2```

Any idea? Compiling on OS X 10.12.3.

High CPU useage

CPU usage can be around 30% at times, which makes laptops quite hot and starts to slow the game down.

Chunk Edges and Lighting

Chunk edges are mostly uneffected by lighting when a block is changed.

The only solution would be to regen EVERY chunk surrounding the one that changed, but there is probably a better way.

Build on macOS got clang error ld: framework not found OpenGL

macOS Sierra 10.12.4

[100%] Linking CXX executable game
ld: framework not found OpenGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [game] Error 1
make[1]: *** [CMakeFiles/game.dir/all] Error 2
make: *** [all] Error 2


brew install glew
brew install sfml
brew install glm

mkdir build
cd build
cmake ..
make

then I got this link error.

Does not work on linux

My buddy tried to run this on linux (arch) but it crashed when he hit the play button.

As a windows user, I am personally unable to test this.

Holes in terrain

Due to infinite terrain, the chunks may no longer know what block is at their edges, which is used to determine whether the chunk should have a face there or not.

Collision detection is not perfct

For some reason, it is unable to allow player to enter a hole 2x blocks high.

Sometimes the player can walk over 1x block gaps etc

White screen

Whenever I try to run the game on "super-flat" mode, the game just freezes on a white screen with a crosshair in the middle.

P.S I'm running the game on Linux

No compile under Linux - path

#/source/Util/File_Uitl.cpp

#include "File_Util.h"
#include <iostream>
#include <fstream>
#include <sstream>

#ifdef __WIN32
    #include <windows.h>
#elif __linux__ //this should be lower case - not upper case
    #include <sys/types.h>
    #include <dirent.h>
#endif // __LINUX__

std::string getFileContents(const std::string& filePath)
{
    std::ifstream inFile(filePath);
    std::stringstream stream;

    stream << inFile.rdbuf();   //Gets the file contents into a string stream
    return stream.str();        //Return the string from the string stream
}




#ifdef __WIN32
    std::vector<std::string> getFileNamesFromFolder(const std::string& folderName)
    {
        std::vector<std::string> fileNames;
        std::string searchFor (folderName + "/*.*");
        WIN32_FIND_DATA findData;
        auto hFind = ::FindFirstFile(searchFor.c_str(), &findData);

        if (hFind != INVALID_HANDLE_VALUE)
        {
            do
            {
                if(!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
                {
                    fileNames.push_back(findData.cFileName);
                }

            } while (::FindNextFile(hFind, &findData));
        }

        return fileNames;
    }
#elif __linux__
   //fixes here
    std::vector<std::string> getFileNamesFromFolder(const std::string& folderName)
    {
        std::vector<std::string> fileNames;

        DIR *dp;
        struct dirent *dirp;
        if((dp  = opendir(folderName.c_str())) == NULL) {
            std::cout << "Error(" << errno << ") opening " << dirp << std::endl;
            //return errno;
        }

        while ((dirp = readdir(dp)) != NULL) {
            fileNames.push_back((dirp->d_name));
        }
        closedir(dp);
        return fileNames;
    }
#elif __APPLE__ //not needed...apple is also POSIX compatible so uses linux code
std::vector<std::string> getFileNamesFromFolder(const std::string& folderName)
{
    ///@TODO Mac implementation of this
    return {};
}

#endif

LNK2019 unresolved external symbol "struct glm::mat<4,4,float,0> __cdecl Maths::createModelMatrix(struct Entity const &)"

Hello,

I have been trying to compile this project and cannot fix this linking error in VS2015. The error traces back to the call of Maths::createModelMatrix(*this) in the constructor of chunk.cpp.

Error	LNK2019	unresolved external symbol "struct glm::mat<4,4,float,0> __cdecl Maths::createModelMatrix(struct Entity const &)" (?createModelMatrix@Maths@@YA?AU?$mat@$03$03M$0A@@glm@@AEBUEntity@@@Z) referenced in function "public: __cdecl Chunk::Chunk(struct Chunk_Location const &,class Chunk_Map &,class Texture_Atlas const &,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Chunk@@QEAA@AEBUChunk_Location@@AEAVChunk_Map@@AEBVTexture_Atlas@@IAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Chunk::Chunk(const Chunk_Location& position,
              Chunk_Map& chunkMap,
              const Texture_Atlas& blockAtlas,
              unsigned seed,
              const std::string& worldName)
:   Entity          ({0, 0, 0}, {position.x * World_Constants::CHUNK_SIZE, 0,
                                 position.z * World_Constants::CHUNK_SIZE})
,   m_location      (position)
,   m_p_chunkMap    (&chunkMap)
,   m_p_atlas       (&blockAtlas)
,   m_mesh          (*this)
,   m_blocks        (*this, m_location, *m_p_chunkMap)
,   m_worldGenerator(*this, seed)
,   m_modelMatrix   (Maths::createModelMatrix(*this))
{
    m_worldGenerator.generate();

    m_hasGenBaseBlockData = true;

    loadBlockData (worldName);
    m_blocks.calculateMaxHeights();
    m_blocks.calculateChunkLight();

    m_hasBlockData = true;
}

If you need any more info please let me know.

-Chris

Use setLoop(true)

Why not simply use sf::Music::setLoop(true) instead of using a timer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.