Spaces:
Running
Running
humanda5
commited on
Commit
Β·
70eedf8
1
Parent(s):
d023960
Complete mini village design step 2
Browse filesThis view is limited to 50 files because it contains too many changes. Β
See raw diff
- .gitattributes +3 -0
- clean_requirements.txt +0 -0
- image_reprocessing/IPM.ipynb +67 -0
- image_reprocessing/input_images/set_1/animal_caw.png +3 -0
- image_reprocessing/input_images/set_1/animal_chicken.png +3 -0
- image_reprocessing/input_images/set_1/animal_dog.png +3 -0
- image_reprocessing/input_images/set_1/animal_horse.png +3 -0
- image_reprocessing/input_images/set_1/animal_pig.png +3 -0
- image_reprocessing/input_images/set_1/animal_sheep.png +3 -0
- image_reprocessing/input_images/set_1/build_house.png +3 -0
- image_reprocessing/input_images/set_1/build_market.png +3 -0
- image_reprocessing/input_images/set_1/build_temple.png +3 -0
- image_reprocessing/input_images/set_1/plant_raspberry.png +3 -0
- image_reprocessing/input_images/set_1/plant_tree.png +3 -0
- image_reprocessing/input_images/set_1/plant_wheat.png +3 -0
- image_reprocessing/input_images/set_1/tile_dirt.png +3 -0
- image_reprocessing/input_images/set_1/tile_grass.png +3 -0
- image_reprocessing/input_images/set_1/tile_pool.png +3 -0
- image_reprocessing/input_images/set_1/tile_stone.png +3 -0
- image_reprocessing/input_images/set_1/tile_water.png +3 -0
- image_reprocessing/input_images/set_2/npc.png +3 -0
- input_images/temple_tile.png +0 -3
- input_images/tree_tile.png +0 -3
- input_images/wheat_field_tile.png +0 -3
- npc_social_network/maps/town_hall.py +37 -20
- input_images/store_tile.png β npc_social_network/static/images/tiles/animal/animal_caw.png +2 -2
- input_images/grass_tile.png β npc_social_network/static/images/tiles/animal/animal_chicken.png +2 -2
- input_images/home_tile.png β npc_social_network/static/images/tiles/animal/animal_dog.png +2 -2
- input_images/stone_tile.png β npc_social_network/static/images/tiles/animal/animal_horse.png +2 -2
- npc_social_network/static/images/tiles/animal/animal_pig.png +3 -0
- npc_social_network/static/images/tiles/animal/animal_sheep.png +3 -0
- npc_social_network/static/images/tiles/building/build_house.png +3 -0
- npc_social_network/static/images/tiles/building/build_market.png +3 -0
- npc_social_network/static/images/tiles/building/build_temple.png +3 -0
- npc_social_network/static/images/tiles/grass_tile.png +0 -3
- npc_social_network/static/images/tiles/home_tile.png +0 -3
- npc_social_network/static/images/tiles/npc/npc.png +3 -0
- npc_social_network/static/images/tiles/plant/plant_raspberry.png +3 -0
- npc_social_network/static/images/tiles/plant/plant_tree.png +3 -0
- npc_social_network/static/images/tiles/plant/plant_wheat.png +3 -0
- npc_social_network/static/images/tiles/stone_tile.png +0 -3
- npc_social_network/static/images/tiles/store_tile.png +0 -3
- npc_social_network/static/images/tiles/temple_tile.png +0 -3
- npc_social_network/static/images/tiles/topography/tile_dirt.png +3 -0
- npc_social_network/static/images/tiles/topography/tile_grass.png +3 -0
- npc_social_network/static/images/tiles/topography/tile_pool.png +3 -0
- npc_social_network/static/images/tiles/topography/tile_stone.png +3 -0
- npc_social_network/static/images/tiles/topography/tile_water.png +3 -0
- npc_social_network/static/images/tiles/tree_tile.png +0 -3
- npc_social_network/static/images/tiles/wheat_field_tile.png +0 -3
.gitattributes
CHANGED
@@ -1 +1,4 @@
|
|
|
|
|
|
|
|
1 |
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
*.ipynb text eol=lf
|
2 |
+
*.bat text eol=crlf
|
3 |
+
*.sh text eol=lf
|
4 |
*.png filter=lfs diff=lfs merge=lfs -text
|
clean_requirements.txt
DELETED
File without changes
|
image_reprocessing/IPM.ipynb
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 9,
|
6 |
+
"id": "d6a916d2",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"name": "stdout",
|
11 |
+
"output_type": "stream",
|
12 |
+
"text": [
|
13 |
+
"npc.png 리μ¬μ΄μ¦ μλ£\n"
|
14 |
+
]
|
15 |
+
}
|
16 |
+
],
|
17 |
+
"source": [
|
18 |
+
"# μ΄λ―Έμ§ ν¬κΈ° 64x64λ‘ λ³κ²½ (input_images -> resized_images)\n",
|
19 |
+
"from PIL import Image\n",
|
20 |
+
"import os\n",
|
21 |
+
"\n",
|
22 |
+
"# μ
λ ₯ ν΄λμ μΆλ ₯ ν΄λ κ²½λ‘ μ€μ \n",
|
23 |
+
"input_folder = \"input_images/set_2\" # μλ³Έ μ΄λ―Έμ§ ν΄λ\n",
|
24 |
+
"output_folder = \"resized_images\" # 리μ¬μ΄μ¦λ μ΄λ―Έμ§ μ μ₯ ν΄λ\n",
|
25 |
+
"target_size = (64, 64)\n",
|
26 |
+
"\n",
|
27 |
+
"# μΆλ ₯ ν΄λκ° μμΌλ©΄ μμ±\n",
|
28 |
+
"os.makedirs(output_folder, exist_ok=True)\n",
|
29 |
+
"\n",
|
30 |
+
"# μ΄λ―Έμ§ 리μ¬μ΄μ¦\n",
|
31 |
+
"for filename in os.listdir(input_folder):\n",
|
32 |
+
" if filename.lower().endswith((\".png\", \".jpg\", \"jpeg\", \".bmp\", \".gif\")):\n",
|
33 |
+
" input_path = os.path.join(input_folder, filename)\n",
|
34 |
+
" output_path = os.path.join(output_folder, filename)\n",
|
35 |
+
"\n",
|
36 |
+
" try:\n",
|
37 |
+
" with Image.open(input_path) as img:\n",
|
38 |
+
" resized_img = img.resize(target_size, Image.Resampling.LANCZOS)\n",
|
39 |
+
" resized_img.save(output_path)\n",
|
40 |
+
" print(f\"{filename} 리μ¬μ΄μ¦ μλ£\")\n",
|
41 |
+
" except Exception as e:\n",
|
42 |
+
" print(f\"{filename} μ²λ¦¬ μ€ μ€λ₯ λ°μ: {e}\")"
|
43 |
+
]
|
44 |
+
}
|
45 |
+
],
|
46 |
+
"metadata": {
|
47 |
+
"kernelspec": {
|
48 |
+
"display_name": "portfolio",
|
49 |
+
"language": "python",
|
50 |
+
"name": "python3"
|
51 |
+
},
|
52 |
+
"language_info": {
|
53 |
+
"codemirror_mode": {
|
54 |
+
"name": "ipython",
|
55 |
+
"version": 3
|
56 |
+
},
|
57 |
+
"file_extension": ".py",
|
58 |
+
"mimetype": "text/x-python",
|
59 |
+
"name": "python",
|
60 |
+
"nbconvert_exporter": "python",
|
61 |
+
"pygments_lexer": "ipython3",
|
62 |
+
"version": "3.11.11"
|
63 |
+
}
|
64 |
+
},
|
65 |
+
"nbformat": 4,
|
66 |
+
"nbformat_minor": 5
|
67 |
+
}
|
image_reprocessing/input_images/set_1/animal_caw.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/animal_chicken.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/animal_dog.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/animal_horse.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/animal_pig.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/animal_sheep.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/build_house.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/build_market.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/build_temple.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/plant_raspberry.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/plant_tree.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/plant_wheat.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/tile_dirt.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/tile_grass.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/tile_pool.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/tile_stone.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_1/tile_water.png
ADDED
![]() |
Git LFS Details
|
image_reprocessing/input_images/set_2/npc.png
ADDED
![]() |
Git LFS Details
|
input_images/temple_tile.png
DELETED
Git LFS Details
|
input_images/tree_tile.png
DELETED
Git LFS Details
|
input_images/wheat_field_tile.png
DELETED
Git LFS Details
|
npc_social_network/maps/town_hall.py
CHANGED
@@ -1,6 +1,8 @@
|
|
|
|
1 |
import pygame
|
2 |
import sys
|
3 |
import random
|
|
|
4 |
|
5 |
# μ΄κΈ° μ€μ
|
6 |
pygame.init()
|
@@ -9,23 +11,41 @@ grid_width, grid_height = 20, 20
|
|
9 |
screen = pygame.display.set_mode((grid_width * tile_size, grid_height * tile_size))
|
10 |
pygame.display.set_caption("town_hall")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# μμ μ μ
|
13 |
COLORS = {
|
14 |
"empty": (230, 230, 230),
|
15 |
-
|
16 |
-
"grass": (144, 238, 144), # μ°λ
Ήμ
|
17 |
-
"dirt": (210, 180, 140), # νμ
|
18 |
-
"stone": (169, 169, 169), # νμ
|
19 |
-
|
20 |
-
"house": (150, 75, 0), # κ°μ
|
21 |
-
"market": (255, 215, 0), # κΈμ
|
22 |
-
"farm": (34, 139, 34), # μ§μ λ
Ήμ
|
23 |
-
"temple": (128, 0, 128), # 보λΌμ
|
24 |
-
"npc": (0,0,255) # νλμ
|
25 |
}
|
26 |
|
27 |
# λλ€ λ°°κ²½ νμΌ μμ±
|
28 |
-
terrain_types = ["grass", "dirt", "stone"]
|
29 |
terrain_map = [[random.choice(terrain_types) for _ in range(grid_width)] for _ in range(grid_height)]
|
30 |
|
31 |
# λ§μ ꡬ쑰 μ μ
|
@@ -34,32 +54,29 @@ village_map = {
|
|
34 |
{"type": "house", "location": [2,3]},
|
35 |
{"type": "house", "location": [3,3]},
|
36 |
{"type": "market", "location": [5,5]},
|
37 |
-
{"type": "
|
38 |
{"type": "temple", "location": [8,8]},
|
39 |
],
|
40 |
"npcs":[
|
41 |
-
{"name": "Elin", "job": "farmer", "location": [2,3]},
|
42 |
-
{"name": "Borg", "job": "blacksmith", "location": [6,6]}
|
43 |
]
|
44 |
}
|
45 |
|
46 |
# νλ©΄ λ λλ§ ν¨μ
|
47 |
def draw_map():
|
48 |
-
screen.fill(COLORS['empty'])
|
49 |
for y in range(grid_height):
|
50 |
for x in range(grid_width):
|
51 |
terrain = terrain_map[y][x]
|
52 |
-
|
53 |
-
pygame.draw.rect(screen, color, (x * tile_size, y * tile_size, tile_size, tile_size))
|
54 |
|
55 |
for building in village_map["buildings"]:
|
56 |
x, y = building["location"]
|
57 |
-
|
58 |
-
pygame.draw.rect(screen, color, (x * tile_size, y * tile_size, tile_size, tile_size))
|
59 |
|
60 |
for npc in village_map["npcs"]:
|
61 |
x, y = npc["location"]
|
62 |
-
|
63 |
|
64 |
# pygame 루ν
|
65 |
runnig = True
|
|
|
1 |
+
# portfolio/npc_social_network/maps/town_hall.py
|
2 |
import pygame
|
3 |
import sys
|
4 |
import random
|
5 |
+
import os
|
6 |
|
7 |
# μ΄κΈ° μ€μ
|
8 |
pygame.init()
|
|
|
11 |
screen = pygame.display.set_mode((grid_width * tile_size, grid_height * tile_size))
|
12 |
pygame.display.set_caption("town_hall")
|
13 |
|
14 |
+
# μ΄λ―Έμ§ λ‘λ ν¨μ
|
15 |
+
def load_image(name):
|
16 |
+
path = os.path.join("../static/images/tiles", name) # μ΄λ―Έμ§λ€μ images/tiles ν΄λμ μ μ₯νλ€κ³ κ°μ
|
17 |
+
return pygame.transform.scale(pygame.image.load(path), (tile_size, tile_size))
|
18 |
+
|
19 |
+
# νμΌ μ΄λ―Έμ§ μ¬μ
|
20 |
+
TILE_IMAGES = {
|
21 |
+
# μ§ν
|
22 |
+
"grass": load_image("topography/tile_grass.png"),
|
23 |
+
"dirt": load_image("topography/tile_dirt.png"),
|
24 |
+
"stone": load_image("topography/tile_stone.png"),
|
25 |
+
"water": load_image("topography/tile_water.png"),
|
26 |
+
|
27 |
+
# 건물
|
28 |
+
"house": load_image("building/build_house.png"),
|
29 |
+
"temple": load_image("building/build_temple.png"),
|
30 |
+
"market": load_image("building/build_market.png"),
|
31 |
+
|
32 |
+
# λλ¬Ό
|
33 |
+
|
34 |
+
# μλ¬Ό
|
35 |
+
"tree":load_image("plant/plant_tree.png"),
|
36 |
+
"wheat":load_image("plant/plant_wheat.png"),
|
37 |
+
|
38 |
+
# μ¬λ
|
39 |
+
"npc":load_image("npc/npc.png"),
|
40 |
+
}
|
41 |
+
|
42 |
# μμ μ μ
|
43 |
COLORS = {
|
44 |
"empty": (230, 230, 230),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
# λλ€ λ°°κ²½ νμΌ μμ±
|
48 |
+
terrain_types = ["grass", "dirt", "stone", "water"]
|
49 |
terrain_map = [[random.choice(terrain_types) for _ in range(grid_width)] for _ in range(grid_height)]
|
50 |
|
51 |
# λ§μ ꡬ쑰 μ μ
|
|
|
54 |
{"type": "house", "location": [2,3]},
|
55 |
{"type": "house", "location": [3,3]},
|
56 |
{"type": "market", "location": [5,5]},
|
57 |
+
{"type": "wheat", "location": [10,3]},
|
58 |
{"type": "temple", "location": [8,8]},
|
59 |
],
|
60 |
"npcs":[
|
61 |
+
{"name": "Elin", "job": "farmer", "location": [2,3], "type": "npc"},
|
62 |
+
{"name": "Borg", "job": "blacksmith", "location": [6,6], "type": "npc"}
|
63 |
]
|
64 |
}
|
65 |
|
66 |
# νλ©΄ λ λλ§ ν¨μ
|
67 |
def draw_map():
|
|
|
68 |
for y in range(grid_height):
|
69 |
for x in range(grid_width):
|
70 |
terrain = terrain_map[y][x]
|
71 |
+
screen.blit(TILE_IMAGES[terrain], (x * tile_size, y * tile_size))
|
|
|
72 |
|
73 |
for building in village_map["buildings"]:
|
74 |
x, y = building["location"]
|
75 |
+
screen.blit(TILE_IMAGES[building["type"]], (x * tile_size, y * tile_size))
|
|
|
76 |
|
77 |
for npc in village_map["npcs"]:
|
78 |
x, y = npc["location"]
|
79 |
+
screen.blit(TILE_IMAGES[npc["type"]], (x * tile_size, y * tile_size))
|
80 |
|
81 |
# pygame 루ν
|
82 |
runnig = True
|
input_images/store_tile.png β npc_social_network/static/images/tiles/animal/animal_caw.png
RENAMED
File without changes
|
input_images/grass_tile.png β npc_social_network/static/images/tiles/animal/animal_chicken.png
RENAMED
File without changes
|
input_images/home_tile.png β npc_social_network/static/images/tiles/animal/animal_dog.png
RENAMED
File without changes
|
input_images/stone_tile.png β npc_social_network/static/images/tiles/animal/animal_horse.png
RENAMED
File without changes
|
npc_social_network/static/images/tiles/animal/animal_pig.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/animal/animal_sheep.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/building/build_house.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/building/build_market.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/building/build_temple.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/grass_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/home_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/npc/npc.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/plant/plant_raspberry.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/plant/plant_tree.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/plant/plant_wheat.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/stone_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/store_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/temple_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/topography/tile_dirt.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/topography/tile_grass.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/topography/tile_pool.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/topography/tile_stone.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/topography/tile_water.png
ADDED
![]() |
Git LFS Details
|
npc_social_network/static/images/tiles/tree_tile.png
DELETED
Git LFS Details
|
npc_social_network/static/images/tiles/wheat_field_tile.png
DELETED
Git LFS Details
|