I have begun to create a procedurally generated RPG using Python, and I am having trouble with rendering the terrain.
What is happening:
I generate some terrain from some files, or create/save new terrain, and display it on the screen as a 2D B&W heightmap; black = low elevation, white = high elevation. The data are stored in .txt files, formatted as a series of arrays populated with floats.
When the game loads, the terrain is displayed properly, however, once you begin to move around, the terrain begins to act funky.
- If you move far from where you start, the terrain becomes gridlike.
- If you move horizontally, the terrain becomes somewhat vertically offset.
- If you move vertically, the terrain does not update.
- Even if you DO move horizontally before/after moving vertically, the terrain will not update vertically, only horizontally.
EDIT: I think the problem occurs in this block of code, but I can't be sure. This is taken from
grid_generator.py. It returns a merged grid from the 3x3 area around a given point, where
findAdjFnames are custom functions within
def threeBYthree(x,y): g =  for gy in range(-1,2): g.append() for gx in range(-1,2): adj = findAdjFnames(x + gx,y + gy) print(adj) shouldSave = not os.path.isfile('./assets/grids/' + str(x + gx) + '_' + str(y + gy) + '.txt') print(shouldSave) g[gy + 1].append(loadGrid(str(x + gx) + '_' + str(x + gy) + '.txt', adjF = adj, andSave = shouldSave)) #merge upper four g3a = merge(g,g,g,g) #merge bottom-left two g3b =  for y in range(len(g)): g3b.append(g[y] + g[y][1:]) #merge top-right two g3c =  for y in range(len(g)+len(g)): if y < len(g): g3c.append(g[y]) elif y == len(g): pass else: g3c.append(g[y-len(g)]) #merge all g3d = merge(g3a,g3c,g3b,g) return g3d
The problem may occur somewhere else, but this bit is what I most recently worked on before the code stopped working.
Terrain functions: grid_generator.py
Main game loop: main_test.py
Terrain file for coordinate (0,0): 0_0.txt
NOTE: irrelevant, and some necessary, functions have been removed for privacy and security reasons. If you feel that this includes information required for a fix, please comment.