-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map gen
42 lines (35 loc) · 827 Bytes
/
Map gen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from Tkinter import *
import random
root = Tk()
root.geometry("1000x1000")
COLS = 10
ROWS = 10
ISLAND_CHANCE = 15
for i in range(COLS):
root.columnconfigure(i)
for i in range(ROWS):
root.rowconfigure(i)
oce = []
for i in ("Ocean1.gif", "Ocean2.gif", "Ocean3.gif"):
oce.append(PhotoImage(file=i))
ild = []
for i in ("Island1.gif", "Island2.gif"):
ild.append(PhotoImage(file=i))
tiles = {}
Xident = 0
Yident = 0
for tile_no in range(ROWS*COLS):
a = random.randint(0,99)
if a < ISLAND_CHANCE:
chosen = random.choice(ild)
else:
chosen = random.choice(oce)
Tile = Label(root, image=chosen)
Tile.image = chosen
Tile.grid(row=Xident, column=Yident)
tiles[tile_no] = Tile
Xident += 1
if Xident >= COLS:
Xident = 0
Yident += 1
root.mainloop()