-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeeper.py
More file actions
executable file
·1369 lines (1327 loc) · 64.2 KB
/
Deeper.py
File metadata and controls
executable file
·1369 lines (1327 loc) · 64.2 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import pygame, random, datetime, pickle, time, os, webbrowser
from pygame.color import THECOLORS
blockImages = ["stone.png", "dirt.png", "coalore.png", "ironore.png", "goldore.png", "clay.png", "bricks.png", "mud.png", "grass.png", "lamp.png", "legacypc.png", "craftshelf.png", "crate.png", "magma.png"]
itemImages = ["Pickaxe.png", "Iron Pickaxe.png", "Gold Pickaxe.png", "Lava Pickaxe.png"]
Background = pygame.image.load("Background.png")
Logo = pygame.image.load("DeeperIcon.jpg")
ToolbarTile = pygame.image.load("ToolbarTile.png")
CheckboxChecked = pygame.image.load("CheckboxChecked.png")
OrionDark7 = pygame.image.load("OrionDark7.png")
mostRecentWorld = open("recent.txt", "rb")
mostRecent = mostRecentWorld.readline()
mostRecentWorld.close()
screenshot = "./screenshots/screenshot"+str(random.randint(1,3))+".png"
toolbarFile = []
cavePos = []
crafting = False
#Deeper - Version 0.4 Codename Fireball:
#Copyright 2018 Orion Williams, MIT License, see LICENSE.txt
#Release Notes:
# Added Gold, Lava, and Iron Pickaxes.
# Added Magma
# Player can no longer fall out of the world.
# Revamped Menu GUI.
# Added "How to Craft" section in the crafting menu.
# Added Save & Quit options inside the in-game menu.
# Loading Screen and Saving Screen now shows please wait message.
# In the Load World Screen, you can now open the most recently played world.
class block(pygame.sprite.Sprite):
def __init__(self, position, ID):
pygame.sprite.Sprite.__init__(self)
self.trueimage = pygame.image.load(blockImages[ID])
self.id = ID
self.rect = self.trueimage.get_rect()
self.rect.centerx, self.rect.centery = position
self.activated = False
self.mined = False
self.image = self.trueimage
self.collideable = True
self.shadedSurface = pygame.surface.Surface((10, 10))
self.shadedSurface.fill([0, 0, 0])
def activate(self):
global mouseGrp
if pygame.sprite.spritecollide(self, mouseGrp, False):
self.activated = True
else:
self.activated = False
def findBlock(self):
global Toolbar, item, screen
itemNotFound = True
for i in Toolbar:
if not i == None:
if i.type == "block" and i.image == blockImages[self.id] and itemNotFound and screen == 'in_game' and i.quantity < 99:
if i.quantity < 99:
if not Toolbar[chosenBlock] == None:
if Toolbar[chosenBlock].image == 'Pickaxe.png' and random.randint(1, 10) > 5:
i.quantity += 2
else:
i.quantity += 1
else:
i.quantity += 1
itemNotFound = False
return itemNotFound
def newBlock(self):
global screen, Toolbar, item, chosenBlock
if screen == 'in_game':
if not Toolbar[chosenBlock] == None:
if Toolbar[chosenBlock].image == 'Pickaxe.png' and random.randint(1, 10) > 5:
Toolbar[Toolbar.index(None)] = item(self.id, True, 2)
elif Toolbar[chosenBlock].image == 'Iron Pickaxe.png' and random.randint(1, 10) > 4:
Toolbar[Toolbar.index(None)] = item(self.id, True, 3)
elif Toolbar[chosenBlock].image == 'Gold Pickaxe.png' and random.randint(1, 10) > 3:
Toolbar[Toolbar.index(None)] = item(self.id, True, 4)
elif Toolbar[chosenBlock].image == 'Lava Pickaxe.png' and random.randint(1, 10) > 2.5:
Toolbar[Toolbar.index(None)] = item(self.id, True, 5)
else:
Toolbar[Toolbar.index(None)] = item(self.id, True, 1)
else:
Toolbar[Toolbar.index(None)] = item(self.id, True, 1)
def mine(self):
global minedBlocks, player, blocksMined, screen, Toolbar, item
if not self.rect.centerx <= player.rect.centerx - 50 or self.rect.centerx >= player.rect.centerx + 50 or self.rect.centery <= player.rect.centery - 50 or self.rect.centery >= player.rect.centery + 50:
self.kill()
minedBlocks.add(self)
allBlocks.add(self)
self.mined = True
itemNotFound = None
if screen == 'in_game':
blocksMined += 1
itemNotFound = self.findBlock()
if itemNotFound:
try:
self.newBlock()
except:
pass
def place(self):
global world, chosenBlock, Toolbar, player, blockImages
if not self.rect.centerx <= player.rect.centerx - 50 or self.rect.centerx >= player.rect.centerx + 50 or self.rect.centery <= player.rect.centery - 50 or self.rect.centery >= player.rect.centery + 50:
self.kill()
world.add(self)
allBlocks.add(self)
self.image = pygame.image.load(Toolbar[chosenBlock].image)
self.id = blockImages.index(Toolbar[chosenBlock].image)
Toolbar[chosenBlock].use(1)
self.mined = False
if self.id == 9:
blocklighting.add(self)
def transfer(self):
global saveblock
saveBlock = saveblock(self.id, self.mined, [self.rect.centerx, self.rect.centery])
return saveBlock
def update(self, action, *sl):
self.activate()
global player, yVelocity, playerMove, playerMoveX, LegacyPC, pcOn, pcMenu, world, blockImages, Toolbar, chosenBlock, crafting, blocklighting
if action == 'mine':
if self.activated and not self.mined:
self.mine()
if self in blocklighting:
blocklighting.pop(blocklighting.index(self))
elif not Toolbar[chosenBlock] == None:
if self.activated and self.mined and Toolbar[chosenBlock].type == "block":
self.place()
elif action == 'collide' and not self.mined:
if pygame.sprite.collide_rect(self, player) and player.rect.bottom <= self.rect.top:
playerMove = self.rect.top + 5
playerWhere = 'bottom'
elif pygame.sprite.collide_rect(self, player) and player.rect.top <= self.rect.bottom and player.rect.top >= self.rect.centery:
playerMove = self.rect.bottom - 5
playerWhere = 'top'
elif pygame.sprite.collide_rect(self, player) and player.rect.right >= self.rect.left and player.rect.right <= self.rect.centerx and player.rect.centery >= self.rect.top and player.rect.centery <= self.rect.centery:
playerMoveX = -3
elif pygame.sprite.collide_rect(self, player) and player.rect.left <= self.rect.right and player.rect.left >= self.rect.centerx and player.rect.centery >= self.rect.top and player.rect.centery <= self.rect.centery:
playerMoveX = 1
elif action == 'startcollide' and not self.mined:
if pygame.sprite.collide_rect(self, player):
self.kill()
minedBlocks.add(self)
allBlocks.add(self)
self.mined = True
elif action == 'interact' and not self.mined and self.activated:
if self.id == 10:
if pcOn:
pcOn = False
else:
pcOn = True
pcMenu = "home"
LegacyPC.using = self.rect.centerx, self.rect.centery
elif self.id == 11 and not crafting:
crafting = True
elif action == 'BuildX':
for y in range(5):
if LegacyPC.using[1] == self.rect.centery + (y * 10) - 20:
for x in range(5):
if LegacyPC.using[0] == self.rect.centerx + (x * 10) - 20:
Y = 4 - y
X = 4 - x
if LegacyPC.buildXdata[Y][X] == "NoneBlock.png":
self.kill()
minedBlocks.add(self)
allBlocks.add(self)
self.mined = True
else:
self.kill()
world.add(self)
allBlocks.add(self)
self.image = pygame.image.load(LegacyPC.buildXdata[Y][X])
self.id = blockImages.index(LegacyPC.buildXdata[Y][X].lower())
self.mined = False
if self.id == 9:
blocklighting.add(self)
if LegacyPC.using[0] == self.rect.centerx and LegacyPC.using[1] == self.rect.centery and not self.id == 10:
pcOn = False
elif LegacyPC.using[0] == self.rect.centerx and LegacyPC.using[1] == self.rect.centery and self.mined:
pcOn = False
class saveblock():
def __init__(self, ID, mined, position):
self.id = ID
self.mined = mined
self.x, self.y = position
def transfer(self):
newBlock = block([self.x, self.y], self.id)
if self.mined:
newBlock.mined = True
return newBlock
class item():
def __init__(self, ID, Type, amount):
global blockImages, itemImages
if Type:
self.image = blockImages[ID]
self.type = "block"
else:
self.image = itemImages[ID]
self.type = "item"
if amount == 0:
self.quantity = 1
else:
self.quantity = amount
def use(self, times):
global chosenBlock, Toolbar
if not times == None:
self.quantity -= times
else:
self.quantity -= 1
if self.quantity <= 0:
Toolbar[Toolbar.index(self)] = None
class craftingRecipe():
def __init__(self, item, parts):
self.item = item
self.parts = parts
def craft(self):
global Toolbar
foundItems = 0
for i in self.parts:
for j in Toolbar:
if not j == None:
if i.quantity <= j.quantity and i.type == j.type and i.image == j.image:
foundItems += 1
j.use(i.quantity)
break
if foundItems == len(self.parts):
returnItem = self.item
else:
returnItem = None
return returnItem
toolbarOld = []
def loadToolbar():
global toolbarFile, toolbarOld
toolbarFile = open("toolbar.dat", "rb")
toolbarData = pickle.load(toolbarFile)
toolbarOld = toolbarData
toolbarFile.close()
def dumpToolbar():
global item, toolbarOld
toolbarFile = open("toolbar.dat", "wb")
items = [item(0, False, 1), item(11, True, 1), None, None, None]
toolbarOld = items
pickle.dump(items, toolbarFile)
try:
loadToolbar()
except:
dumpToolbar()
worldLoaded = True
tutorialAccess = True
def loadWorlds():
files = os.listdir('./worlds')
new_files = []
for i in files:
if str(i).endswith('.deep'):
new_files.append(i)
return new_files
worlds = loadWorlds()
try:
tutorialFile = open("./worlds/tutorial.deep", "rb")
except:
tutorialAccess = False
tutorialError = False
if tutorialAccess:
try:
tutorialData = pickle.load(tutorialFile)
except:
tutorialError = True
tutorialFile.close()
class LightingBlock(pygame.sprite.Sprite):
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.surface.Surface([10, 10])
self.image = self.image.convert()
self.fakeimage = pygame.surface.Surface([20, 20])
self.fakeimage = self.fakeimage.convert()
self.rect = self.fakeimage.get_rect()
self.rect.centerx, self.rect.centery = position
def update(self):
global blocklighting
if pygame.sprite.spritecollide(self, blocklighting, False):
self.image.set_alpha(0)
window.blit(self.image, (self.rect.centerx, self.rect.centery))
elif self.rect.centerx <= player.rect.centerx - 50 or self.rect.centerx >= player.rect.centerx + 50 or self.rect.centery <= player.rect.centery - 50 or self.rect.centery >= player.rect.centery + 50:
self.image.set_alpha(500)
window.blit(self.image, (self.rect.centerx, self.rect.centery))
elif self.rect.centerx <= player.rect.centerx - 40 or self.rect.centerx >= player.rect.centerx + 40 or self.rect.centery <= player.rect.centery - 40 or self.rect.centery >= player.rect.centery + 40:
self.image.set_alpha(200)
window.blit(self.image, (self.rect.centerx, self.rect.centery))
elif self.rect.centerx <= player.rect.centerx - 30 or self.rect.centerx >= player.rect.centerx + 30 or self.rect.centery <= player.rect.centery - 30 or self.rect.centery >= player.rect.centery + 30:
self.image.set_alpha(100)
window.blit(self.image, (self.rect.centerx, self.rect.centery))
class mouse(pygame.sprite.Sprite):
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.img = pygame.image.load("mouse.png")
self.rect = self.img.get_rect()
class button(pygame.sprite.Sprite):
def __init__(self, text, location, basecolor, excess_trim):
pygame.sprite.Sprite.__init__(self)
self.text = str(text)
self.font = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
if excess_trim == None:
self.excess_trim = int(0)
else:
try:
self.excess_trim = int(excess_trim)
except:
self.excess_trim = int(0)
self.surface = self.font.render(self.text, 1, (0, 0, 0))
self.base = pygame.surface.Surface([(len(self.text) * 10 + 10) + self.excess_trim, 30])
self.base.fill(THECOLORS[str(basecolor)])
self.base = self.base.convert()
self.rect = self.base.get_rect()
self.rect.centerx, self.rect.centery = location
self.activated = False
self.clicked = False
self.length = len(self.text) * 10 + 5 + self.excess_trim
def display(self):
global window
window.blit(self.base, [self.rect.centerx - 5, self.rect.centery - 5])
window.blit(self.surface, [self.rect.centerx, self.rect.centery])
def checkmouse(self):
global Mouse, MouseTriggerZone
if MouseTriggerZone(self.rect.centerx, self.rect.top, self.rect.centerx + self.length, self.rect.bottom):
self.activated = True
else:
self.activated = False
def click(self):
if self.activated:
self.clicked = True
def update(self, addclick):
self.checkmouse()
self.display()
if addclick:
self.click()
class Player(pygame.sprite.Sprite):
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("Player.png")
self.real_image = pygame.image.load("PlayerSkin.png")
self.rect = self.image.get_rect()
self.rect.centerx, self.rect.centery = position
def update(self, action):
global playerMove, playerMoveX, playerWhere, world, cavePos, achievements
if pygame.sprite.spritecollide(self, world, False):
world.update('collide')
elif player.rect.bottom > 480 or player.rect.bottom == 481:
self.rect.bottom = 480
else:
playerMove += 1
self.rect.centerx += playerMoveX
if playerWhere == 'bottom':
self.rect.centery = playerMove
elif playerWhere == 'top':
self.rect.centery = playerMove
else:
self.rect.centery = playerMove
if action == "jump":
if pygame.sprite.spritecollide(self, world, False) or player.rect.bottom == 481:
for i in range(7):
playerMove -= 2
if action == 'cavecheck':
if self.rect.centery > cavePos[0] * 10 and self.rect.centery <= cavePos[4] * 10:
achievements[1] = True
def background():
window.blit(Background, [0, 0])
def MouseTriggerZone(x1, y1, x2, y2):
if Mouse.rect.centerx >= x1 and Mouse.rect.centery >= y1 and Mouse.rect.centerx <= x2 and Mouse.rect.centery <= y2:
triggered = True
else:
triggered = False
return triggered
class in_game_menu(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.surface.Surface([240, 240])
self.image = self.image.convert()
self.rect = self.image.get_rect()
self.rect.centerx, self.rect.centery = 120, 120
self.image.fill([128, 128, 128])
self.dimSurf = pygame.surface.Surface([480, 480])
self.dimSurf.set_alpha(100)
self.upButton = pygame.image.load("UpButton.png")
self.downButton = pygame.image.load("DownButton.png")
def display(self):
global window, blockImages, chosenBlock, toolbar, Toolbar, name
window.blit(self.dimSurf, [0, 0])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
MenuFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
if not Toolbar[chosenBlock] == None:
toolbartext = MenuFont.render(str(list(Toolbar[chosenBlock].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(toolbartext, [225, 125])
toolbar(125, 125)
Achievements(125, 200)
currenttext = MenuFont.render("Current World: "+name, 0, (0, 0, 0))
window.blit(currenttext, [125, 345])
quitButton.display()
saveButton.display()
def displayCraft(self):
global window, Toolbar, craftClose, craftMenu, MouseTriggerZone, currentCraft, craftingRecipes
window.blit(self.dimSurf, [0, 0])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
window.blit(self.upButton, [125, 150])
window.blit(self.downButton, [125, 170])
MenuFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
toolbar(125, 125)
craftClose.checkmouse()
craftClose.display()
craftButton.checkmouse()
craftButton.display()
craft = craftingRecipes[currentCraft]
window.blit(pygame.image.load(craftingRecipes[currentCraft].item.image), [215, 160])
window.blit(pygame.image.load(craft.item.image), [125, 200])
titleText = MenuFont.render("How to craft "+str(list(craft.item.image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(titleText, [140, 199])
window.blit(pygame.image.load(craft.parts[0].image), [125, 220])
Text = MenuFont.render(str(craft.parts[0].quantity)+" "+str(list(craft.parts[0].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(Text, [140, 219])
if len(craft.parts) == 2:
window.blit(pygame.image.load(craft.parts[1].image), [125, 240])
Text = MenuFont.render(str(craft.parts[1].quantity)+" "+str(list(craft.parts[1].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(Text, [140, 239])
if len(craft.parts) == 3:
window.blit(pygame.image.load(craft.parts[2].image), [125, 260])
Text = MenuFont.render(str(craft.parts[2].quantity)+" "+str(list(craft.parts[2].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(Text, [140, 259])
if len(craft.parts) == 4:
window.blit(pygame.image.load(craft.parts[3].image), [125, 280])
Text = MenuFont.render(str(craft.parts[3].quantity)+" "+str(list(craft.parts[3].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(Text, [140, 279])
if len(craft.parts) == 5:
window.blit(pygame.image.load(craft.parts[4].image), [125, 300])
Text = MenuFont.render(str(craft.parts[4].quantity)+" "+str(list(craft.parts[4].image.split(".png"))[0]).capitalize(), 0, (0, 0, 0))
window.blit(Text, [140, 299])
class textbox(pygame.sprite.Sprite):
def __init__(self, width):
pygame.sprite.Sprite.__init__(self)
self.surf = pygame.surface.Surface([int(width), 30])
self.rect = self.surf.get_rect()
self.surf.fill([255, 255, 255])
self.keys = ""
def update(self, position):
window.blit(self.surf, position)
font = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
text = font.render(self.keys, 1, (0, 0, 0))
window.blit(text, [position[0]+2, position[1]+3])
def write(self, key):
if not len(self.keys) == 27:
if key == 'space':
self.keys = self.keys + " "
elif key == 'backspace':
self.keys = self.keys[0:len(self.keys) - 1]
elif not key == 'right shift' and not key == 'left shift' and not key == 'return':
self.keys = self.keys + str(key)
elif key == 'backspace':
self.keys = self.keys[0:len(self.keys) - 1]
class pcScreen(pygame.sprite.Sprite):
def __init__(self):
self.image = pygame.surface.Surface([240, 180])
self.image2 = pygame.surface.Surface([280, 250])
self.image2 = self.image2.convert()
self.quitUI = pygame.image.load("ShutdownButton.png")
self.quitUI2 = pygame.image.load("ShutdownButton2.png")
self.buildX = pygame.image.load("BuildX.png")
self.HomeButton = pygame.image.load("HomeButton.png")
self.eraseButton = pygame.image.load("EraseButton.png")
self.optionsButton = pygame.image.load("options.png")
self.upButton = pygame.image.load("UpButton.png")
self.downButton = pygame.image.load("DownButton.png")
self.buildXdata = list([["Stone.png", "Stone.png", "Stone.png", "Stone.png", "Stone.png"], ["Stone.png", "Stone.png", "Stone.png", "Stone.png", "Stone.png"], ["Stone.png", "Stone.png", "LegacyPC.png", "Stone.png", "Stone.png"], ["Stone.png", "Stone.png", "Stone.png", "Stone.png", "Stone.png"], ["Stone.png", "Stone.png", "Stone.png", "Stone.png", "Stone.png"]])
self.rect = self.image2.get_rect()
self.rect.centerx, self.rect.centery = 120, 120
self.image.fill([20, 20, 20])
self.image2.fill([239, 228, 176])
self.dimSurf = pygame.surface.Surface([480, 480])
self.dimSurf.set_alpha(100)
self.screen = "home"
self.using = 5, 5
self.eraser = False
self.screenRGB = [150, 150, 150]
def display(self, screen):
global MouseTriggerZone, clicked, pcMenu, toolbar, blockImages, chosenBlock, Toolbar, buildXgenerate, allBlocks
self.screen = str(screen)
Font = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
MonitorText = Font.render("LegacyPC", 1, (232, 216, 138))
window.blit(self.dimSurf, [0, 0])
window.blit(self.image2, [self.rect.centerx - 20, self.rect.centery - 20])
if self.screen == "home":
self.image.fill(self.screenRGB)
window.blit(self.image, [self.rect.centerx, self.rect.centery])
window.blit(self.quitUI2, [self.rect.centerx + 59, self.rect.centery])
window.blit(self.buildX, [self.rect.centerx, self.rect.centery])
window.blit(self.optionsButton, [self.rect.centerx + 79, self.rect.centery])
if MouseTriggerZone(self.rect.centerx + 59, self.rect.centery, self.rect.centerx + 79, self.rect.centery + 20) and clicked:
pcMenu = "off"
elif MouseTriggerZone(self.rect.centerx, self.rect.centery, self.rect.centerx + 58, self.rect.centery + 20) and clicked:
pcMenu = "BuildX"
elif MouseTriggerZone(self.rect.centerx + 79, self.rect.centery, self.rect.centerx + 137, self.rect.centery + 20) and clicked:
pcMenu = "Options"
elif self.screen == "BuildX":
self.image.fill([200, 200, 200])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
BuildXtitle = Font.render("BuildX 1.0", 1, (0, 0, 0))
window.blit(BuildXtitle, [self.rect.centerx + 5, self.rect.centery + 5])
toolbar(self.rect.centerx + 5, self.rect.centery + 25)
window.blit(self.HomeButton, [self.rect.centerx + 220, self.rect.centery])
buildXgenerate.checkmouse()
buildXgenerate.display()
window.blit(self.eraseButton, [self.rect.centerx + 80, self.rect.centery + 25])
for y in range(5):
for x in range(5):
BlockImg = pygame.image.load(self.buildXdata[y][x])
window.blit(BlockImg, [self.rect.centerx + (x * 10) + 5, self.rect.centery + (y * 10) + 50])
if MouseTriggerZone(self.rect.centerx + (x * 10) + 5, self.rect.centery + (y * 10) + 50, self.rect.centerx + (x * 10) + 15, self.rect.centery + (y * 10) + 60) and clicked:
if self.eraser or Toolbar[chosenBlock] == None:
BlockImg = pygame.image.load("NoneBlock.png")
self.buildXdata[y][x] = "NoneBlock.png"
else:
if Toolbar[chosenBlock].type == 'block':
BlockImg = pygame.image.load(Toolbar[chosenBlock].image)
self.buildXdata[y][x] = Toolbar[chosenBlock].image
Toolbar[chosenBlock].use(1)
else:
BlockImg = pygame.image.load(self.buildXdata[y][x])
window.blit(BlockImg, [self.rect.centerx + (x * 10) + 5, self.rect.centery + (y * 10) + 50])
if self.eraser:
pygame.draw.rect(window, (0, 255, 255), (self.rect.centerx + 80, self.rect.centery + 45, 20, 2))
if MouseTriggerZone(self.rect.centerx + 220, self.rect.centery, self.rect.centerx + 235, self.rect.centery + 15) and clicked:
pcMenu = "home"
elif MouseTriggerZone(self.rect.centerx + 80, self.rect.centery + 25, self.rect.centerx + 100, self.rect.centery + 45) and clicked:
if self.eraser:
self.eraser = False
else:
self.eraser = True
elif buildXgenerate.activated and clicked:
pcMenu = "BuildX Generate"
elif self.screen == "BuildX Generate":
self.image.fill([200, 200, 200])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
allBlocks.update("BuildX", [self.rect.centerx, self.rect.centery])
pcMenu = "BuildX"
elif self.screen == "Options":
self.image.fill([150, 150, 150])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
ScrColor = Font.render("Screen Color", 1, (0, 0, 0))
window.blit(ScrColor, [self.rect.centerx + 5, self.rect.centery + 5])
Red = Font.render(str(self.screenRGB[0]), 1, (0, 0, 0))
window.blit(Red, [self.rect.centerx + 5, self.rect.centery + 30])
window.blit(self.upButton, [self.rect.centerx + 45, self.rect.centery + 30])
window.blit(self.downButton, [self.rect.centerx + 45, self.rect.centery + 40])
Green = Font.render(str(self.screenRGB[1]), 1, (0, 0, 0))
window.blit(Green, [self.rect.centerx + 65, self.rect.centery + 30])
window.blit(self.upButton, [self.rect.centerx + 105, self.rect.centery + 30])
window.blit(self.downButton, [self.rect.centerx + 105, self.rect.centery + 40])
Blue = Font.render(str(self.screenRGB[2]), 1, (0, 0, 0))
window.blit(Blue, [self.rect.centerx + 125, self.rect.centery + 30])
window.blit(self.upButton, [self.rect.centerx + 165, self.rect.centery + 30])
window.blit(self.downButton, [self.rect.centerx + 165, self.rect.centery + 40])
if MouseTriggerZone(self.rect.centerx + 45, self.rect.centery + 30, self.rect.centerx + 65, self.rect.centery + 39) and clicked and self.screenRGB[0] < 255:
self.screenRGB[0] += 15
elif MouseTriggerZone(self.rect.centerx + 45, self.rect.centery + 40, self.rect.centerx + 65, self.rect.centery + 49) and clicked and self.screenRGB[0] > 0:
self.screenRGB[0] -= 15
if MouseTriggerZone(self.rect.centerx + 105, self.rect.centery + 30, self.rect.centerx + 125, self.rect.centery + 39) and clicked and self.screenRGB[1] < 255:
self.screenRGB[1] += 15
elif MouseTriggerZone(self.rect.centerx + 105, self.rect.centery + 40, self.rect.centerx + 125, self.rect.centery + 49) and clicked and self.screenRGB[1] > 0:
self.screenRGB[1] -= 15
if MouseTriggerZone(self.rect.centerx + 165, self.rect.centery + 30, self.rect.centerx + 185, self.rect.centery + 39) and clicked and self.screenRGB[2] < 255:
self.screenRGB[2] += 15
elif MouseTriggerZone(self.rect.centerx + 165, self.rect.centery + 40, self.rect.centerx + 185, self.rect.centery + 49) and clicked and self.screenRGB[2] > 0:
self.screenRGB[2] -= 15
elif self.screen == "off":
self.image.fill([20, 20, 20])
window.blit(self.image, [self.rect.centerx, self.rect.centery])
window.blit(self.quitUI, [self.rect.centerx + 220, self.rect.centery + 195])
window.blit(MonitorText, [self.rect.centerx + 70, self.rect.centery + 195])
def quitUIclicked(self):
global MouseTriggerZone
if MouseTriggerZone(self.rect.centerx + 220, self.rect.centery + 195, self.rect.centerx + 235, self.rect.centery + 210):
isclicked = True
else:
isclicked = False
return isclicked
def loading():
global window
window.fill((0, 0, 0))
window.blit(OrionDark7, [221, 221])
font = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
urlfont = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
credit = font.render("Built by OrionDark7", 1, (255, 255, 255))
url = urlfont.render("http://oriondark7.com", 1, (255, 255, 255))
window.blit(credit, [160, 265])
window.blit(url, [190, 290])
pygame.display.flip()
def menu():
global window, Logo, screenshot, version
background()
topbar = pygame.surface.Surface([480, 100])
topbar.fill([128, 128, 128])
window.blit(topbar, [0, 0])
window.blit(Logo, [20, 20])
textFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 15)
textRender = textFont.render("Deeper", 1, (255, 255, 255))
smallTextFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
versionText = smallTextFont.render("Deeper "+version, 1, (255, 255, 255))
window.blit(textRender, [100, 35])
window.blit(versionText, [240, 325])
menuButton.update(False)
exitButton.update(False)
helpButton.update(False)
webButton.update(False)
window.blit(pygame.image.load('Pickaxe.png'), [10, 130])
window.blit(pygame.image.load('Lamp.png'), [10, 180])
window.blit(pygame.image.load('legacypc.png'), [10, 230])
window.blit(pygame.image.load('NoneBlock.png'), [10, 280])
window.blit(pygame.image.load(screenshot), [240, 0])
window.blit(OrionDark7, [2, 440])
pygame.display.flip()
def help_menu():
global window
background()
textFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 15)
smallFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 7)
helpText = textFont.render("Deeper Help Center", 1, (255, 255, 255))
text1 = smallFont.render("Deeper is a 2D Sandbox Game about mining, building, & exploring.", 1, (255, 255, 255))
text2 = smallFont.render("Press A & D to move, and press space to jump.", 1, (255, 255, 255))
text3 = smallFont.render("To mine blocks, click on a block in range.", 1, (255, 255, 255))
text4 = smallFont.render("To place blocks, click on an empty space in range.", 1, (255, 255, 255))
text5 = smallFont.render("To access your toolbar & achievements, press E.", 1, (255, 255, 255))
text6 = smallFont.render("To change the items, go to your toolbar, and click on the item.", 1, (255, 255, 255))
text7 = smallFont.render("To interact with blocks, right-click on the block.", 1, (255, 255, 255))
window.blit(helpText, [100, 25])
window.blit(text1, [25, 75])
window.blit(text2, [25, 90])
window.blit(text3, [25, 105])
window.blit(text4, [25, 120])
window.blit(text5, [25, 135])
window.blit(text6, [25, 150])
window.blit(text7, [25, 165])
backButton.update(False)
def choose_world():
background()
titlefont = pygame.font.Font("PixelFJVerdana12pt.TTF", 20)
title = titlefont.render("Choose World", 0, (255, 255, 255))
window.blit(title, [110, 10])
loadButton.update(False)
newButton.update(False)
backButton.update(False)
pygame.display.flip()
def new_world():
global world_type
background()
titlefont = pygame.font.Font("PixelFJVerdana12pt.TTF", 20)
title = titlefont.render("New World", 0, (255, 255, 255))
font = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
worldType = font.render("World Type", 0, (255, 255, 255))
worldName = font.render("World Name", 0, (255, 255, 255))
window.blit(title, [140, 10])
window.blit(worldName, [15, 137])
window.blit(worldType, [15, 237])
if world_type:
window.blit(CheckboxChecked, [15, 278])
window.blit(ToolbarTile, [15, 328])
window.blit(ToolbarTile, [15, 378])
if not world_type:
window.blit(ToolbarTile, [15, 278])
window.blit(CheckboxChecked, [15, 328])
window.blit(ToolbarTile, [15, 378])
if world_type == 'tutorial':
window.blit(ToolbarTile, [15, 278])
window.blit(ToolbarTile, [15, 328])
window.blit(CheckboxChecked, [15, 378])
box.update([10, 175])
goButton.update(False)
basicButton.update(False)
minersButton.update(False)
tutorialButton.update(False)
backButton.update(False)
pygame.display.flip()
def load_world():
global mostRecent
background()
titlefont = pygame.font.Font("PixelFJVerdana12pt.TTF", 20)
title = titlefont.render("Load World", 0, (255, 255, 255))
font = pygame.font.Font("PixelFJVerdana12pt.TTF", 10)
worldName = font.render("World Name", 0, (255, 255, 255))
mrwText = font.render("Most Recent World: " + mostRecent, 0, (255, 255, 255))
window.blit(mrwText, [5, 450])
window.blit(worldName, [50, 200])
window.blit(title, [130, 10])
worldbox.update([50, 225])
goButton2.update(False)
backButton.update(False)
loadRecentButton.update(False)
pygame.display.flip()
def display_world():
global world, window
background()
world.draw(window)
def Tutorial():
global window, pygame
if tutorialIndex <= int(len(tutorial) - 1):
surface = pygame.surface.Surface((480, 50))
surface.fill([128, 128, 128])
font = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
text = font.render(tutorial[tutorialIndex], 1, (0, 0, 0))
window.blit(surface, [0, 430])
window.blit(text, [5, 450])
def generate_world(Basic):
Id = 0
Coal = 0
Iron = 0
Gold = 0
Magma = 0
Airspace = 0
Crate = 0
global player, players, playerSpawned, world, screen, achievements, cavePos, Toolbar, toolbarData, worldData, blocklighting
cavePos.append(int(random.randint(1, 42)))
playerSpawnX = random.randint(0, 47)
window.fill(THECOLORS['black'])
LoadingFont = pygame.font.Font("PixelFJVerdana12pt.ttf", 10)
LoadingRender = LoadingFont.render("Generating World, please wait...", 0, (255, 255, 255))
window.blit(LoadingRender, [10, 10])
pygame.display.flip()
if Basic == 'load':
for i in worldData:
Block = i.transfer()
if Block.rect.centery == 5 and Block.rect.centerx == (playerSpawnX * 10) + 5:
player = Player([Block.rect.centerx - 2, Block.rect.centery - 5])
playerSpawned = True
else:
if Block.mined:
minedBlocks.add(Block)
else:
world.add(Block)
if Block.id == 9 and not Block.mined:
blocklighting.add(Block)
allBlocks.add(Block)
lightBlock = LightingBlock([Block.rect.centerx - 5, Block.rect.centery - 5])
lighting.add(lightBlock)
elif Basic == 'tutorial':
for i in tutorialData:
Block = i.transfer()
if Block.rect.centery == 5 and Block.rect.centerx == (playerSpawnX * 10) + 5:
player = Player([Block.rect.centerx - 2, Block.rect.centery - 5])
playerSpawned = True
else:
if Block.mined:
minedBlocks.add(Block)
else:
world.add(Block)
if Block.id == 9 and not Block.mined:
blocklighting.add(Block)
allBlocks.add(Block)
lightBlock = LightingBlock([Block.rect.centerx - 5, Block.rect.centery - 5])
lighting.add(lightBlock)
elif Basic:
for y in range(48):
for x in range(48):
if y == 0 and x == playerSpawnX:
player = Player([x * 10 + 2, y * 10])
playerSpawned = True
Id = None
if not Id == None:
Block = block([(x*10) + 5, (y*10) + 5], Id)
lightingBlock = LightingBlock([(x*10), (y*10)])
world.add(Block)
allBlocks.add(Block)
lighting.add(lightingBlock)
if Id == None:
Id = 0
Block = block([(x*10) + 5, (y*10) + 5], Id)
lightingBlock = LightingBlock([(x*10), (y*10)])
minedBlocks.add(Block)
allBlocks.add(Block)
lighting.add(lightingBlock)
Block.mined = True
Block.mine()
window.fill(THECOLORS['black'])
LoadingFont = pygame.font.Font("PixelFJVerdana12pt.ttf", 10)
LoadingRender = LoadingFont.render("Generating World, please wait...", 0, (255, 255, 255))
window.blit(LoadingRender, [10, 10])
pygame.display.flip()
else:
for c in range(4):
cavePos.append(cavePos[c] + 1)
for y in range(48):
for x in range(48):
if y in cavePos:
Airspace = int(random.randint(1, 10))
if Airspace > 5 and not cavePos[1] == y and not cavePos[2] == y and not cavePos[3] == y:
Id = None
elif Airspace <= 5 and not cavePos[1] == y and not cavePos[2] == y and not cavePos[3] == y:
Id = 0
else:
Id = None
else:
Crate = random.randint(1, 100)
if Crate == 1:
Id = 12
elif y < 10:
Coal = int(random.randint(1, 10))
if Coal > 7:
Id = int(random.randint(0, 2))
else:
Id = int(random.randint(0, 1))
if Id == 1:
if int(random.randint(0, 4)) > 2:
Id = 5
else:
Id = 1
if y == 0 and x == playerSpawnX:
player = Player([x * 10 + 2, y * 10 + 1])
playerSpawned = True
Id = None
elif y > 20 and y < 30:
Iron = int(random.randint(1, 10))
Coal = int(random.randint(1, 10))
if Iron > 9:
Id = 3
else:
if Coal > 9:
Id = 2
else:
Id = 0
elif y > 30 and y < 38:
Iron = int(random.randint(1, 10))
Gold = int(random.randint(1, 10))
Coal = int(random.randint(1, 20))
if Gold > 9:
Id = 4
else:
if Iron > 9:
Id = 3
else:
if Coal > 19:
Id = 2
else:
Id = 0
elif y > 38:
Magma = int(random.randint(1, 10))
if Magma > 3:
Id = 13
else:
Id = 0
else:
Coal = int(random.randint(1, 10))
if Coal == 10:
Id = 2
else:
Id = 0
if not Id == None:
Block = block([(x*10) + 5, (y*10) + 5], Id)
lightingBlock = LightingBlock([(x*10), (y*10)])
world.add(Block)
allBlocks.add(Block)
lighting.add(lightingBlock)
if Id == None:
Id = 0
Block = block([(x*10) + 5, (y*10) + 5], Id)
lightingBlock = LightingBlock([(x*10), (y*10)])
minedBlocks.add(Block)
allBlocks.add(Block)
lighting.add(lightingBlock)
Block.mined = True
Block.mine()
window.fill(THECOLORS['black'])
LoadingFont = pygame.font.Font("PixelFJVerdana12pt.ttf", 10)
LoadingRender = LoadingFont.render("Generating World, please wait...", 0, (255, 255, 255))
window.blit(LoadingRender, [10, 10])
pygame.display.flip()
world.update('startcollide')
screen = "in_game"
achievements[0] = True
def toolbar(x, y):
global chosenBlock
ItemFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
if not Toolbar[0] == None:
item1 = ItemFont.render(str(Toolbar[0].quantity), 1, (255, 255, 255))
else:
item1 = None
if not Toolbar[1] == None:
item2 = ItemFont.render(str(Toolbar[1].quantity), 1, (255, 255, 255))
else:
item2 = None
if not Toolbar[2] == None:
item3 = ItemFont.render(str(Toolbar[2].quantity), 1, (255, 255, 255))
else:
item3 = None
if not Toolbar[3] == None:
item4 = ItemFont.render(str(Toolbar[3].quantity), 1, (255, 255, 255))
else:
item4 = None
if not Toolbar[4] == None:
item5 = ItemFont.render(str(Toolbar[4].quantity), 1, (255, 255, 255))
else:
item5 = None
window.blit(ToolbarTile, [x, y])
if not Toolbar[0] == None:
window.blit(pygame.image.load(Toolbar[0].image), [x + 2, y + 2])
window.blit(item1, [x - 2, y - 2])
else:
Toolbar[0] = None
window.blit(ToolbarTile, [x + 15, y])
if MouseTriggerZone(x, y, x + 14, y + 14) and clicked:
chosenBlock = 0
if not Toolbar[1] == None:
window.blit(pygame.image.load(Toolbar[1].image), [x + 17, y + 2])
window.blit(item2, [x + 13, y - 2])
else:
Toolbar[1] = None
window.blit(ToolbarTile, [x + 30, y])
if MouseTriggerZone(x + 15, y, x + 29, y + 14) and clicked:
chosenBlock = 1
if not Toolbar[2] == None:
window.blit(pygame.image.load(Toolbar[2].image), [x + 32, y + 2])
window.blit(item3, [x + 28, y - 2])
else:
Toolbar[2] = None
window.blit(ToolbarTile, [x + 45, y])
if MouseTriggerZone(x + 30, y, x + 44, y + 14) and clicked:
chosenBlock = 2
if not Toolbar[3] == None:
window.blit(pygame.image.load(Toolbar[3].image), [x + 47, y + 2])
window.blit(item4, [x + 43, y - 2])
else:
Toolbar[3] = None
window.blit(ToolbarTile, [x + 60, y])
if MouseTriggerZone(x + 45, y, x + 59, y + 14) and clicked:
chosenBlock = 3
if not Toolbar[4] == None:
window.blit(pygame.image.load(Toolbar[4].image), [x + 62, y + 2])
window.blit(item5, [x + 58, y - 2])
else:
Toolbar[4] = None
if MouseTriggerZone(x + 60, y, x + 74, y + 14) and clicked:
chosenBlock = 4
pygame.draw.rect(window, (0, 255, 255), (x + (chosenBlock * 15), y + 14, 14, 2))
def Achievements(x, y):
global CheckboxChecked, blocksMined
if achievements[0] == None:
window.blit(ToolbarTile, [x, y])
else:
window.blit(CheckboxChecked, [x, y])
achievementFont = pygame.font.Font("PixelFJVerdana12pt.TTF", 5)
achieve1 = achievementFont.render("Beginning - Start a World", 1, (0, 0, 0))
window.blit(achieve1, [x + 20, y])
if world_type == False:
if achievements[1] == None:
window.blit(ToolbarTile, [x, y + 25])
else:
window.blit(CheckboxChecked, [x, y + 25])
achieve2 = achievementFont.render("Explorer - Find a cave", 1, (0, 0, 0))
window.blit(achieve2, [x + 20, y + 25])
if blocksMined >= 100:
achievements[2] = True
if achievements[2] == None:
window.blit(ToolbarTile, [x, y + 50])
else:
window.blit(CheckboxChecked, [x, y + 50])
achieve3 = achievementFont.render("Miner - Mine 100 Blocks", 1, (0, 0, 0))
window.blit(achieve3, [x + 20, y + 50])
pygame.init()
version = "0.4"
window = pygame.display.set_mode([480, 480])
pygame.display.set_caption("Deeper " + version)
pygame.display.set_icon(pygame.image.load("DeeperIcon.jpg"))
Mouse = mouse((0, 0))
LegacyPC = pcScreen()