Giter VIP home page Giter VIP logo

blockgame's Introduction

BlockGame

Prototype of a Voxelgame with C++ and OpenGL.

Disclaimer

This Project is still under construction and might not work stable. The Licence (and Licences of used Dependecies) will be added soon


Dependencies

glew, glm, SDL2, freetype


Instaltion

Linux

Ubuntu

following dependencies need to be installed:

dependency installation (apt-get)
GLEW: sudo apt-get install libglew-dev
glm: sudo apt-get install libglm-dev
SDL2: sudo apt-get install libsdl2-dev
freetype: sudo apt-get install libfreetype6-dev

Building
To build the Project (with g++), simply execute the buildLinux bash script.
If the compilation was sucessfull the executable game will be at build/mainLinux.
To run the game, the corresponding dynamic librarys of the dependencies are necessaray (the commands above should install these correctly)

Windows (Still Work in Progress)

following dependencies need to be installed:

dependency
(development Version)
download link
GLEW: http://glew.sourceforge.net/
glm: https://glm.g-truc.net/0.9.9/
SDL2: https://libsdl.org/download-2.0.php
freetype: https://freetype.org/download.html

Building
The buildWindows.sh script can be used to build the Game for Windows. All Dependecies must be located in the libs\ directory. It's important that all folders have the same names as in the script.
The file .vscode\tasks.json can be used in VSCode for the compilation.
To run the game, the DLLs of the dependencies are necessaray (SDL2.dll, glew32.dll, freetype.dll). For windows they are aleady locted in the build directory.

MacOS (Work in Progress)

coming soon

Building
coming soon


The development of this Project has started around 20.09.2021.

blockgame's People

Contributors

lolbaum avatar

Stargazers

 avatar  avatar Felix Lerch avatar

Watchers

 avatar

blockgame's Issues

Fix Texutebleeding

At ceratain agnles white stripes occour at the edges of blocks. They are nor visible all the time but still annoying.

Rendering Text more efficient

When dispaling around 10 lines of text, the game already has framedrops and wont run smothly.
The RenderText() function is very inefficient (it's still based on the Tutorial from learnopengl). For every character aney quad is created and directly send to OpenGL via glDrawArrays().
It would propably be more efficient to store the vertices in a vector and preloading the capacity so it doesn't need to be reallocated so often and then dawing all quads at once. Additionally a monospace Font could be used so the quad wont need to be recalculated each time.
Another idea is to create one inctance of each ASCII character and then using GLs instancing functionality to display the text.

Clean up

  • Removing old Comments,
  • changing Filenames from .h to .hpp

Improve README

  • Simple installation Guide (Win, Linux, MacOS)
  • Move details e.g. manual installation of dependencies to a Wiki (?)
  • add table of contents
  • add screenshot form the game

could use Craft and MineTest as reference

What is a suitable licence for this Project?

It doesn't really matter, but I think I still want to add one to this Project.
It should be free to use and distribute for everyone, as long as they credit this Project.

Maybe GLP or MIT would be right. But I don't know much about licences... Well I gonna do that later

Refactoring to create a simple Build Process

Currently the code and the libraries are a Mess. That's why the Structure and Building Process of this Project should be changed so it's easy to complile it on different Operating Systems.

  • specify the used Dependencis and where they can be downloaded.
  • add the compliation Command
  • add a MAKE File
  • Use Variables vor the Include directories
  • Test the Building Process on Windows without IDE
  • Test the Building Process on Linux
  • add the Licences for the used Libraries

Valgrind: Conditional jump or move depends on uninitialised value(s)

==28010== Conditional jump or move depends on uninitialised value(s)
==28010== at 0x188900: createDir_IfDoesNotExist(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x168B3E: SuperChunk::initialize() (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x14C9DB: main_function() (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x14E7D5: main (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== Uninitialised value was created by a stack allocation
==28010== at 0x188866: isDir(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (in /home/baum/fun/BlockGame/build/mainLinux)

==28010== Conditional jump or move depends on uninitialised value(s)
==28010== at 0x155A02: bool glm::operator==<float, (glm::qualifier)0>(glm::vec<3, float, (glm::qualifier)0> const&, glm::vec<3, float, (glm::qualifier)0> const&) (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x154AA4: bool glm::operator!=<float, (glm::qualifier)0>(glm::vec<3, float, (glm::qualifier)0> const&, glm::vec<3, float, (glm::qualifier)0> const&) (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x150F11: LocalPlayer::update() (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x150BED: LocalPlayer::LocalPlayer() (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x14C9EA: main_function() (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== by 0x14E7D5: main (in /home/baum/fun/BlockGame/build/mainLinux)
==28010== Uninitialised value was created by a stack allocation
==28010== at 0x14C0EB: main_function() (in /home/baum/fun/BlockGame/build/mainLinux)

Add Callbacks for changing settings

If I want to change the settings (config.json), I need to close and restart the game.

So to reload the settings (including the window size) at runtime, I'll need to add a callback to every game component that uses the config.

  • Add reload function
  • callback for simple config stuff e.g. Fov
  • Callback for window size

Using The BlockTypeManager

Currently the blocks / textures are hard coded in serveral Places. These Values should be replaced with a call of a functon of the BloackTypeManager. All Chunks consits of Blocks, which have an int as BlockType. This BlockTypeInt should then be passed to the BTM and return requested information about this Bloacktype eg. texture, opacity, hardness, ect.

  • add Texture class
  • add BlockTexture classes (standard and special)
  • all parameters of the BlockType can be set on creation
  • creating the BlockMesh by using the BlockTypes
  • Load Types from Json-files?

[Linux] Bug: Items have incorrect texture

on branch strange-linux-issue I fixed a bug that made the game crash on my Ubuntu 22.04.3 laptop.
now the Textures of the Items in the Inventory bar are not displayed correctly. It looks like the UV coords are either 0 or y has a random value. y changes when moving.
the StandaradBlockTextures of the BlockItemTypes are initialised correctly at first, but are overwritten later...

Adding a Sky

Currently the 'sky' is just a solid background color (the GL clear color of the color buffer). Thats pretty boring. It would be much cooler if there were moving clouds. Usually this is solved with a Cubemap, but that would be hard for a dynamic environment. My Idea is to add a skybox and use a shader with something like raymarching on it to calculate the clouds on the fly.

For the shader is plenty of reference on Shadertoy.com

  • adding a sky shader
  • fast and fancy sky (fancy should have nice clouds, while fast should result in better performance)
  • adding clouds
  • adding sun cycles

Add Gravity / Use Velocity for movement

Currently the Players Position is directly changed when moving. If a general Player Velocity was Used it will be easier tho add gravity and other forces.

  • Gravity
  • Velocity based Movement
  • add inertia to Movement
  • Clean up: Move funtion ect.

Adding an InputHandler

Currently all user Input will be treat the same way while the whole time the program is running. At the moment that's no problem because the player is always in the same sate - he's moving around removing or placing Blocks with a click and selecting them with the Numbers 1...9.
But for further features Like an interactive inventory GUI or a chat new states of input need to be added.
That's why an InputHandler should be implemented, which forwards the user input to the correct Component (PlayerContoller, Inventory Drag n Drop, Chat, ect.) depending on the input state.

  • general abstraction for input handling
  • using input for the chat

Compile with CMake

  • Add CMake File
  • Use FetchContent to get the dependencies (?)
  • Test it with CLion
  • Test it on different OS (Win 10/11, Linux: Ubuntu ...)
  • add documentation for that (#20)

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.