Skip to content

hackolite/Craft

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Craft

License: MIT Platform Language

A Minecraft-like voxel game with both C/OpenGL and Python/Pyglet implementations. Features infinite terrain generation, multiplayer support, and modern graphics rendering.

๐ŸŒ Website: http://www.michaelfogleman.com/craft/

Screenshot

๐Ÿš€ Quick Start

Choose your implementation:

C/OpenGL Version (Original) Python Version (Modern Port)
โœ… Full-featured and optimized โœ… Easy to modify and extend
โœ… High performance โœ… Cross-platform Python
โœ… Production ready ๐Ÿšง In active development
๐Ÿ“– Full C Documentation ๐Ÿ“– Python Documentation

๐Ÿ Python Version (Recommended for Development)

# Install dependencies pip install pyglet numpy pillow # Run the game python3 craft.py

โšก C Version (Recommended for Performance)

# Install dependencies (see detailed instructions below) # Then build and run: git clone https://github.com/hackolite/Craft.git cd Craft cmake . make ./craft

๐Ÿ“‹ Table of Contents

โœจ Features

๐ŸŒ World Generation

  • Infinite terrain using Perlin/Simplex noise algorithms
  • Chunk-based loading (32x32 blocks) for optimal performance
  • 10+ block types with easy extensibility
  • Natural structures: grass, flowers, trees, and landscapes

๐ŸŽฎ Gameplay

  • Building & destruction with left/right click mechanics
  • Flying and walking modes with realistic physics
  • Day/night cycles with dynamic lighting
  • Transparent blocks (glass) and natural plants
  • World persistence via SQLite3 database

๐ŸŒ Multiplayer

  • Client-server architecture with Python server
  • Real-time synchronization of player actions
  • Chat system with commands
  • Player observation modes (main view + picture-in-picture)

๐ŸŽจ Graphics

  • Modern OpenGL with vertex/fragment shaders
  • Ambient occlusion for realistic lighting
  • Textured sky dome with time-based transitions
  • Frustum culling and optimization for smooth performance

๐Ÿ› ๏ธ Implementations

This repository contains two complete implementations of the Craft game:

C Implementation (Original)

  • Language: C99 with OpenGL
  • Performance: Highly optimized, production-ready
  • Features: Complete feature set, mature codebase
  • Best for: Playing the game, high-performance needs
  • Location: src/ directory, built with CMake

Python Implementation (Modern Port)

  • Language: Python 3.7+ with Pyglet
  • Performance: Good performance, easier to modify
  • Features: Core features implemented, actively developed
  • Best for: Learning, modding, experimentation
  • Location: craft*.py files
  • Documentation: README_PYTHON.md

Both implementations are compatible with the same:

  • ๐Ÿ—บ๏ธ World save format
  • ๐ŸŒ Multiplayer server
  • ๐ŸŽจ Texture assets
  • ๐ŸŽฎ Game mechanics

๐Ÿ’ป Installation

C Implementation

Dependencies needed:

  • CMake 2.8+
  • OpenGL development libraries
  • CURL development libraries

๐ŸŽ macOS

# Using Homebrew (recommended) brew install cmake # Or download from: http://www.cmake.org/cmake/resources/software.html

๐Ÿง Linux (Ubuntu/Debian)

sudo apt-get update sudo apt-get install cmake libglew-dev xorg-dev libcurl4-openssl-dev sudo apt-get build-dep glfw

๐ŸชŸ Windows

  1. Install dependencies:

    • Download and install CMake
    • Download and install MinGW
    • Add C:\MinGW\bin to your PATH
    • Download cURL so that CURL/lib and CURL/include are in your Program Files
  2. Build with MinGW:

    cmake -G "MinGW Makefiles" mingw32-make

๐Ÿ”จ Build and Run (All Platforms)

git clone https://github.com/hackolite/Craft.git cd Craft cmake . make ./craft

Python Implementation

Requirements:

  • Python 3.7+
  • Pyglet 2.0+
  • NumPy
  • Pillow

๐Ÿ“ฆ Installation

# Install Python dependencies pip install pyglet numpy pillow # Clone repository (if not already done) git clone https://github.com/hackolite/Craft.git cd Craft # Run Python version python3 craft.py # Or test modules python3 launcher.py test

๐Ÿ“š Detailed Python Documentation: See README_PYTHON.md for complete Python implementation details.

๐ŸŒ Multiplayer

Note: The original craft.michaelfogleman.com server has been taken down. You'll need to run your own server for multiplayer.

๐Ÿ–ฅ๏ธ Server Setup

Compile the world generation library:

gcc -std=c99 -O3 -fPIC -shared -o world -I src -I deps/noise deps/noise/noise.c src/world.c

Run the Python server:

python server.py [HOST [PORT]]

๐ŸŽฎ Client Connection

Command line:

./craft [HOST [PORT]]

In-game command:

/online [HOST [PORT]] 

๐ŸŽฎ Controls

๐Ÿšถ Movement

Key Action
WASD Move forward, left, backward, right
Space Jump
Tab Toggle between walking and flying
ZXCVBN Move in exact XYZ directions

๐Ÿ”จ Building

Key Action
Left Click Destroy block
Right Click Create block (or Cmd + Left Click on Mac)
Ctrl + Right Click Toggle block as light source
1-9 Select block type to create
E Cycle through block types

๐Ÿ“ท Camera & View

Key Action
Mouse Look around
Left Shift Zoom
F Orthographic mode
O Observe players in main view
P Observe players in picture-in-picture
Arrow Keys Emulate mouse movement
Enter Emulate mouse click

๐Ÿ’ฌ Communication

Key Action
T Type into chat
/ Enter command
` Write text on blocks (signs)

๐Ÿ’ฌ Chat Commands

Command Description
/goto [NAME] Teleport to another user (random if NAME unspecified)
/list Display connected users
/login NAME Switch to registered username (case-sensitive)
/logout Become guest user
/offline [FILE] Switch to offline mode (default save: "craft")
/online HOST [PORT] Connect to specified server
/pq P Q Teleport to specified chunk coordinates
/spawn Return to spawn point

๐Ÿ“ธ Screenshots

Main Screenshot

๐Ÿ”ง Technical Implementation

๐ŸŒ World Generation

  • Algorithm: Simplex noise for deterministic, position-based terrain
  • Architecture: 32x32 block chunks with XZ plane organization
  • Persistence: SQLite3 database stores only player modifications (delta)
  • Optimization: Only exposed block faces are rendered

๐ŸŽจ Rendering Engine

  • API: Modern OpenGL with vertex/fragment shaders
  • Performance: Frustum culling, VBO optimization
  • Effects: Ambient occlusion, transparency, sky dome texturing
  • Text: Bitmap atlas rendering on 2D rectangles

๐ŸŒ Networking Protocol

  • Transport: Plain TCP sockets with ASCII line-based protocol
  • Synchronization: Real-time player positions, block updates, chat
  • Caching: Client-side chunk caching with delta updates
  • Performance: Background SQLite writes, transaction batching

๐Ÿ—ƒ๏ธ Dependencies

C Implementation:

  • GLEW - OpenGL extension management
  • GLFW - Cross-platform window management
  • CURL - HTTPS/SSL for authentication
  • lodepng - PNG texture loading
  • sqlite3 - World persistence
  • tinycthread - Cross-platform threading

Python Implementation:

  • Pyglet - OpenGL graphics and windowing
  • NumPy - Mathematical operations
  • Pillow - Image processing

๐Ÿค Contributing

๐Ÿ”ง Development Setup

  1. Fork the repository
  2. Clone your fork
  3. Test both implementations:
    # Test C build cmake . && make # Test Python modules  python3 launcher.py test

๐Ÿ“ Guidelines

  • ๐ŸŽฏ Focus on minimal changes for maximum compatibility
  • ๐Ÿงช Test both C and Python implementations when possible
  • ๐Ÿ“š Update documentation for any new features
  • ๐Ÿ”„ Maintain compatibility between implementations

๐Ÿ› Issues & Features

  • ๐Ÿ› Bug reports: Please include OS, implementation (C/Python), and steps to reproduce
  • โœจ Feature requests: Consider implementation in both C and Python versions
  • ๐Ÿค Pull requests: Test thoroughly and update relevant documentation

๐Ÿ“„ License

Licensed under the MIT License - see LICENSE.md for details.

Copyright (C) 2013 Michael Fogleman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software... 

๐Ÿ™ Credits

Original Author: Michael Fogleman
Python Port: Community contributions
Inspiration: Minecraft by Mojang Studios


๐Ÿ“š Additional Resources

โญ Star this repository if you found it useful!

About

A simple Minecraft clone written in C using modern OpenGL (shaders).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 61.3%
  • Python 37.1%
  • GLSL 1.2%
  • CMake 0.4%