Skip to content
Snippets Groups Projects
Commit ad4a6979 authored by Kirill Schmidt's avatar Kirill Schmidt
Browse files

Add preview render

parent 09acccbb
No related branches found
No related tags found
No related merge requests found
main.py 0 → 100644
"""
Author: Kirill Schmidt, Lukas Weichelt, Robert Seimetz
A game with an isometric (2.5D) view.
"""
# Import modules
import sys
import pygame
from pygame.locals import *
# Set constants
SCREEN_NAME = "Isometric"
SCREEN_HEIGHT = 1080
SCREEN_WIDTH = 720
TILE_HEIGHT = 64
TILE_WIDTH = 64
def main():
# Initialise screen
pygame.init()
screen = pygame.display.set_mode((SCREEN_HEIGHT, SCREEN_WIDTH))
pygame.display.set_caption(SCREEN_NAME)
# Fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((0, 0, 0))
# Blit everything to the screen
screen.blit(background, (0, 0))
pygame.display.update()
# Initialise map
map_data = [
[1, 1, 1, 1, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1]
]
# Load images
wall = pygame.image.load('sprites/wall.png').convert()
grass = pygame.image.load('sprites/grass.png').convert()
currentTile = 0
currentRow = 0
for row in map_data:
for tile in row:
if tile==1:
tileType = wall
else:
tileType = grass
x = currentTile * TILE_WIDTH +500
y = currentRow * TILE_HEIGHT +100
currentTile += 1
screen.blit(tileType, twoDtoIso(x, y))
pygame.display.update()
currentTile = 0
currentRow += 1
# Event loop
while 1:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# Function to convert cartesian coordinates to isometric
def twoDtoIso(cartX, cartY):
isoX = cartX - cartY
isoY = (cartX + cartY) / 2
return(isoX, isoY)
if __name__ == '__main__': main()
\ No newline at end of file
sprites/grass.png

238 B

sprites/wall.png

237 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment