Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 88e7890

Browse files
committedNov 4, 2019
Commited V1.5.0
1 parent d2a0fe1 commit 88e7890

16 files changed

+401
-222
lines changed
 

‎InputBox.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pygame
2+
3+
COLOR_INACTIVE = pygame.Color("black")
4+
COLOR_ACTIVE = pygame.Color("white")
5+
6+
class InputBox:
7+
def __init__(self, x, y, w, h, font, text=""):
8+
self.rect = pygame.Rect(x, y, w, h)
9+
self.color = COLOR_INACTIVE
10+
self.font = font
11+
self.text = text
12+
self.txt_surface = self.font.render(text, True, self.color)
13+
self.active = False
14+
15+
def handle_event(self, event):
16+
if event.type == pygame.MOUSEBUTTONDOWN:
17+
# If the user clicked on the input_box rect.
18+
if self.rect.collidepoint(event.pos):
19+
self.active = True
20+
else:
21+
self.active = False
22+
# Change the current color of the input box.
23+
self.color = COLOR_ACTIVE if self.active else COLOR_INACTIVE
24+
25+
if event.type == pygame.KEYDOWN:
26+
if self.active:
27+
if event.key == pygame.K_BACKSPACE:
28+
self.text = self.text[0:-1]
29+
else:
30+
if self.txt_surface.get_width() < self.rect.w - 15:
31+
self.text += event.unicode
32+
# Re-render the text.
33+
self.txt_surface = self.font.render(self.text, True, self.color)
34+
35+
def draw(self, screen):
36+
# Blit the text.
37+
screen.blit(self.txt_surface, (self.rect.x+5, self.rect.y+5))
38+
# Blit the rect.
39+
pygame.draw.rect(screen, self.color, self.rect, 4)

‎Installer.iss

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define MyAppName "MineBlock 2D"
2-
#define MyAppVersion "1.4.0"
2+
#define MyAppVersion "1.5.0"
33
#define MyAppPublisher "MineBlock 2D Dev Team"
44
#define MyAppURL "http://mineblock2d.ml/"
55
#define MyAppExeName "MineBlock 2D.exe"
@@ -37,6 +37,7 @@ Source: ".\dist\Default_skin.png"; DestDir: "{app}"; Flags: ignoreversion
3737
Source: ".\dist\MineBlock 2D.exe"; DestDir: "{app}"; Flags: ignoreversion
3838
Source: ".\dist\options.txt"; DestDir: "{app}"; Flags: ignoreversion
3939
Source: ".\dist\Readme.html"; DestDir: "{app}"; Flags: ignoreversion
40+
Source: ".\dist\LICENSE"; DestDir: "{app}"; Flags: ignoreversion
4041
Source: ".\dist\Texture Packs\*"; DestDir: "{app}\Texture Packs"; Flags: ignoreversion recursesubdirs createallsubdirs
4142

4243
[Dirs]

‎Texture Packs/Default/117.png

17.2 KB
Loading

‎Texture Packs/Default/118.png

13.7 KB
Loading

‎Texture Packs/Default/16.png

15.8 KB
Loading

‎Texture Packs/Default/17.png

18.3 KB
Loading

‎Texture Packs/Default/18.png

30.1 KB
Loading

‎Texture Packs/Default/19.png

36.2 KB
Loading

‎Texture Packs/Default/Crafting1.png

53 Bytes
Loading

‎Texture Packs/Default/Loading2.png

325 KB
Loading

‎World_gen.py

+60-45
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os.path, data
22
from random import randint
3-
3+
44
def main(WORLD):
55
level = []
66
ch = None
77

88
rand = 0
99
crand = 0
10+
gravel_rand = 0
1011
coal_rand = 0
1112
iron_rand = 0
1213
gold_rand = 0
@@ -40,7 +41,6 @@ def tree(x, y, trand):
4041
ch.append([x-1,y-3,101])
4142
ch.append([x,y-4,101])
4243

43-
4444
print("Generating")
4545
for x in range(-128, 128 + 1):
4646
# Start new chunk
@@ -64,6 +64,8 @@ def tree(x, y, trand):
6464
if crand == 0:
6565
crand = randint(1, 1000)
6666
if crand > 50:
67+
if gravel_rand == 0:
68+
gravel_rand = randint(1, 200)
6769
if coal_rand == 0:
6870
coal_rand = randint(1, 200)
6971
if iron_rand == 0:
@@ -72,8 +74,10 @@ def tree(x, y, trand):
7274
gold_rand = randint(1, 200)
7375
if diamond_rand == 0:
7476
diamond_rand = randint(1, 300)
75-
76-
if coal_rand < 10:
77+
78+
if gravel_rand < 10:
79+
ch.append([x,y,19])
80+
elif coal_rand < 10:
7781
ch.append([x,y,6])
7882
elif iorn_rand < 10:
7983
ch.append([x,y,7])
@@ -83,6 +87,8 @@ def tree(x, y, trand):
8387
ch.append([x,y,9])
8488
else:
8589
ch.append([x,y,3])
90+
91+
gravel_rand -= 1
8692
coal_rand -= 1
8793
iorn_rand -= 1
8894
gold_rand -= 1
@@ -97,52 +103,61 @@ def tree(x, y, trand):
97103
ch.append([x,48,5])
98104
ch.append([x,49,5])
99105
ch.append([x,50,5])
100-
101-
# Ground level
102-
if rand == 0:
103-
rand = randint(1, 10)
104-
# High
105-
if rand > 4:
106-
ch.append([x,28,3])
107-
if randint(1, 2) == 1:
108-
ch.append([x,27,3])
109-
else:
110-
ch.append([x,27,2])
111-
ch.append([x,26,2])
112-
ch.append([x,25,2])
113-
ch.append([x,24,1])
114106

115-
# Vegitation
116-
trand = randint(1, 50)
117-
if trand < 3:
118-
tree(x, 23, trand)
119-
elif randint(1, 5) == 1:
120-
ch.append([x,23,102])
121-
elif randint(1, 7) == 1:
122-
ch.append([x,23,103])
123-
elif randint(1, 7) == 1:
124-
ch.append([x,23,104])
125-
# Low
126-
else:
107+
if x > 120 or x < -120:
127108
if randint(1, 2) == 1:
128109
ch.append([x,28,3])
129110
else:
130-
ch.append([x,28,2])
131-
ch.append([x,27,2])
132-
ch.append([x,26,2])
133-
ch.append([x,25,1])
111+
ch.append([x,28,16])
112+
ch.append([x,27,16])
113+
ch.append([x,26,16])
114+
ch.append([x,25,16])
115+
else:
116+
# Ground level
117+
if rand == 0:
118+
rand = randint(1, 10)
119+
# High
120+
if rand > 4:
121+
ch.append([x,28,3])
122+
if randint(1, 2) == 1:
123+
ch.append([x,27,3])
124+
else:
125+
ch.append([x,27,2])
126+
ch.append([x,26,2])
127+
ch.append([x,25,2])
128+
ch.append([x,24,1])
129+
130+
# Vegitation
131+
trand = randint(1, 50)
132+
if trand < 3:
133+
tree(x, 23, trand)
134+
elif randint(1, 5) == 1:
135+
ch.append([x,23,102])
136+
elif randint(1, 7) == 1:
137+
ch.append([x,23,103])
138+
elif randint(1, 7) == 1:
139+
ch.append([x,23,104])
140+
# Low
141+
else:
142+
if randint(1, 2) == 1:
143+
ch.append([x,28,3])
144+
else:
145+
ch.append([x,28,2])
146+
ch.append([x,27,2])
147+
ch.append([x,26,2])
148+
ch.append([x,25,1])
134149

135-
# Vegitation
136-
trand = randint(1, 50)
137-
if trand < 3:
138-
tree(x, 24, trand)
139-
elif randint(1, 5) == 1:
140-
ch.append([x,24,102])
141-
elif randint(1, 7) == 1:
142-
ch.append([x,24,103])
143-
elif randint(1, 7) == 1:
144-
ch.append([x,24,104])
145-
rand -= 1
150+
# Vegitation
151+
trand = randint(1, 50)
152+
if trand < 3:
153+
tree(x, 24, trand)
154+
elif randint(1, 5) == 1:
155+
ch.append([x,24,102])
156+
elif randint(1, 7) == 1:
157+
ch.append([x,24,103])
158+
elif randint(1, 7) == 1:
159+
ch.append([x,24,104])
160+
rand -= 1
146161

147162
# Save
148163
with open(os.path.join("Worlds", WORLD), "w") as f:

‎Worlds/test.json

+3-3
Large diffs are not rendered by default.

‎compile.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pyinstaller --onefile --windowed -i "..\icon.ico" "MineBlock 2D.py"
55

66
robocopy ".\Texture Packs" ".\dist\Texture Packs" -MIR
77
robocopy ".\Worlds" ".\dist\Worlds" -MIR
8-
robocopy .\ .\dist\ options.txt Readme.html "Arial Black.ttf" Default_skin.png
8+
robocopy .\ .\dist\ options.txt Readme.html LICENSE "Arial Black.ttf" Default_skin.png
99

1010
echo Run...
1111
".\Dist\MineBlock 2D.exe"

‎compile.sh

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ cp Default_skin.png MineBlock\ 2D\ V$1/
1818
cp MineBlock\ 2D MineBlock\ 2D\ V$1/
1919
cp options.txt MineBlock\ 2D\ V$1/
2020
cp Readme.html MineBlock\ 2D\ V$1/
21+
cp LICENSE MineBlock\ 2D\ V$1/
2122
cp -R Texture\ Packs/ MineBlock\ 2D\ V$1/
2223

2324
echo compressing

‎data.py

+33-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
# Block properties
2-
# bid:[plant, brakeable, bid to get, bid to smelt, fuel]
3-
block_types = {1:[False,True,1,0,0], 2:[False,True,2,0,0], 3:[False,True,3,0,0],
4-
4:[False,False,0,0,0], 5:[False,False,0,0,0], 6:[False,True,6,0,64], 7:[False,True,7,202,0],
5-
8:[False,True,8,203,0], 9:[False,True,9,10,0], 10:[False,True,10,0,8],
6-
11:[False,True,107,0,1], 12:[False,True,105,0,2], 13:[False,True,105,0,2],
7-
14:[False,True,14,202,0], 15:[False,True,15,203,0],
2+
# bid:[plant, brakeable, bid to get, gravity effected, bid to smelt, fuel]
3+
block_types = {1:[False,True,1,False,0,0], 2:[False,True,2,False,0,0],
4+
3:[False,True,3,False,0,0], 4:[False,False,0,False,0,0],
5+
5:[False,False,0,False,0,0], 6:[False,True,6,False,0,64],
6+
7:[False,True,7,False,202,0], 8:[False,True,8,False,203,0],
7+
9:[False,True,9,False,10,0], 10:[False,True,10,False,0,8],
8+
11:[False,True,107,False,0,1], 12:[False,True,105,False,0,2],
9+
13:[False,True,105,False,0,2], 14:[False,True,14,False,202,0],
10+
15:[False,True,15,False,203,0], 16:[False,True,16,True,17,0],
11+
17:[False,True,0,False,17,0], 18:[False,True,18,False,3,0],
12+
19:[False,True,19,True,0,0],
813

9-
100:[False,True,100,0,8], 101:[False,True,111,0,0], 102:[True,True,0,0,0],
10-
103:[True,True,103,0,0], 104:[True,True,104,0,0], 105:[False,True,105,0,2],
11-
106:[False,True,105,0,2], 107:[False,True,107,0,1], 108:[False,True,108,0,8],
12-
109:[False,True,109,0,0], 110:[False,True,110,0,2], 111:[True,True,111,0,0],
13-
112:[False,True,112,0,8], 113:[False,True,113,202,0], 114:[False,True,114,202,0],
14-
115:[False,True,3,0,0], 116:[False,True,116,203,0],
14+
100:[False,True,100,False,0,8], 101:[False,True,111,False,0,0],
15+
102:[True,True,0,True,0,0], 103:[True,True,103,True,0,0],
16+
104:[True,True,104,True,0,0], 105:[False,True,105,False,0,2],
17+
106:[False,True,105,False,0,2], 107:[False,True,107,False,0,1],
18+
108:[False,True,108,False,0,8], 109:[False,True,109,False,0,0],
19+
110:[False,True,110,False,0,2], 111:[True,True,111,False,0,0],
20+
112:[False,True,112,False,0,8], 113:[False,True,113,False,202,0],
21+
114:[False,True,114,False,202,0], 115:[False,True,3,False,0,0],
22+
116:[False,True,116,False,203,0], 117:[False,True,117,False,0,1],
23+
118:[False,True,118,False,0,1],
1524

16-
200:[False,True,0,0,0.25], 201:[False,True,0,0,8], 202:[False,True,0,202,0],
17-
203:[False,True,0,203,0]}
25+
200:[False,True,0,False,0,0.25], 201:[False,True,0,False,0,8],
26+
202:[False,True,0,False,202,0], 203:[False,True,0,False,203,0]}
1827

1928
# Crafting recipies
2029
# [bid to craft, bids,required,0,0,0, quantity to get]
21-
crafting_recipies = [[112, 100,0,0,0,0, 1], [10, 100,0,0,0,0, 1], [200, 10,0,0,0,0, 32],
22-
[107, 10,0,0,0,0, 4], [105, 10,0,0,0,0, 2], [110, 10,0,0,0,0, 4],
23-
[108, 10,10,0,0,0, 1], [109, 3,3,0,0,0, 1], [115, 3,0,0,0,0, 1],
24-
[114, 202,202,202,202,202, 1]]
30+
crafting_recipies = [[112, 100,0,0,0,0, 1], [10, 100,0,0,0,0, 1],
31+
[200, 10,0,0,0,0, 32], [107, 10,0,0,0,0, 4],
32+
[105, 10,0,0,0,0, 2], [110, 10,0,0,0,0, 4],
33+
[108, 10,10,0,0,0, 1], [109, 3,3,0,0,0, 1],
34+
[115, 3,0,0,0,0, 1], [18, 3,0,0,0,0, 1],
35+
[114, 202,202,202,202,202, 1], [117, 10,200,201,0,0, 5],
36+
[118, 10,103,104,0,0, 5]]
2537

26-
anvil_recipies = [[201, 6,0,0,0,0, 9], [14, 202,202,202,202,202, 1], [113, 202,202,202,0,0, 1],
27-
[15, 203,203,203,203,203, 1], [116, 203,203,203,0,0, 1]]
38+
anvil_recipies = [[201, 6,0,0,0,0, 9], [14, 202,202,202,202,202, 1],
39+
[113, 202,202,202,0,0, 1], [15, 203,203,203,203,203, 1],
40+
[116, 203,203,203,0,0, 1]]
2841

2942
# Empty chest
3043
chest = [[110, 260, 0, 0], [170, 260, 0, 0], [230, 260, 0, 0], [290, 260, 0, 0], [350, 260, 0, 0], [410, 260, 0, 0], [470, 260, 0, 0], [530, 260, 0, 0], [590, 260, 0, 0],

‎main.py

+262-152
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.