Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isometric
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
Material und Vorlagen
Thema Spieleprogrammierung
isometric
Commits
ad4a6979
Commit
ad4a6979
authored
5 years ago
by
Kirill Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Add preview render
parent
09acccbb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.py
+81
-0
81 additions, 0 deletions
main.py
sprites/grass.png
+0
-0
0 additions, 0 deletions
sprites/grass.png
sprites/wall.png
+0
-0
0 additions, 0 deletions
sprites/wall.png
with
81 additions
and
0 deletions
main.py
0 → 100644
+
81
−
0
View file @
ad4a6979
"""
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
This diff is collapsed.
Click to expand it.
sprites/grass.png
0 → 100644
+
0
−
0
View file @
ad4a6979
238 B
This diff is collapsed.
Click to expand it.
sprites/wall.png
0 → 100644
+
0
−
0
View file @
ad4a6979
237 B
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment