Why doesn't my map appear on my pygame display? I have used the number system for a map but still no result.
Code
Don't need to read the notes, they are for myself:
import sys
import pygame
from pygame.locals import *
clock = pygame.time.Clock()
pygame.init()
pygame.display.set_caption("Kemal AKsay")
WINDOW_SIZE = (600, 400)
ekran = pygame.display.set_mode(WINDOW_SIZE, 0, 32)
display = pygame.Surface((300, 200))
oyuncu_görüntüsü = pygame.image.load("tt.png")
çimen_görüntüsü = pygame.image.load('çimen.png')
toprak_görüntüsü = pygame.image.load("toprak.png")
TILE_SIZE = çimen_görüntüsü.get_width()
game_map = [['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0', '2', '2', '2', '2', '2', '0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
['2', '2', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '2', '2'],
['1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '1', '1'],
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']]
sağa_ileri = False
sola_ileri = False
oyuncu_konumu = [50, 50]
oyuncu_y_hızı = 0
player_rect = pygame.Rect(oyuncu_konumu[0], oyuncu_konumu[1], oyuncu_görüntüsü.get_width(), oyuncu_görüntüsü.get_height())
while True:
ekran.fill((146, 244, 255)) # bu arkaplan o 3 sayı rgb
tile_rects = []
y = 0
for row in game_map:
x = 0
for tile in row:
if tile == '1':
display.blit(toprak_görüntüsü, (x * TILE_SIZE, y * TILE_SIZE))
if tile == "2":
display.blit(çimen_görüntüsü, (x * TILE_SIZE, y * TILE_SIZE))
if tile != "0":
tile_rects.append(pygame.Rect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE , TILE_SIZE))
x += 1
y += 1
ekran.blit(oyuncu_görüntüsü, oyuncu_konumu,)
oyuncu_y_hızı += 0.2
oyuncu_konumu[1] += oyuncu_y_hızı
if sağa_ileri:
oyuncu_konumu[0] += 1
if sola_ileri:
oyuncu_konumu[0] -= 1
oyuncu_karesi = pygame.Rect(oyuncu_konumu[0], oyuncu_konumu[1], oyuncu_görüntüsü.get_width(), oyuncu_görüntüsü.get_height())
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_RIGHT:
sağa_ileri = True
if event.key == K_LEFT:
sola_ileri = True
if event.type == KEYUP:
if event.key == K_RIGHT:
sağa_ileri = False
if event.key == K_LEFT:
sola_ileri = False
if event.key == K_DOWN:
alta_ileri = False
if event.key == K_UP:
üste_ileri = False
pygame.display.update()
clock.tick(60)