Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
L
LordlarKamarasi
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
LordlarKamarasi
Commits
e1cde7ff
Kaydet (Commit)
e1cde7ff
authored
Nis 21, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Inital player, player registery, texture
üst
7ad67d8e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
8 deletions
+35
-8
controller.py
lordlarkamarasi/controller.py
+8
-2
players.py
lordlarkamarasi/players.py
+19
-0
textures.py
lordlarkamarasi/textures.py
+8
-6
player.png
lordlarkamarasi/textures/entities/player.png
+0
-0
No files found.
lordlarkamarasi/controller.py
Dosyayı görüntüle @
e1cde7ff
...
...
@@ -9,8 +9,8 @@ from typing import Tuple
import
pygame
from
pygame.locals
import
QUIT
from
lordlarkamarasi.textures
import
AVAILABLE_BLOCKS
,
BASE_PATH
,
TILE_SIZE
,
Blocks
from
lordlarkamarasi.textures
import
AVAILABLE_BLOCKS
,
BASE_PATH
,
TILE_SIZE
,
Blocks
,
Entities
from
lordlarkamarasi.players
import
PlayerRegistery
class
Map
(
UserList
):
def
__init__
(
self
,
width
,
height
,
surface
):
...
...
@@ -57,6 +57,8 @@ class Game:
self
.
surface
=
pygame
.
display
.
set_mode
(
window
)
self
.
map
=
Map
.
from_file
(
'maps/base_map.ini'
)
self
.
playerreg
=
PlayerRegistery
()
def
process_event
(
self
,
event
:
pygame
.
event
.
EventType
):
self
.
draw_map
()
...
...
@@ -71,6 +73,7 @@ class Game:
pygame
.
quit
()
def
start
(
self
):
self
.
playerreg
.
join
(
"BTaskaya"
)
self
.
event_handler
()
def
draw_map
(
self
):
...
...
@@ -79,6 +82,9 @@ class Game:
self
.
surface
.
blit
(
block
.
value
.
texture
,
(
cpos
*
TILE_SIZE
,
rpos
*
TILE_SIZE
)
)
for
player
in
self
.
playerreg
.
values
():
self
.
surface
.
blit
(
Entities
.
PLAYER
.
value
.
texture
,
(
player
.
coord
.
x
*
TILE_SIZE
,
player
.
coord
.
y
*
TILE_SIZE
))
if
__name__
==
"__main__"
:
...
...
lordlarkamarasi/players.py
0 → 100644
Dosyayı görüntüle @
e1cde7ff
from
dataclasses
import
dataclass
,
field
from
collections
import
UserDict
@dataclass
class
Coordinates
:
x
:
int
=
0
y
:
int
=
0
@dataclass
class
Player
:
username
:
str
coord
:
Coordinates
=
field
(
default_factory
=
Coordinates
)
class
PlayerRegistery
(
UserDict
):
def
join
(
self
,
username
):
self
.
data
[
username
]
=
Player
(
username
)
def
quit
(
self
,
username
):
del
self
.
data
[
username
]
lordlarkamarasi/textures.py
Dosyayı görüntüle @
e1cde7ff
...
...
@@ -13,22 +13,24 @@ def relative_load(path: str) -> pygame.Surface:
return
pygame
.
image
.
load
(
os
.
fspath
(
BASE_PATH
/
path
))
@dataclass
class
Block
:
class
Texture
:
id
:
int
texture
:
pygame
.
Surface
must_connect
:
Optional
[
id
]
=
None
class
Blocks
(
Enum
):
GRASS
=
Block
(
0
,
relative_load
(
"textures/land/grass.png"
))
STONE
=
Block
(
1
,
relative_load
(
"textures/land/stone.png"
))
WATER
=
Block
(
2
,
relative_load
(
"textures/land/water.png"
))
SAND
=
Block
(
3
,
relative_load
(
"textures/land/sand.png"
))
GRASS
=
Texture
(
0
,
relative_load
(
"textures/land/grass.png"
))
STONE
=
Texture
(
1
,
relative_load
(
"textures/land/stone.png"
))
WATER
=
Texture
(
2
,
relative_load
(
"textures/land/water.png"
))
SAND
=
Texture
(
3
,
relative_load
(
"textures/land/sand.png"
))
@classmethod
def
get_by_id
(
cls
,
id
):
block
,
=
filter
(
lambda
member
:
member
.
value
.
id
==
id
,
cls
.
__members__
.
values
())
return
cls
(
block
)
class
Entities
(
Enum
):
PLAYER
=
Texture
(
0xF0
,
relative_load
(
"textures/entities/player.png"
))
ALL_BLOCKS
=
set
(
Blocks
.
__members__
.
values
())
AVAILABLE_BLOCKS
=
set
(
filter
(
lambda
block
:
not
block
.
value
.
must_connect
,
ALL_BLOCKS
))
...
...
lordlarkamarasi/textures/entities/player.png
0 → 100644
Dosyayı görüntüle @
e1cde7ff
3.78 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment