Python Forum
Why doesnt chunk generation work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why doesnt chunk generation work?
#1
So basically I have been trying to get a terrain generator but the values are always the same on the top left corner. Any ideas why? Wall Wall

MAIN SCRIPT
import pygame
import player
import world_gen

pygame.init()

tk = pygame.time.Clock()
FPS = 60

background = pygame.image.load('imgs/background_gradient.png')


is_running = True

(WIN_W, WIN_H) = (1600, 900)
display = pygame.display.set_mode((WIN_W, WIN_H))
pygame.display.set_caption('2D Minecraft v0.0 ALPHA')

temp_tile = pygame.image.load('imgs/temp_tile.png')

def HandleDrawing():
    display.blit(background, (0, 0))

    at_block = 0
    for chunk in world_gen.world_dat:
        display.blit(temp_tile, (chunk[at_block], chunk[at_block+1]))
        at_block += 1

    if player.is_walking:
        if not player.left and player.right:
            display.blit(pygame.transform.flip(player.walk_anim[player.at_walk_frame], True, False), (player.x, player.y))

        elif not player.right and player.left:
            display.blit(player.walk_anim[player.at_walk_frame], (player.x, player.y))

        elif player.left and player.right:
            display.blit(player.player, (player.x, player.y))

    else:
        display.blit(player.player, (player.x, player.y))

    pygame.display.update()

world_gen.chunk_gen(1)
while is_running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            is_running = False
    player.Movement()
    HandleDrawing()

    tk.tick(FPS)
pygame.quit()
WORLD GEN
import pygame
import noise
import random

chunk_size = 24
grid_size = 40
noise_multiplier = 0.05

world_dat = []

def chunk_gen(x):
    global world_dat
    chunk_dat = []
    for x_pos in range(chunk_size):
        h = int(noise.pnoise1(x + x_pos* chunk_size * noise_multiplier, repeat=9999999) * 5)
        chunk_dat.append(x + x_pos * grid_size)
        chunk_dat.append(h)

    chunk_dat.append(round(x / chunk_size)) 
    world_dat.append(chunk_dat)

Attached Files

Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question PDF generation / edit SpongeB0B 2 342 Jul-28-2021, 05:59 AM
Last Post: SpongeB0B
  if conditions in the for indentation doesnt work ? Sutsro 6 1,317 Jun-15-2021, 11:45 PM
Last Post: bowlofred
  Calling Input for Random Generation ScaledCodingWarrior 1 479 Feb-02-2021, 07:27 PM
Last Post: bowlofred
  I have two Same Code but One of them Doesnt Work beginner721 6 781 Jan-22-2021, 10:56 PM
Last Post: beginner721
  code doesnt return anything ofrihemo 3 813 Jun-30-2020, 05:14 PM
Last Post: ofrihemo
  taking input doesnt print as list bntayfur 2 804 Jun-04-2020, 02:48 AM
Last Post: bntayfur
  Pydoc documentation doesnt work Cosmosso 4 1,645 Dec-13-2019, 08:21 AM
Last Post: Cosmosso
  multiprocessing doesnt contain some modules(shared_memory) mike000 3 866 Oct-31-2019, 02:20 PM
Last Post: mike000
  BEGINNER: My calculator doesnt work iskov 5 1,245 Oct-09-2019, 07:45 AM
Last Post: buran
  Using chunk size issue sandy 1 953 Feb-25-2019, 04:43 PM
Last Post: sandy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020