Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,13 @@ def __init__(self, *args, **kwargs):
x=10, y=self.height - 10, anchor_x='left', anchor_y='top',
color=(0, 0, 0, 255))

# Boolean whether to display loading screen
self.is_initializing = True
# Loading screen label displayed in center of canvas
self.loading_label = pyglet.text.Label('', font_name='Arial', font_size=100,
x=self.width // 2, y=self.height // 2, anchor_x='center', anchor_y='center',
color=(0, 0, 0, 255))

# This call schedules the `update()` method to be called
# TICKS_PER_SEC. This is the main game event loop.
pyglet.clock.schedule_interval(self.update, 1.0 / TICKS_PER_SEC)
Expand Down Expand Up @@ -803,13 +810,18 @@ def on_draw(self):

"""
self.clear()
self.set_3d()
glColor3d(1, 1, 1)
self.model.batch.draw()
self.draw_focused_block()
if not self.is_initializing:
self.set_3d()
glColor3d(1, 1, 1)
self.model.batch.draw()
self.draw_focused_block()
self.set_2d()
self.draw_reticle()
self.set_2d()
self.draw_label()
self.draw_reticle()
if self.is_initializing:
self.loading_label.delete()
self.is_initializing = False

def draw_focused_block(self):
""" Draw black edges around the block that is currently under the
Expand All @@ -830,18 +842,24 @@ def draw_label(self):
""" Draw the label in the top left of the screen.

"""
x, y, z = self.position
self.label.text = '%02d (%.2f, %.2f, %.2f) %d / %d' % (
pyglet.clock.get_fps(), x, y, z,
len(self.model._shown), len(self.model.world))
self.label.draw()
if not self.is_initializing:
x, y, z = self.position
self.label.text = '%02d (%.2f, %.2f, %.2f) %d / %d' % (
pyglet.clock.get_fps(), x, y, z,
len(self.model._shown), len(self.model.world))
self.label.draw()
else:
# Only draw the loading screen during the first draw loop
self.loading_label.text = 'Loading...'
self.loading_label.draw()

def draw_reticle(self):
""" Draw the crosshairs in the center of the screen.

"""
glColor3d(0, 0, 0)
self.reticle.draw(GL_LINES)
if not self.is_initializing:
glColor3d(0, 0, 0)
self.reticle.draw(GL_LINES)


def setup_fog():
Expand Down