Skip to content

Commit 4f8c9b9

Browse files
DiscordRP + Image Loading + Fire Fix
1 parent 1fa57a3 commit 4f8c9b9

File tree

4 files changed

+50
-26
lines changed

4 files changed

+50
-26
lines changed

game/blocks/CubeHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def add(self, p, t, now=False):
100100
if p in self.cubes:
101101
return
102102
cube = self.cubes[p] = Cube(t, p, self.block[t],
103-
'alpha' if t in self.alpha_textures else 'blend' if (t == 'water' or t == "lava")
103+
'alpha' if t in self.alpha_textures else 'blend' if (t == 'water' or t == "lava" or t =="fire")
104104
else 'solid')
105105

106106
for adj in adjacent(*cube.p):

game/blocks/droppedBlock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ def update(self):
105105
if roundPos((i[1][0][0], i[1][0][1], i[1][0][2])) not in self.gl.cubes.cubes:
106106
yy -= 0.1
107107
self.blocks[i[0]][0] = (i[1][0][0], yy, i[1][0][2])
108-
self.blocks[i[0]][4] = i[1][4]
108+
self.blocks[i[0]][4] = i[1][4]

main.py

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,27 @@
3232
#gc.set_debug(gc.DEBUG_LEAK)
3333

3434

35-
programIcon = pygame.image.load('textures/pycraft-32.png')
35+
36+
working_dir = os.path.dirname(os.path.realpath(__file__))
37+
image_dir = os.path.join(working_dir, 'textures')
38+
sound_dir = os.path.join(working_dir, 'sounds')
39+
gui_dir = os.path.join(working_dir, 'gui')
40+
41+
pyglet.resource.path = [working_dir, image_dir, sound_dir, gui_dir]
42+
pyglet.resource.reindex()
43+
44+
programIcon = pygame.image.load('textures\pycraft-32.png')
3645

3746
pygame.display.set_icon(programIcon)
3847

48+
pygame.DOUBLEBUF
49+
3950
client_id = "851879525590630411"
4051
RPC = Presence(client_id)
41-
RPC.connect()
4252

53+
if DiscordRP == True:
54+
RPC.connect()
55+
RPC.update(state="Loading", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
4356

4457
def respawn():
4558
pause()
@@ -255,7 +268,9 @@ def genWorld(mc):
255268
IN_MENU = False
256269
PAUSE = False
257270

258-
RPC.update(state="In Game", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
271+
if DiscordRP == True:
272+
#RPC.connect()
273+
RPC.update(state="In Game", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
259274

260275

261276
proc = round((scene.worldGen.start - len(scene.worldGen.queue)) * 100 / chunkCnt)
@@ -273,7 +288,10 @@ def drawMainMenu(mc):
273288
glFogf(GL_FOG_START, 0)
274289
glFogf(GL_FOG_END, 1000)
275290

276-
RPC.update(state="On the Main Menu", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
291+
292+
if DiscordRP == True:
293+
#RPC.connect()
294+
RPC.update(state="On the Main Menu", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
277295

278296

279297
scene.set3d()
@@ -339,7 +357,10 @@ def drawMainMenu(mc):
339357

340358
print("Loading the game...")
341359

342-
RPC.update(state="Loading PyCraft...", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
360+
#if DiscordRP == True:
361+
# RPC.connect()
362+
# RPC.update(state="Loading PyCraft...", large_image="icon", large_text="PyCraft: Made By IAJ", buttons=[{"label": "PyCraft Github", "url": "https://github.com/IAJWasTooShort/PyCraft"}])
363+
343364

344365
resizeEvent = False
345366
LAST_SAVED_RESOLUTION = [WIDTH, HEIGHT]
@@ -357,7 +378,7 @@ def drawMainMenu(mc):
357378
glLoadIdentity()
358379
gluOrtho2D(0, WIDTH, 0, HEIGHT)
359380

360-
logo = pyglet.resource.image("gui/logo.png")
381+
logo = pyglet.resource.image("logo.png")
361382
logo.blit(WIDTH // 2 - (logo.width // 2), HEIGHT // 2 - (logo.height // 2))
362383
pygame.display.flip()
363384

@@ -454,24 +475,25 @@ def drawMainMenu(mc):
454475
print("Music loaded!")
455476

456477
print("Loading GUI textures...")
478+
#gui/
457479
gui.GUI_TEXTURES = {
458-
"crafting_table": pyglet.resource.image("gui/crafting_table.png"),
459-
"inventory_window": pyglet.resource.image("gui/inventory_window.png"),
460-
"crosshair": pyglet.resource.image("gui/crosshair.png"),
461-
"inventory": pyglet.resource.image("gui/inventory.png"),
462-
"sel_inventory": pyglet.resource.image("gui/sel_inventory.png"),
463-
"fullheart": pyglet.resource.image("gui/fullheart.png"),
464-
"halfheart": pyglet.resource.image("gui/halfheart.png"),
465-
"heartbg": pyglet.resource.image("gui/heartbg.png"),
466-
"game_logo": pyglet.resource.image("gui/game_logo.png"),
467-
"button_bg": pyglet.resource.image("gui/gui_elements/button_bg.png"),
468-
"button_bg_hover": pyglet.resource.image("gui/gui_elements/button_bg_hover.png"),
469-
"edit_bg": pyglet.resource.image("gui/gui_elements/edit_bg.png"),
470-
"options_background": pyglet.resource.image("gui/gui_elements/options_background.png"),
471-
"black": pyglet.resource.image("gui/gui_elements/black.png"),
472-
"red": pyglet.resource.image("gui/gui_elements/red.png"),
473-
"selected": pyglet.resource.image("gui/gui_elements/selected.png"),
474-
"slider": pyglet.resource.image("gui/gui_elements/slider.png"),
480+
"crafting_table": pyglet.resource.image("crafting_table.png"),
481+
"inventory_window": pyglet.resource.image("inventory_window.png"),
482+
"crosshair": pyglet.resource.image("crosshair.png"),
483+
"inventory": pyglet.resource.image("inventory.png"),
484+
"sel_inventory": pyglet.resource.image("sel_inventory.png"),
485+
"fullheart": pyglet.resource.image("fullheart.png"),
486+
"halfheart": pyglet.resource.image("halfheart.png"),
487+
"heartbg": pyglet.resource.image("heartbg.png"),
488+
"game_logo": pyglet.resource.image("game_logo.png"),
489+
"button_bg": pyglet.resource.image("gui_elements/button_bg.png"),
490+
"button_bg_hover": pyglet.resource.image("gui_elements/button_bg_hover.png"),
491+
"edit_bg": pyglet.resource.image("gui_elements/edit_bg.png"),
492+
"options_background": pyglet.resource.image("gui_elements/options_background.png"),
493+
"black": pyglet.resource.image("gui_elements/black.png"),
494+
"red": pyglet.resource.image("gui_elements/red.png"),
495+
"selected": pyglet.resource.image("gui_elements/selected.png"),
496+
"slider": pyglet.resource.image("gui_elements/slider.png"),
475497
}
476498

477499
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
@@ -547,7 +569,7 @@ def drawMainMenu(mc):
547569
showInfoLabel = False
548570

549571
print("Loading splashes...")
550-
splfile = open("gui/splashes.txt", "r", encoding='utf-8')
572+
splfile = open("gui\splashes.txt", "r", encoding='utf-8')
551573
splash = splfile.read().split("\n")
552574
splash = splash[randint(0, len(splash) - 1)]
553575
splfile.close()

settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
VERSION = "Alpha 0.1 Test"
1818
clock = pygame.time.Clock()
1919

20+
DiscordRP = True
21+
2022
FOV = 100
2123
RENDER_DISTANCE = 100
2224

0 commit comments

Comments
 (0)