Giter Club home page Giter Club logo

terracraft's Introduction



made-with-python Maintenance GPLv3 license


Goals and Vision

TerraCraft is a small SandBox game engine written in Python 3 + Pyglet.

The objectives of this project are as follows:

  • The intention is to create a small complete game focused exclusively on creative mode.

  • The project must remain simple, well documented (code and wiki) and easy to modify / improve for students and hobbyists. Keeping the code ordered is very important.

  • I would like to see this project turn into an educational tool. Kids love Minecraft and Python is a great first language.

  • This is a good opportunity to entertain children on programming.

  • We are writing a new wiki to help users collaborate on the project in an easy and productive way. If you have questions, suggestions or want to help us, please write to [email protected] or open a discussion here on Github in the "Issues" section.

The code should be well commented and more easily configurable. It should be easy to make some simple changes and see the results quickly.

Thank you all.

🎯 Goals to achieve:


  • ❗ Keep the code ordered, and well commented! realize documentation that is a step by step process for the long-term development of the project. Keep the project easy to understand and simple to change. The wiki is undergoing constant improvement, and will always be updated and improved over time.
  • 💾 Project optimization and reorganization.
  • 🎃 Create dedicated and exclusive textures for TerraCraft.
  • 🎮 A new inventory system, which can be recalled with the "I" key and a configurable hotbar (from a minimum of 8 to a maximum of 15 frames). The current inventory system allows you to select blocks using the keyboard keys 1 to 0, without displaying the active block. Removing the limit of only 10 blocks is one of the priorities of the project.
  • 👾 Improvement of the map generation system, with the possibility of generating the terrain with the Perlin algorithm or a completely flat map. The choice can be made via the game menu when the New World button is activated.
  • 💡 Making a menu at the start of the game, similar to that of Minecraft but with a personal and easily customizable gui.
  • 🎼 Add sound effects and music that can be adjusted and deactivated in game (and from the options menu).

How to Run

sudo pip3 install pyglet
git clone https://github.com/XenonLab-Studio/TerraCraft.git
cd TerraCraft
python3 main.py

Mac

On Mac OS X, you may have an issue with running Pyglet in 64-bit mode. Try running Python in 32-bit mode first:

arch -i386 python3 main.py

If that doesn't work, set Python to run in 32-bit mode by default:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes 

This assumes you are using the OS X default Python. Works on Lion 10.7 with the default Python 3.5+, and may work on other versions too. Please raise an issue if not.

See the wiki for this project to install Python, and other tips.

Controls:

Moving

  • W: forward
  • S: back
  • A: strafe left
  • D: strafe right
  • Mouse: look around
  • Space: jump + vertical flying up
  • Tab: toggle flying mode
  • Left-Shift: vertical flying down
  • Left-Ctrl: run
  • ESC: release mouse, then close window

Building

  • Selecting type of block to create:
    • 1: Dirt
    • 2: Dirt_with_Grass
    • 3: Sand
    • 4: Snow
    • 5: Cobblestone
    • 6: Brick_Cobblestone
    • 7: Brick
    • 8: Tree
    • 9: Leaves
    • 0: Wooden_Planks
    • Mouse left-click: remove block
    • Mouse right-click: create block

Warning! By pressing F12, the previous screenshot is automatically overwritten.

Quitting

  • ESC: release mouse, then close window

License

Copyright (C) 2013 Michael Fogleman
Copyright (C) 2018-2019 Stefano Peris

eMail: [email protected]
Github repository: https://github.com/XenonLab-Studio/TerraCraft

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

This software is licensed under the GPL3 license.

Find a copy of the full license within this project (LICENSE).

terracraft's People

Contributors

benmoran56 avatar einarf avatar trevortomesh avatar vallsv 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

Watchers

 avatar  avatar  avatar  avatar  avatar

terracraft's Issues

time.clock() missing

In python3.8 time.clock() is removed, documentation says it must either be replaced with time.process_time() or time.perf_counter().

Close old issues.

It seems that many of the open issues are already solved, and can be closed.

Vertical flight improvement

Now vertical flight up (space bar "and down (Left-Shift") is possible.

Run mode is now activated with Left-Ctrl.

Reorganization of the code (new modules)

The main.py module has become too big! I want to divide the classes and functions into various modules to make the project more organized and easy to manage.

Add simple lighting (sun), and point light sources (torches, etc.)

This will require writing some simple LightSource classes. OpenGL has a few different types of lights with logs of parameters. It will require a little bit of OpenGL knowledge to write these classes but, once written, will be easy to use to add lights emitting to different things.

Can I use TerraCraft for a project?

Hi,
I found this handsome project a few weeks ago and started messing around with the code.

I found it very useful and I want to work on a project using it as a code base (but I will also rewrite most of the engins)

Is it okay if I use it?

Constant additions to the settings section

All the constants to set the engine parameters are grouped in the "settings" area. This makes the project more orderly and easily configurable, especially in anticipation of a future main menu.

Added vertical flight mode

Add vertical flight capacity, by pressing the following command:

  • Spacebar (up)

This is a very useful feature. PyCraft is a small sandbox game focused exclusively on creative mode, so vertical flight is very convenient for building structures.

We need an application icon

This is important so TerraCraft will show up OK in the taskbar.
An image of 128x128 or so should be good.

New textures

New free textures, directly from my version of "PixelBox", texture pack for Minetest.

screenshot.png

Adding the map save/load system

Added saving and automatic loading of the map. The Save/Load system has the following characteristics:

  • Added saving of the game in progress by pressing the F5 key.
  • Automatic loading at startup, if the file savegame.sav exists.

Need to add sound effects

At some point, we can begin to add sound effects. For a start, we can use a site such as "jfxr" to generate some simple free samples. They can be exported as wav files: https://jfxr.frozenfractal.com/

For playback, the most simple way would be to:

  1. Write a simplified AudioPlayer class, to wrap the pyglet.media.Player class. This class can have play and play_music methods to start.
  2. Each Scene will have a reference to the audio player, so you can do something like: self.audio_player.play('jump.wav')` from any Scene.

This would be very simple and quick to add. To start, maybe we should rename /img to /assets? Then we can organize things into something like /assets/sounds and /assets/images. What do you think?

Allow runtime script control for placing and removing blocks

A suggestion -- a useful feature for education would be to allow students to write code that can add and delete blocks automatically. For example, I would like my students to be able to write a "game of life simulation" within terracraft. Maybe a new class of block -- a "control block"? Something like that?

Add a label when you load the map

It takes time to initially draw all the blocks (initial chunks), so I added a simple "Loading..." label that covers the center of the screen during the first design cycle.

Always better than having an empty screen waiting for the upload :D

In the future I want to create a semitransparent text frame to make the text more readable and visually beautiful (including the import of a new, well-readable pixelated font).

[Idea] Enhancing the SaveManager, and sharing data between scenes.

We will need to enhance the saving/loading features, and also easily share data betwen the different Scenes. I have a plan to do this, but I would like your feedback.

  1. The SceneManager will gain a few dictionaries. This will include an "options" dictionary, containing things such as "fullscreen", "volume levels", etc. This will also include an "inventory" dictionary.
  2. The SceneManager class will have a reference to the SaveManager. This means that all Scenes can access it (because all Scenes already have a reference to self.scene_manager).

In this design, the MenuScene can check the self.scene_manager['options']['fullscreen'] value to see if the game should be full screen. An OptionsScene could be used to set all of these things. When you are playing, you bring up the inventory Scene, and make some actions. The GameScene can see this data when you return to the game.

If it helps, I will make a pull request with the basic design. You can decide if you like it or not. As always, feel free to reject any pull requests you do not like.

Improved label for fps/coordinates information

I have performed the following corrections and improvements to the code:

  • Font size from 18 to 12.
  • Adding text labels (FPS + COORDS).
  • Remove the round brackets, and add the square brackets.
  • Added the ":" of separation.

[Idea] Separate generate_world from scenes.py

It would be really great if we could separate the generate_world call from scenes.py! This would allow students to look at the source code and understand how proc. gen works -- but more importantly, it would allow them to write their own algorithms to generate terrain!

System of saving/loading. Crash of the program with the use of the blocks Tree, Leaves, Wooden_Planks.

Blocks: Dirt, Grass, Snow, Sand, Brick, Badstone, are saved at startup correctly without problems.

the blocks: Tree, Leaves, Wooden_Planks generate an error that causes the program to crash!

I work on the bugfix, I suspect it is a variable that determines the maximum number of blocks? The original Michael Fogleman project only implemented Grass, Sand, Brick, Stone.

I focus on debugging!

WIP...

[proposal] remove "loading" code, and prepare for incremental map loading.

I was thinking that we should remove the "now loading" label from the GameScene. Instead of waiting for the level to be generated, we will want to add incremental loading. This will be important when we try to create larger maps in the future; it won't be practical to wait for the entire map to be generated. Also, when we implement a better generation algorithms, it will be better if we don't have to wait.

Capture a screenshot by pressing F12

Make screenshots by pressing the F12 key.

Warning! Each time F12 is pressed, the previous screenshot is overwritten! I recommend saving each screenshot by adding a number.

Example:

screenshot_01.png

Note: that images can only be saved in the PNG format unless the Pillow library is installed.

Added the setup.py module

I created the setup.py module to include the following information:

from setuptools import setup

setup (
     name = 'TerraCraft',
     version = '0.2.1',
     packages = ['pyglet'], # external packages as dependencies
     url = 'https: //github.com/XenonCoder/TerraCraft',
     license = 'GPL 3.0',
     author = 'Stefano Peris a.k.a. <XenonCoder> ',
     author_email='[email protected] ',
     description = 'Voxel Engine written in Python 3 + Pyglet.'
)

Very important if we want to distribute the project in the future (for example, in the ubuntu repository).

Game will crash when trying to load a corrupted save.

This is a low priority bug, but we should fix it eventually.
Right now, we check if a save exists, and if so, we load it and skip the new map generation.
We should check if the save loads correctly, and then return a True/False result. If this happens, we can then generate a map.

New textures

The old Minecraft textures are not in line with the open source spirit of this project. I have edited new textures that are much more beautiful and free.

I modifed the for loop to go from -10 to 10

I made the following changes:

  • It more apparent and player does not have to change his position to see the
    wall because it is built right in front of player.
  • I Also changed the name of the build wall function from buildWall to build_wall this makes it more consistent with the variables and function names within the game.

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.