I made this code (Its in python)

Sort:
Avatar of crystal0192

nothing really

Avatar of crystal0192

just practice

Avatar of Thruul_Mcgon

Try to make 2d minecraft frfr

Avatar of Thruul_Mcgon

I don't think I could tbh, as a python user.

Avatar of ZacharyQuack6

That's really good i enjoyed it!

Avatar of StudiosPlaysChess

from __future__ import division

import sys
import math
import random
import time

from collections import deque
from pyglet import image
from import *
from import TextureGroup
from import key, mouse

from noise_gen import NoiseGen

TICKS_PER_SEC = 60

# Size of sectors used to ease block loading.
SECTOR_SIZE = 16

# Movement variables
WALKING_SPEED = 5
FLYING_SPEED = 15
CROUCH_SPEED = 2
SPRINT_SPEED = 7
SPRINT_FOV = SPRINT_SPEED / 2

GRAVITY =
MAX_JUMP_HEIGHT = # About the height of a block.
# To derive the formula for calculating jump speed, first solve
# v_t = v_0 + a * t
# for the time at which you achieve maximum height, where a is the acceleration
# due to gravity and v_t = 0. This gives:
# t = - v_0 / a
# Use t and the desired MAX_JUMP_HEIGHT to solve for v_0 (jump speed) in
# s = s_0 + v_0 * t + (a * t^2) / 2
JUMP_SPEED = (2 * GRAVITY * MAX_JUMP_HEIGHT)
TERMINAL_VELOCITY = 50

# Player variables
PLAYER_HEIGHT = 2
PLAYER_FOV =

if [0] >= 3:
xrange = range

def cube_vertices(x, y, z, n):
""" Return the vertices of the cube at position x, y, z with size 2*n.

"""
return [
x-n,y+n,z-n, x-n,y+n,z+n, x+n,y+n,z+n, x+n,y+n,z-n, # top
x-n,y-n,z-n, x+n,y-n,z-n, x+n,y-n,z+n, x-n,y-n,z+n, # bottom
x-n,y-n,z-n, x-n,y-n,z+n, x-n,y+n,z+n, x-n,y+n,z-n, # left
x+n,y-n,z+n, x+n,y-n,z-n, x+n,y+n,z-n, x+n,y+n,z+n, # right
x-n,y-n,z+n, x+n,y-n,z+n, x+n,y+n,z+n, x-n,y+n,z+n, # front
x+n,y-n,z-n, x-n,y-n,z-n, x-n,y+n,z-n, x+n,y+n,z-n, # back
]

def tex_coord(x, y, n=4):
""" Return the bounding vertices of the texture square.

"""
m = / n
dx = x * m
dy = y * m
return dx, dy, dx + m, dy, dx + m, dy + m, dx, dy + m

def tex_coords(top, bottom, side):
""" Return a list of the texture squares for the top, bottom and side.

"""
top = tex_coord(*top)
bottom = tex_coord(*bottom)
side = tex_coord(*side)
result = []
(top)
(bottom)
(side * 4)
return result

TEXTURE_PATH = ''

GRASS = tex_coords((1, 0), (0, 1), (0, 0))
SAND = tex_coords((1, 1), (1, 1), (1, 1))
BRICK = tex_coords((2, 0), (2, 0), (2, 0))
STONE = tex_coords((2, 1), (2, 1), (2, 1))
WOOD = tex_coords((3, 1), (3, 1), (3, 1))
LEAF = tex_coords((3, 0), (3, 0), (3, 0))
WATER = tex_coords((0, 2), (0, 2), (0, 2))

FACES = [
( 0, 1, 0),
( 0,-1, 0),
(-1, 0, 0),
( 1, 0, 0),
( 0, 0, 1),
( 0, 0,-1),
]

def normalize(position):
""" Accepts `position` of arbitrary precision and returns the block
containing that position.

Parameters
----------
position : tuple of len 3

Returns
-------
block_position : tuple of ints of len 3

"""
x, y, z = position
x, y, z = (int(round(x)), int(round(y)), int(round(z)))
return (x, y, z)

def sectorize(position):
""" Returns a tuple representing the sector for the given `position`.

Parameters
----------
position : tuple of len 3

Returns
-------
sector : tuple of len 3

"""
x, y, z = normalize(position)
x, y, z = x // SECTOR_SIZE, y // SECTOR_SIZE, z // SECTOR_SIZE
return (x, 0, z)

class Model(object):

def __init__(self):

# A Batch is a collection of vertex lists for batched rendering.
= .Batch()

# A TextureGroup manages an OpenGL texture.
= TextureGroup((TEXTURE_PATH).get_texture())

# A mapping from position to the texture of the block at that position.
# This defines all the blocks that are currently in the world.
= {}

# Same mapping as `world` but only contains blocks that are shown.
= {}

# Mapping from position to a pyglet `VertextList` for all shown blocks.
= {}

# Mapping from sector to a list of positions inside that sector.
= {}

# Simple function queue implementation. The queue is populated with
# _show_block() and _hide_block() calls
= deque()

()

def _initialize(self):
""" Initialize the world by placing all the blocks.

"""
gen = NoiseGen(452692)

n = 128 #size of the world
s = 1 # step size
y = 0 # initial y height

#too lazy to do this properly lol
heightMap = []
for x in xrange(0, n, s):
for z in xrange(0, n, s):
heightMap.append(0)
for x in xrange(0, n, s):
for z in xrange(0, n, s):
heightMap[z + x * n] = int(gen.getHeight(x, z))

#Generate the world
for x in xrange(0, n, s):
for z in xrange(0, n, s):
h = heightMap[z + x * n]
if (h < 15):
((x, h, z), SAND, immediate=False)
for y in range (h, 15):
((x, y, z), WATER, immediate=False)
continue
if (h < 18):
((x, h, z), SAND, immediate=False)
((x, h, z), GRASS, immediate=False)
for y in xrange(h - 1, 0, -1):
((x, y, z), STONE, immediate=False)
#Maybe add tree at this (x, z)
if (h > 20):
if (0, 1000) > 990:
treeHeight = (5, 7)
#Tree trunk
for y in xrange(h + 1, h + treeHeight):
((x, y, z), WOOD, immediate=False)
#Tree leaves
leafh = h + treeHeight
for lz in xrange(z + -2, z + 3):
for lx in xrange(x + -2, x + 3):
for ly in xrange(3):
((lx, leafh + ly, lz), LEAF, immediate=False)

def hit_test(self, position, vector, max_distance=8):
""" Line of sight search from current position. If a block is
intersected it is returned, along with the block previously in the line
of sight. If no block is found, return None, None.

Parameters
----------
position : tuple of len 3
The (x, y, z) position to check visibility from.
vector : tuple of len 3
The line of sight vector.
max_distance : int
How many blocks away to search for a hit.

"""
m = 8
x, y, z = position
dx, dy, dz = vector
previous = None
for _ in xrange(max_distance * m):
key = normalize((x, y, z))
if key != previous and key in :
return key, previous
previous = key
x, y, z = x + dx / m, y + dy / m, z + dz / m
return None, None

def exposed(self, position):
""" Returns False is given `position` is surrounded on all 6 sides by
blocks, True otherwise.

"""
x, y, z = position
for dx, dy, dz in FACES:
if (x + dx, y + dy, z + dz) not in :
return True
return False

def add_block(self, position, texture, immediate=True):
""" Add a block with the given `texture` and `position` to the world.

Parameters
----------
position : tuple of len 3
The (x, y, z) position of the block to add.
texture : list of len 3
The coordinates of the texture squares. Use `tex_coords()` to
generate.
immediate : bool
Whether or not to draw the block immediately.

"""
if position in :
(position, immediate)
[position] = texture
.setdefault(sectorize(position), []).append(position)
if immediate:
if (position):
(position)
(position)

def remove_block(self, position, immediate=True):
""" Remove the block at the given `position`.

Parameters
----------
position : tuple of len 3
The (x, y, z) position of the block to remove.
immediate : bool
Whether or not to immediately remove block from canvas.

"""
del [position]
[sectorize(position)].remove(position)
if immediate:
if position in :
(position)
(position)

def check_neighbors(self, position):
""" Check all blocks surrounding `position` and ensure their visual
state is current. This means hiding blocks that are not exposed and
ensuring that all exposed blocks are shown. Usually used after a block
is added or removed.

"""
x, y, z = position
for dx, dy, dz in FACES:
key = (x + dx, y + dy, z + dz)
if key not in :
continue
if (key):
if key not in :
(key)
else:
if key in :
(key)

def show_block(self, position, immediate=True):
""" Show the block at the given `position`. This method assumes the
block has already been added with add_block()

Parameters
----------
position : tuple of len 3
The (x, y, z) position of the block to show.
immediate : bool
Whether or not to show the block immediately.

"""
texture = [position]
[position] = texture
if immediate:
(position, texture)
else:
(, position, texture)

def _show_block(self, position, texture):
""" Private implementation of the `show_block()` method.

Parameters
----------
position : tuple of len 3
The (x, y, z) position of the block to show.
texture : list of len 3
The coordinates of the texture squares. Use `tex_coords()` to
generate.

"""
x, y, z = position
vertex_data = cube_vertices(x, y, z, )
texture_data = list(texture)
# create vertex list
# FIXME Maybe `add_indexed()` should be used instead
[position] = .add(24, GL_QUADS, ,
('v3f/static', vertex_data),
('t2f/static', texture_data))

def hide_block(self, position, immediate=True):
""" Hide the block at the given `position`. Hiding does not remove the
block from the world.

Parameters
----------
position : tuple of len 3
The (x, y, z) position of the block to hide.
immediate : bool
Whether or not to immediately remove the block from the canvas.

"""
.pop(position)
if immediate:
(position)
else:
(, position)

def _hide_block(self, position):
""" Private implementation of the 'hide_block()` method.

"""
.pop(position).delete()

def show_sector(self, sector):
""" Ensure all blocks in the given sector that should be shown are
drawn to the canvas.

"""
for position in .get(sector, []):
if position not in and (position):
(position, False)

def hide_sector(self, sector):
""" Ensure all blocks in the given sector that should be hidden are
removed from the canvas.

"""
for position in .get(sector, []):
if position in :
(position, False)

def change_sectors(self, before, after):
""" Move from sector `before` to sector `after`. A sector is a
contiguous x, y sub-region of world. Sectors are used to speed up
world rendering.

"""
before_set = set()
after_set = set()
pad = 4
for dx in xrange(-pad, pad + 1):
for dy in [0]: # xrange(-pad, pad + 1):
for dz in xrange(-pad, pad + 1):
if dx ** 2 + dy ** 2 + dz ** 2 > (pad + 1) ** 2:
continue
if before:
x, y, z = before
((x + dx, y + dy, z + dz))
if after:
x, y, z = after
((x + dx, y + dy, z + dz))
show = after_set - before_set
hide = before_set - after_set
for sector in show:
(sector)
for sector in hide:
(sector)

def _enqueue(self, func, *args):
""" Add `func` to the internal queue.

"""
.append((func, args))

def _dequeue(self):
""" Pop the top function from the internal queue and call it.

"""
func, args = .popleft()
func(*args)

def process_queue(self):
""" Process the entire queue while taking periodic breaks. This allows
the game loop to run smoothly. The queue contains calls to
_show_block() and _hide_block() so this method should be called if
add_block() or remove_block() was called with immediate=False

"""
start = ()
while and () - start < / TICKS_PER_SEC:
()

def process_entire_queue(self):
""" Process the entire queue with no breaks.

"""
while :
()

class Window(pyglet.Window):

def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)

# Whether or not the window exclusively captures the mouse.
= False

# When flying gravity has no effect and speed is increased.
= False

# Used for constant jumping. If the space bar is held down,
# this is true, otherwise, it's false
= False

# If the player actually jumped, this is true
= False

# If this is true, a crouch offset is added to the final glTranslate
= False

# Player sprint
= False

# This is an offset value so stuff like speed potions can also be easily added
= 0

= {"top": False, "bottom": False, "right": False, "left": False}

# Strafing is moving lateral to the direction you are facing,
# . moving to the left or right while continuing to face forward.
#
# First element is -1 when moving forward, 1 when moving back, and 0
# otherwise. The second element is -1 when moving left, 1 when moving
# right, and 0 otherwise.
= [0, 0]

# Current (x, y, z) position in the world, specified with floats. Note
# that, perhaps unlike in math class, the y-axis is the vertical axis.
= (30, 50, 80)

# First element is rotation of the player in the x-z plane (ground
# plane) measured from the z-axis down. The second is the rotation
# angle from the ground plane up. Rotation is in degrees.
#
# The vertical plane rotation ranges from -90 (looking straight down) to
# 90 (looking straight up). The horizontal rotation range is unbounded.
= (0, 0)

# Which sector the player is currently in.
= None

# The crosshairs at the center of the screen.
= None

# Velocity in the y (upward) direction.
= 0

# A list of blocks the player can place. Hit num keys to cycle.
= [BRICK, GRASS, SAND, WOOD, LEAF]

# The current block the user can place. Hit num keys to cycle.
= [0]

# Convenience list of num keys.
= [
, , , , ,
, , , , ]

# Instance of the model that handles the world.
= Model()

# The label that is displayed in the top left of the canvas.
= pyglet.text.Label('', font_name='Arial', font_size=18,
x=10, y= - 10, anchor_x='left', anchor_y='top',
color=(0, 0, 0, 255))

# This call schedules the `update()` method to be called
# TICKS_PER_SEC. This is the main game event loop.
(, / TICKS_PER_SEC)

def set_exclusive_mouse(self, exclusive):
""" If `exclusive` is True, the game will capture the mouse, if False
the game will ignore the mouse.

"""
super(Window, self).set_exclusive_mouse(exclusive)
= exclusive

def get_sight_vector(self):
""" Returns the current line of sight vector indicating the direction
the player is looking.

"""
x, y =
# y ranges from -90 to 90, or -pi/2 to pi/2, so m ranges from 0 to 1 and
# is 1 when looking ahead parallel to the ground and 0 when looking
# straight up or down.
m = ((y))
# dy ranges from -1 to 1 and is -1 when looking straight down and 1 when
# looking straight up.
dy = ((y))
dx = ((x - 90)) * m
dz = ((x - 90)) * m
return (dx, dy, dz)

def get_motion_vector(self):
""" Returns the current motion vector indicating the velocity of the
player.

Returns
-------
vector : tuple of len 3
Tuple containing the velocity in x, y, and z respectively.

"""
if any():
x, y =
strafe = ((*))
y_angle = (y)
x_angle = (x + strafe)
if :
m = (y_angle)
dy = (y_angle)
if [1]:
# Moving left or right.
dy =
m = 1
if [0] > 0:
# Moving backwards.
dy *= -1
# When you are flying up or down, you have less left and right
# motion.
dx = (x_angle) * m
dz = (x_angle) * m
else:
dy =
dx = (x_angle)
dz = (x_angle)
else:
dy =
dx =
dz =
return (dx, dy, dz)

def update(self, dt):
""" This method is scheduled to be called repeatedly by the pyglet
clock.

Parameters
----------
dt : float
The change in time since the last call.

"""
.process_queue()
sector = sectorize()
if sector != :
.change_sectors(, sector)
if is None:
.process_entire_queue()
= sector
m = 8
dt = min(dt, )
for _ in xrange(m):
(dt / m)

def _update(self, dt):
""" Private implementation of the `update()` method. This is where most
of the motion logic lives, along with gravity and collision detection.

Parameters
----------
dt : float
The change in time since the last call.

"""
# walking
if :
speed = FLYING_SPEED
elif :
speed = SPRINT_SPEED
elif :
speed = CROUCH_SPEED
else:
speed = WALKING_SPEED

if :
if ["top"]:
= JUMP_SPEED
= True
else:
if ["top"]:
= False
if :
speed +=

d = dt * speed # distance covered this tick.
dx, dy, dz = ()
# New position in space, before accounting for gravity.
dx, dy, dz = dx * d, dy * d, dz * d
# gravity
if not :
# Update your vertical speed: if you are falling, speed up until you
# hit terminal velocity; if you are jumping, slow down until you
# start falling.
-= dt * GRAVITY
= max(, -TERMINAL_VELOCITY)
dy += * dt
# collisions
old_pos =
x, y, z = old_pos
x, y, z = ((x + dx, y + dy, z + dz), PLAYER_HEIGHT)
= (x, y, z)

# Sptinting stuff. If the player stops moving in the x and z direction, the player stops sprinting
# and the sprint fov is subtracted from the fov offset
if old_pos[0]-[0] == 0 and old_pos[2]-[2] == 0:
disablefov = False
if :
disablefov = True
= False
if disablefov:
-= SPRINT_FOV

def collide(self, position, height):
""" Checks to see if the player at the given `position` and `height`
is colliding with any blocks in the world.

Parameters
----------
position : tuple of len 3
The (x, y, z) position to check for collisions at.
height : int or float
The height of the player.

Returns
-------
position : tuple of len 3
The new position of the player taking into account collisions.

"""
# How much overlap with a dimension of a surrounding block you need to
# have to count as a collision. If 0, touching terrain at all counts as
# a collision. If .49, you sink into the ground, as if walking through
# tall grass. If >= .5, you'll fall through the ground.
pad = 5
p = list(position)
np = normalize(position)
= {"top":False,"bottom":False,"right":False,"left":False}
for face in FACES: # check all surrounding blocks
for i in xrange(3): # check each dimension independently
if not face[i]:
continue
# How much overlap you have with this dimension.
d = (p[i] - np[i]) * face[i]
if d < pad:
continue
for dy in xrange(height): # check each height
op = list(np)
op[1] -= dy
op[i] += face[i]
if tuple(op) not in .world:
continue
p[i] -= (d - pad) * face[i]
# If you are colliding with the ground or ceiling, stop
# falling / rising.
if face == (0, -1, 0):
["top"] = True
= 0
if face == (0, 1, 0):
["bottom"] = True
= 0
break
return tuple(p)

def on_mouse_press(self, x, y, button, modifiers):
""" Called when a mouse button is pressed. See pyglet docs for button
amd modifier mappings.

Parameters
----------
x, y : int
The coordinates of the mouse click. Always center of the screen if
the mouse is captured.
button : int
Number representing mouse button that was clicked. 1 = left button,
4 = right button.
modifiers : int
Number representing any modifying keys that were pressed when the
mouse button was clicked.

"""
if :
vector = ()
block, previous = .hit_test(, vector)
if (button == mouse.RIGHT) or \
((button == mouse.LEFT) and (modifiers & key.MOD_CTRL)):
# ON OSX, control + left click = right click.
if previous:
.add_block(previous, )
elif button == pyglet.mouse.LEFT and block:
texture = .world[block]
if texture != STONE:
.remove_block(block)
else:
(True)

def on_mouse_motion(self, x, y, dx, dy):
""" Called when the player moves the mouse.

Parameters
----------
x, y : int
The coordinates of the mouse click. Always center of the screen if
the mouse is captured.
dx, dy : float
The movement of the mouse.

"""
if :
m =
x, y =
x, y = x + dx * m, y + dy * m
y = max(-90, min(90, y))
= (x, y)

def on_key_press(self, symbol, modifiers):
""" Called when the player presses a key. See pyglet docs for key
mappings.

Parameters
----------
symbol : int
Number representing the key that was pressed.
modifiers : int
Number representing any modifying keys that were pressed.

"""
if symbol == key.W:
[0] -= 1
elif symbol == key.S:
[0] += 1
elif symbol == key.A:
[1] -= 1
elif symbol == key.D:
[1] += 1
elif symbol == key.C:
-= 6
elif symbol == key.SPACE:
= True
elif symbol == key.ESCAPE:
(False)
elif symbol == key.LSHIFT:
= True
if :
-= SPRINT_FOV
= False
elif symbol == key.R:
if not :
if not :
+= SPRINT_FOV
= True
elif symbol == key.TAB:
= not
elif symbol in :
index = (symbol - [0]) % len()
= [index]

def on_key_release(self, symbol, modifiers):
""" Called when the player releases a key. See pyglet docs for key
mappings.

Parameters
----------
symbol : int
Number representing the key that was pressed.
modifiers : int
Number representing any modifying keys that were pressed.

"""
if symbol == key.W:
[0] += 1
elif symbol == key.S:
[0] -= 1
elif symbol == key.A:
[1] += 1
elif symbol == key.D:
[1] -= 1
elif symbol == key.SPACE:
= False
elif symbol == key.LSHIFT:
= False
elif symbol == key.C:
+= 6

def on_resize(self, width, height):
""" Called when the window is resized to a new `width` and `height`.

"""
# label
.y = height - 10
# reticle
if :
.delete()
x, y = // 2, // 2
n = 10
= .vertex_list(4,
('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))
)

def set_2d(self):
""" Configure OpenGL to draw in 2d.

"""
width, height = ()
glDisable(GL_DEPTH_TEST)
viewport = ()
glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1]))
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0, max(1, width), 0, max(1, height), -1, 1)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

def set_3d(self):
""" Configure OpenGL to draw in 3d.

"""
width, height = ()
glEnable(GL_DEPTH_TEST)
viewport = ()
glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1]))
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(PLAYER_FOV + , width / float(height), , 6)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
x, y =
glRotatef(x, 0, 1, 0)
glRotatef(-y, ((x)), 0, ((x)))
x, y, z =
if :
glTranslatef(-x, -y+, -z)
else:
glTranslatef(-x, -y, -z)

def on_draw(self):
""" Called by pyglet to draw the canvas.

"""
()
()
glColor3d(1, 1, 1)
.()
()
()
()
()

def draw_focused_block(self):
""" Draw black edges around the block that is currently under the
crosshairs.

"""
vector = ()
block = .hit_test(, vector)[0]
if block:
x, y, z = block
vertex_data = cube_vertices(x, y, z, 1)
glColor3d(0, 0, 0)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
.draw(24, GL_QUADS, ('v3f/static', vertex_data))
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

def draw_label(self):
""" Draw the label in the top left of the screen.

"""
x, y, z =
.text = '%02d (%.2f, %.2f, %.2f) %d / %d' % (
(), x, y, z,
len(._shown), len(.world))
.draw()

def draw_reticle(self):
""" Draw the crosshairs in the center of the screen.

"""
glColor3d(0, 0, 0)
.draw(GL_LINES)

def setup_fog():
""" Configure the OpenGL fog properties.

"""
# Enable fog. Fog "blends a fog color with each rasterized pixel fragment's
# post-texturing color."
glEnable(GL_FOG)
# Set the fog color.
glFogfv(GL_FOG_COLOR, (GLfloat * 4)(, , , 1))
# Say we have no preference between rendering speed and quality.
glHint(GL_FOG_HINT, GL_DONT_CARE)
# Specify the equation used to compute the blending factor.
glFogi(GL_FOG_MODE, GL_LINEAR)
# How close and far away fog starts and ends. The closer the start and end,
# the denser the fog in the fog range.
glFogf(GL_FOG_START, 4)
glFogf(GL_FOG_END, 6)

def setup():
""" Basic OpenGL configuration.

"""
# Set the color of "clear", . the sky, in rgba.
glClearColor(, , , 1)
# Enable culling (not rendering) of back-facing facets -- facets that aren't
# visible to you.
glEnable(GL_CULL_FACE)
# Set the texture minification/magnification function to GL_NEAREST (nearest
# in Manhattan distance) to the specified texture coordinates. GL_NEAREST
# "is generally faster than GL_LINEAR, but it can produce textured images
# with sharper edges because the transition between texture elements is not
# as smooth."
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
setup_fog()

def main():
window = Window(width=1280, height=720, caption='Minecraft', resizable=True)
# Hide the mouse cursor and prevent the mouse from leaving the
set_exclusive_mouse(True)
setup()
()

main()

now, another file: 

import random as rand
import math

class NoiseParameters:
def __init__(self, octaves, amplitude, smoothness, roughness, heightOffset):
= octaves
= amplitude
= smoothness
= roughness
self.heightOffset = heightOffset

class NoiseGen:
def __init__(self, seed):
= seed
self.noiseParams = NoiseParameters(
7, 50, 450, , 20
)

def _getNoise2(self, n):
n +=
n = (int(n) << 13) ^ int(n)
newn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff
return - (float(newn) / )

def _getNoise(self, x, z):
return self._getNoise2(x + z * 57)

def _lerp(self, a, b, z):
mu2 = ( - (z * )) /
return (a * (1 - mu2) + b * mu2)

def _noise(self, x, z):
floorX = float(int(x))
floorZ = float(int(z))

s = ,
t = ,
u = ,
v = ;#Integer declaration

s = self._getNoise(floorX, floorZ)
t = self._getNoise(floorX + 1, floorZ)
u = self._getNoise(floorX, floorZ + 1)
v = self._getNoise(floorX + 1, floorZ + 1)

rec1 = (s, t, x - floorX)
rec2 = (u, v, x - floorX)
rec3 = (rec1, rec2, z - floorZ)
return rec3

def getHeight(self, x, z):
totalValue =

for a in range(self.noiseParams.octaves - 1):
freq = (, a)
amp = (self.noiseParams.roughness, a)
totalValue += (
(float(x)) * freq / self.noiseParams.smoothness,
(float(z)) * freq / self.noiseParams.smoothness
) * self.noiseParams.amplitude

result = (((totalValue / ) + ) * self.noiseParams.amplitude) + self.noiseParams.heightOffset

return (totalValue / 5) + self.noiseParams.heightOffset

together they make minecraft with python! (Remember to add your own textures!)

Avatar of fr05t3d-fl4k3s
How do i see the rest im on ipad
Avatar of Milansid

You don't need to

Avatar of BurgerEatersInc
AmericanChadAGC wrote:

massive code

massive?