humanda5 commited on
Commit
573bc98
Β·
1 Parent(s): 082f464

random village set test

Browse files
npc_social_network/maps/town_hall.py CHANGED
@@ -1,5 +1,6 @@
1
  import pygame
2
  import sys
 
3
 
4
  # 초기 μ„€μ •
5
  pygame.init()
@@ -11,13 +12,22 @@ pygame.display.set_caption("town_hall")
11
  # 색상 μ •μ˜
12
  COLORS = {
13
  "empty": (230, 230, 230),
14
- "house": (150, 75, 0),
15
- "market": (255, 215, 0),
16
- "farm": (34, 139, 34),
17
- "temple": (128, 0, 128),
18
- "npc": (0,0,255)
 
 
 
 
 
19
  }
20
 
 
 
 
 
21
  # λ§ˆμ„ ꡬ쑰 μ •μ˜
22
  village_map = {
23
  "buildings": [
@@ -27,10 +37,39 @@ village_map = {
27
  {"type": "farm", "location": [10,3]},
28
  {"type": "temple", "location": [8,8]},
29
  ],
30
- "npc":[
31
  {"name": "Elin", "job": "farmer", "location": [2,3]},
32
  {"name": "Borg", "job": "blacksmith", "location": [6,6]}
33
  ]
34
  }
35
 
36
- # ν™”λ©΄ λ Œλ”λ§ ν•¨μˆ˜
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pygame
2
  import sys
3
+ import random
4
 
5
  # 초기 μ„€μ •
6
  pygame.init()
 
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
  # λ§ˆμ„ ꡬ쑰 μ •μ˜
32
  village_map = {
33
  "buildings": [
 
37
  {"type": "farm", "location": [10,3]},
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
+ color = COLORS.get(terrain, (200, 200, 200))
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
+ color = COLORS.get(building["type"], (100, 100, 100))
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
+ pygame.draw.circle(screen, COLORS["npc"], (x * tile_size + tile_size // 2, y * tile_size + tile_size // 2), 8)
63
+
64
+ # pygame 루프
65
+ runnig = True
66
+ while runnig:
67
+ draw_map()
68
+ pygame.display.update()
69
+
70
+ for event in pygame.event.get():
71
+ if event.type == pygame.QUIT:
72
+ runnig = False
73
+
74
+ pygame.quit()
75
+ sys.exit()