stanislavpetrovv / minecraft Goto Github PK
View Code? Open in Web Editor NEWVoxel Engine (like Minecraft) in Python and OpenGL
License: MIT License
Voxel Engine (like Minecraft) in Python and OpenGL
License: MIT License
Error
"C:\Users\#\Game Development\Hellow3DWorld\venv\Scripts\python.exe" "C:\Users\#\Game Development\Hellow3DWorld\h3Dw\main.py"
Traceback (most recent call last):
File "C:\Users\echol\Game Development\Hellow3DWorld\h3Dw\main.py", line 1, in <module>
from settings import *
File "C:\Users\echol\Game Development\Hellow3DWorld\h3Dw\settings.py", line 7, in <module>
WIN_RES = glm.vec2(1600, 900)
^^^^^^^^
AttributeError: module 'glm' has no attribute 'vec2'
Process finished with exit code 1
settings.py:
from numba import njit
import numpy as np
import glm
import math
# resolution
WIN_RES = glm.vec2(1600, 900)
# colors
BG_COLOR = glm.vec3(0.1, 0.16, 0.25)
main.py:
from settings import *
import moderngl as mgl
import pygame as pg
import sys
class VoxelEngine:
def __init__(self):
pg.init()
pg.display.gl_set_attribute(pg.GL_CONTEXT_MAJOR_VERSION, 3)
pg.display.gl_set_attribute(pg.GL_CONTEXT_MINOR_VERSION, 3)
pg.display.gl_set_attribute(pg.GL_CONTEXT_PROFILE_MASK, pg.GL_CONTEXT_PROFILE_CORE)
pg.display.gl_set_attribute(pg.GL_DEPTH_SIZE, 24)
pg.display.set_mode(WIN_RES, flags=pg.OPENGL | pg.DOUBLEBUF)
self.ctx = mgl.create_context()
self.ctx.enable(flags=mgl.DEPTH_TEST | mgl.CULL_FACE | mgl.BLEND)
self.ctx.gc_mode = 'auto'
self.clock = pg.time.Clock()
self.delta_time = 0
self.time = 0
self.is_running = True
def update(self):
self.delta_time = self.clock.tick()
self.time = pg.time.get_ticks() * 0.001
pg.display.set_caption(f'{self.clock.get_fps() :.0f}')
def render(self):
self.ctx.clear(color=BG_COLOR)
pg.display.flip()
def handle_events(self):
for event in pg.event.get():
if event.type == pg.QUIT or (event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE):
self.is_running = False
def run(self):
while self.is_running:
self.handle_events()
self.update()
self.render()
pg.quit()
sys.exit()
if __name__ == '__main__':
app = VoxelEngine()
app.run()
When i delete voxels (inside initial terrain), new faces dont show up. (no issue when if i delete voxels placed by me)
https://drive.google.com/drive/folders/1sio-UjWD9lzcl4VVGHm_423aESX8arjC?usp=sharing
I have all of the packages including opensimplex and they are all upgraded to or higher than the requirements i read in the requirements.txt file but i still get this error: ValueError: Requested OpenGL version 330, got version 310
Here is my code so far:
main.py:
from settings import *
import moderngl as mgl
import pygame as pg
import sys
class VoxelEngine:
def init(self):
pg.init()
pg.display.gl_set_attribute(pg.GL_CONTEXT_MAJOR_VERSION, 3)
pg.display.gl_set_attribute(pg.GL_CONTEXT_MAJOR_VERSION, 3)
pg.display.gl_set_attribute(pg.GL_CONTEXT_PROFILE_MASK, pg.GL_CONTEXT_PROFILE_CORE)
pg.display.gl_set_attribute(pg.GL_DEPTH_SIZE, 24)
pg.display.set_mode(WIN_RES, flags=pg.OPENGL | pg.DOUBLEBUF)
self.ctx = mgl.create_context()
self.ctx.enable(flags=mgl.DEPTH_TEST | mgl.CULL_FACE | mgl.BLEND)
self.ctx.gc_mode = 'auto'
self.clock = pg.time.Clock()
self.delta_time = 0
self.time = 0
self.is_running = True
def update(self):
self.delta_time = self.clock.tick()
self.time = pg.time.get_ticks() * 0.001
pg.display.set_caption(f'{self.clock.get_fps() :.0f}')
def render(self):
self.ctx.clear()
pg.display.flip()
def handle_events(self):
for event in pg.event.get():
if event.type == pg.QUIT or (event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE):
self.is_running = False
def run(self):
while self.is_running:
self.handle_events()
self.update()
self.render()
pg.quit()
sys.exit()
if name == 'main':
app = VoxelEngine()
app.run()
settings:
from numba import njit
import numpy as np
import glm
import math
WIN_RES = glm.vec2(1600,900)
The current requriments.txt
is invalid. The normal opensimplex
module does not work with Numba. Installing opensimplex[numpy]
would fix all problems. Also having the dependencies without their version would have a possibility of incompatible modules being installed and thus the error ...
$ python main.py
pygame 2.1.2 (SDL 2.0.18, Python 3.10.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
pygame==2.5.0
moderngl==5.8.2
numba==0.57.1
PyGLM==2.7.0
numpy<1.25,>=1.21
opensimplex[numpy]==0.4.4
Also I recommend adding a LICENSE file, this tell people what they cant and can do with your code. Currently they are legally not allowed to do anything, so following your video and copying the code would be breaking the law (even if you want them to do so). https://choosealicense.com/ can help you to choose a LICENSE that you want. It is best practice to put a file called LICENSE inside the repository root. Then GitHub will parse the file and label the repository appropriately.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.