From 65b4a25a28303577a450deae2a2524a5e7a3f0d5 Mon Sep 17 00:00:00 2001 From: Yuval Date: Mon, 8 Jun 2026 20:29:11 +0300 Subject: [PATCH 1/2] my commits --- main.py | 809 ++++++++++++++++++++-------------------------------- texture.png | Bin 5257 -> 8797 bytes 2 files changed, 317 insertions(+), 492 deletions(-) diff --git a/main.py b/main.py index 6332d97a..1343b1f1 100644 --- a/main.py +++ b/main.py @@ -1,59 +1,40 @@ -from __future__ import division - -import sys import math import random import time - from collections import deque + +import pyglet from pyglet import image from pyglet.gl import * from pyglet.graphics import TextureGroup from pyglet.window import key, mouse TICKS_PER_SEC = 60 - -# Size of sectors used to ease block loading. SECTOR_SIZE = 16 - WALKING_SPEED = 5 FLYING_SPEED = 15 GRAVITY = 20.0 -MAX_JUMP_HEIGHT = 1.0 # About the height of a block. -# To derive the formula for calculating jump speed, first solve -# v_t = v_0 + a * t -# for the time at which you achieve maximum height, where a is the acceleration -# due to gravity and v_t = 0. This gives: -# t = - v_0 / a -# Use t and the desired MAX_JUMP_HEIGHT to solve for v_0 (jump speed) in -# s = s_0 + v_0 * t + (a * t^2) / 2 +MAX_JUMP_HEIGHT = 1.0 JUMP_SPEED = math.sqrt(2 * GRAVITY * MAX_JUMP_HEIGHT) TERMINAL_VELOCITY = 50 - PLAYER_HEIGHT = 2 -if sys.version_info[0] >= 3: - xrange = range def cube_vertices(x, y, z, n): - """ Return the vertices of the cube at position x, y, z with size 2*n. - - """ + """ Return the vertices of the cube at position x, y, z with size 2*n. """ return [ - x-n,y+n,z-n, x-n,y+n,z+n, x+n,y+n,z+n, x+n,y+n,z-n, # top - x-n,y-n,z-n, x+n,y-n,z-n, x+n,y-n,z+n, x-n,y-n,z+n, # bottom - x-n,y-n,z-n, x-n,y-n,z+n, x-n,y+n,z+n, x-n,y+n,z-n, # left - x+n,y-n,z+n, x+n,y-n,z-n, x+n,y+n,z-n, x+n,y+n,z+n, # right - x-n,y-n,z+n, x+n,y-n,z+n, x+n,y+n,z+n, x-n,y+n,z+n, # front - x+n,y-n,z-n, x-n,y-n,z-n, x-n,y+n,z-n, x+n,y+n,z-n, # back + x - n, y + n, z - n, x - n, y + n, z + n, x + n, y + n, z + n, x + n, y + n, z - n, + x - n, y - n, z - n, x + n, y - n, z - n, x + n, y - n, z + n, x - n, y - n, z + n, + x - n, y - n, z - n, x - n, y - n, z + n, x - n, y + n, z + n, x - n, y + n, z - n, + x + n, y - n, z + n, x + n, y - n, z - n, x + n, y + n, z - n, x + n, y + n, z + n, + x - n, y - n, z + n, x + n, y - n, z + n, x + n, y + n, z + n, x - n, y + n, z + n, + x + n, y - n, z - n, x - n, y - n, z - n, x - n, y + n, z - n, x + n, y + n, z - n, ] def tex_coord(x, y, n=4): - """ Return the bounding vertices of the texture square. - - """ + """ Return the bounding vertices of the texture square. """ m = 1.0 / n dx = x * m dy = y * m @@ -61,16 +42,14 @@ def tex_coord(x, y, n=4): def tex_coords(top, bottom, side): - """ Return a list of the texture squares for the top, bottom and side. - - """ - top = tex_coord(*top) - bottom = tex_coord(*bottom) - side = tex_coord(*side) + """ Return a list of the texture squares for the top, bottom and side. """ + top_coords = tex_coord(*top) + bottom_coords = tex_coord(*bottom) + side_coords = tex_coord(*side) result = [] - result.extend(top) - result.extend(bottom) - result.extend(side * 4) + result.extend(top_coords) + result.extend(bottom_coords) + result.extend(side_coords * 4) return result @@ -79,139 +58,116 @@ def tex_coords(top, bottom, side): GRASS = tex_coords((1, 0), (0, 1), (0, 0)) SAND = tex_coords((1, 1), (1, 1), (1, 1)) BRICK = tex_coords((2, 0), (2, 0), (2, 0)) -STONE = tex_coords((2, 1), (2, 1), (2, 1)) +BEDROCK = tex_coords((2, 1), (2, 1), (2, 1)) + +OAK_LOG = tex_coords((3, 2), (3, 2), (3, 1)) +OAK_PLANKS = tex_coords((3, 0), (3, 0), (3, 0)) +OAK_LEAVES = tex_coords((2, 2), (2, 2), (2, 2)) +STONE = tex_coords((1, 2), (1, 2), (1, 2)) FACES = [ - ( 0, 1, 0), - ( 0,-1, 0), + (0, 1, 0), + (0, -1, 0), (-1, 0, 0), - ( 1, 0, 0), - ( 0, 0, 1), - ( 0, 0,-1), + (1, 0, 0), + (0, 0, 1), + (0, 0, -1), ] def normalize(position): - """ Accepts `position` of arbitrary precision and returns the block - containing that position. - - Parameters - ---------- - position : tuple of len 3 - - Returns - ------- - block_position : tuple of ints of len 3 - - """ + """ Accepts `position` of arbitrary precision and returns the block containing that position. """ x, y, z = position - x, y, z = (int(round(x)), int(round(y)), int(round(z))) - return (x, y, z) + return int(round(x)), int(round(y)), int(round(z)) def sectorize(position): - """ Returns a tuple representing the sector for the given `position`. - - Parameters - ---------- - position : tuple of len 3 - - Returns - ------- - sector : tuple of len 3 - - """ + """ Returns a tuple representing the sector for the given `position`. """ x, y, z = normalize(position) - x, y, z = x // SECTOR_SIZE, y // SECTOR_SIZE, z // SECTOR_SIZE - return (x, 0, z) + return x // SECTOR_SIZE, 0, z // SECTOR_SIZE -class Model(object): - +class Model: def __init__(self): - - # A Batch is a collection of vertex lists for batched rendering. self.batch = pyglet.graphics.Batch() - - # A TextureGroup manages an OpenGL texture. self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture()) - - # A mapping from position to the texture of the block at that position. - # This defines all the blocks that are currently in the world. self.world = {} - - # Same mapping as `world` but only contains blocks that are shown. self.shown = {} - - # Mapping from position to a pyglet `VertextList` for all shown blocks. - self._shown = {} - - # Mapping from sector to a list of positions inside that sector. + self.shown_batch_items = {} self.sectors = {} - - # Simple function queue implementation. The queue is populated with - # _show_block() and _hide_block() calls self.queue = deque() - self._initialize() def _initialize(self): - """ Initialize the world by placing all the blocks. - - """ - n = 80 # 1/2 width and height of world - s = 1 # step size - y = 0 # initial y height - for x in xrange(-n, n + 1, s): - for z in xrange(-n, n + 1, s): - # create a layer stone an grass everywhere. + """ Initialize the world by placing all the blocks and trees. """ + n = 80 + s = 1 + y = 0 + + for x in range(-n, n + 1, s): + for z in range(-n, n + 1, s): self.add_block((x, y - 2, z), GRASS, immediate=False) self.add_block((x, y - 3, z), STONE, immediate=False) + self.add_block((x, y - 4, z), STONE, immediate=False) + self.add_block((x, y - 5, z), BEDROCK, immediate=False) if x in (-n, n) or z in (-n, n): - # create outer walls. - for dy in xrange(-2, 3): - self.add_block((x, y + dy, z), STONE, immediate=False) + for dy in range(-5, 3): + self.add_block((x, y + dy, z), BEDROCK, immediate=False) - # generate the hills randomly o = n - 10 - for _ in xrange(120): - a = random.randint(-o, o) # x position of the hill - b = random.randint(-o, o) # z position of the hill - c = -1 # base of the hill - h = random.randint(1, 6) # height of the hill - s = random.randint(4, 8) # 2 * s is the side length of the hill - d = 1 # how quickly to taper off the hills + for _ in range(120): + a = random.randint(-o, o) + b = random.randint(-o, o) + c = -1 + h = random.randint(1, 6) + side_len = random.randint(4, 8) + d = 1 t = random.choice([GRASS, SAND, BRICK]) - for y in xrange(c, c + h): - for x in xrange(a - s, a + s + 1): - for z in xrange(b - s, b + s + 1): - if (x - a) ** 2 + (z - b) ** 2 > (s + 1) ** 2: + for y_pos in range(c, c + h): + for x in range(a - side_len, a + side_len + 1): + for z in range(b - side_len, b + side_len + 1): + if (x - a) ** 2 + (z - b) ** 2 > (side_len + 1) ** 2: continue if (x - 0) ** 2 + (z - 0) ** 2 < 5 ** 2: continue - self.add_block((x, y, z), t, immediate=False) - s -= d # decrement side length so hills taper off + self.add_block((x, y_pos, z), t, immediate=False) + side_len -= d + + for x in range(-n + 4, n - 4, 5): + for z in range(-n + 4, n - 4, 5): + if random.random() < 0.25: + surface_y = 10 + while surface_y > -5: + if (x, surface_y, z) in self.world: + break + surface_y -= 1 + + if (x, surface_y, z) in self.world and self.world[(x, surface_y, z)] == GRASS: + tree_height = random.randint(4, 6) + for dy in range(1, tree_height + 1): + self.add_block((x, surface_y + dy, z), OAK_LOG, immediate=False) + + leaf_bottom = surface_y + tree_height - 2 + for dy in range(leaf_bottom, leaf_bottom + 4): + for dx in range(-2, 3): + for dz in range(-2, 3): + if dy >= leaf_bottom + 2 and (abs(dx) > 1 or abs(dz) > 1): + continue + if abs(dx) == 2 and abs(dz) == 2: + continue + if dx == 0 and dz == 0 and dy <= surface_y + tree_height: + continue + leaf_pos = (x + dx, dy, z + dz) + if leaf_pos not in self.world: + self.add_block(leaf_pos, OAK_LEAVES, immediate=False) def hit_test(self, position, vector, max_distance=8): - """ Line of sight search from current position. If a block is - intersected it is returned, along with the block previously in the line - of sight. If no block is found, return None, None. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position to check visibility from. - vector : tuple of len 3 - The line of sight vector. - max_distance : int - How many blocks away to search for a hit. - - """ + """ Line of sight search from current position. Returns hit block and previous block. """ m = 8 x, y, z = position dx, dy, dz = vector previous = None - for _ in xrange(max_distance * m): + for _ in range(max_distance * m): key = normalize((x, y, z)) if key != previous and key in self.world: return key, previous @@ -220,10 +176,7 @@ def hit_test(self, position, vector, max_distance=8): return None, None def exposed(self, position): - """ Returns False is given `position` is surrounded on all 6 sides by - blocks, True otherwise. - - """ + """ Returns False if given `position` is surrounded on all 6 sides by blocks, True otherwise. """ x, y, z = position for dx, dy, dz in FACES: if (x + dx, y + dy, z + dz) not in self.world: @@ -231,19 +184,7 @@ def exposed(self, position): return False def add_block(self, position, texture, immediate=True): - """ Add a block with the given `texture` and `position` to the world. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position of the block to add. - texture : list of len 3 - The coordinates of the texture squares. Use `tex_coords()` to - generate. - immediate : bool - Whether or not to draw the block immediately. - - """ + """ Add a block with the given `texture` and `position` to the world. """ if position in self.world: self.remove_block(position, immediate) self.world[position] = texture @@ -254,16 +195,7 @@ def add_block(self, position, texture, immediate=True): self.check_neighbors(position) def remove_block(self, position, immediate=True): - """ Remove the block at the given `position`. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position of the block to remove. - immediate : bool - Whether or not to immediately remove block from canvas. - - """ + """ Remove the block at the given `position`. """ del self.world[position] self.sectors[sectorize(position)].remove(position) if immediate: @@ -272,12 +204,7 @@ def remove_block(self, position, immediate=True): self.check_neighbors(position) def check_neighbors(self, position): - """ Check all blocks surrounding `position` and ensure their visual - state is current. This means hiding blocks that are not exposed and - ensuring that all exposed blocks are shown. Usually used after a block - is added or removed. - - """ + """ Check all blocks surrounding `position` and ensure their visual state is current. """ x, y, z = position for dx, dy, dz in FACES: key = (x + dx, y + dy, z + dz) @@ -291,99 +218,57 @@ def check_neighbors(self, position): self.hide_block(key) def show_block(self, position, immediate=True): - """ Show the block at the given `position`. This method assumes the - block has already been added with add_block() - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position of the block to show. - immediate : bool - Whether or not to show the block immediately. - - """ + """ Show the block at the given `position`. """ texture = self.world[position] self.shown[position] = texture if immediate: - self._show_block(position, texture) + self.render_block(position, texture) else: - self._enqueue(self._show_block, position, texture) + self.enqueue(self.render_block, position, texture) - def _show_block(self, position, texture): - """ Private implementation of the `show_block()` method. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position of the block to show. - texture : list of len 3 - The coordinates of the texture squares. Use `tex_coords()` to - generate. - - """ + def render_block(self, position, texture): + """ Render the block into the batch queue. """ x, y, z = position vertex_data = cube_vertices(x, y, z, 0.5) texture_data = list(texture) - # create vertex list - # FIXME Maybe `add_indexed()` should be used instead - self._shown[position] = self.batch.add(24, GL_QUADS, self.group, + self.shown_batch_items[position] = self.batch.add( + 24, GL_QUADS, self.group, ('v3f/static', vertex_data), - ('t2f/static', texture_data)) + ('t2f/static', texture_data) + ) def hide_block(self, position, immediate=True): - """ Hide the block at the given `position`. Hiding does not remove the - block from the world. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position of the block to hide. - immediate : bool - Whether or not to immediately remove the block from the canvas. - - """ + """ Hide the block at the given `position`. """ self.shown.pop(position) if immediate: - self._hide_block(position) + self.unrender_block(position) else: - self._enqueue(self._hide_block, position) - - def _hide_block(self, position): - """ Private implementation of the 'hide_block()` method. + self.enqueue(self.unrender_block, position) - """ - self._shown.pop(position).delete() + def unrender_block(self, position): + """ Remove the block from the render batch. """ + self.shown_batch_items.pop(position).delete() def show_sector(self, sector): - """ Ensure all blocks in the given sector that should be shown are - drawn to the canvas. - - """ + """ Ensure all blocks in the given sector that should be shown are drawn to the canvas. """ for position in self.sectors.get(sector, []): if position not in self.shown and self.exposed(position): self.show_block(position, False) def hide_sector(self, sector): - """ Ensure all blocks in the given sector that should be hidden are - removed from the canvas. - - """ + """ Ensure all blocks in the given sector that should be hidden are removed from the canvas. """ for position in self.sectors.get(sector, []): if position in self.shown: self.hide_block(position, False) def change_sectors(self, before, after): - """ Move from sector `before` to sector `after`. A sector is a - contiguous x, y sub-region of world. Sectors are used to speed up - world rendering. - - """ + """ Move from sector `before` to sector `after`. """ before_set = set() after_set = set() pad = 4 - for dx in xrange(-pad, pad + 1): - for dy in [0]: # xrange(-pad, pad + 1): - for dz in xrange(-pad, pad + 1): + for dx in range(-pad, pad + 1): + for dy in [0]: + for dz in range(-pad, pad + 1): if dx ** 2 + dy ** 2 + dz ** 2 > (pad + 1) ** 2: continue if before: @@ -399,153 +284,83 @@ def change_sectors(self, before, after): for sector in hide: self.hide_sector(sector) - def _enqueue(self, func, *args): - """ Add `func` to the internal queue. - - """ + def enqueue(self, func, *args): + """ Add `func` to the internal queue. """ self.queue.append((func, args)) - def _dequeue(self): - """ Pop the top function from the internal queue and call it. - - """ + def dequeue(self): + """ Pop the top function from the internal queue and call it. """ func, args = self.queue.popleft() func(*args) def process_queue(self): - """ Process the entire queue while taking periodic breaks. This allows - the game loop to run smoothly. The queue contains calls to - _show_block() and _hide_block() so this method should be called if - add_block() or remove_block() was called with immediate=False - - """ + """ Process the entire queue while taking periodic breaks to maintain smooth framerates. """ start = time.perf_counter() while self.queue and time.perf_counter() - start < 1.0 / TICKS_PER_SEC: - self._dequeue() + self.dequeue() def process_entire_queue(self): - """ Process the entire queue with no breaks. - - """ + """ Process the entire queue with no breaks. """ while self.queue: - self._dequeue() + self.dequeue() class Window(pyglet.window.Window): - def __init__(self, *args, **kwargs): - super(Window, self).__init__(*args, **kwargs) - - # Whether or not the window exclusively captures the mouse. + super().__init__(*args, **kwargs) self.exclusive = False - - # When flying gravity has no effect and speed is increased. self.flying = False - - # Strafing is moving lateral to the direction you are facing, - # e.g. moving to the left or right while continuing to face forward. - # - # First element is -1 when moving forward, 1 when moving back, and 0 - # otherwise. The second element is -1 when moving left, 1 when moving - # right, and 0 otherwise. self.strafe = [0, 0] - - # Current (x, y, z) position in the world, specified with floats. Note - # that, perhaps unlike in math class, the y-axis is the vertical axis. self.position = (0, 0, 0) - - # First element is rotation of the player in the x-z plane (ground - # plane) measured from the z-axis down. The second is the rotation - # angle from the ground plane up. Rotation is in degrees. - # - # The vertical plane rotation ranges from -90 (looking straight down) to - # 90 (looking straight up). The horizontal rotation range is unbounded. self.rotation = (0, 0) - - # Which sector the player is currently in. self.sector = None - - # The crosshairs at the center of the screen. self.reticle = None - - # Velocity in the y (upward) direction. self.dy = 0 - # A list of blocks the player can place. Hit num keys to cycle. - self.inventory = [BRICK, GRASS, SAND] - # The current block the user can place. Hit num keys to cycle. + self.inventory = [GRASS, SAND, STONE, OAK_LOG, OAK_LEAVES, OAK_PLANKS, BRICK] self.block = self.inventory[0] - # Convenience list of num keys. self.num_keys = [ key._1, key._2, key._3, key._4, key._5, - key._6, key._7, key._8, key._9, key._0] - - # Instance of the model that handles the world. + key._6, key._7, key._8, key._9, key._0 + ] self.model = Model() - - # The label that is displayed in the top left of the canvas. self.label = pyglet.text.Label('', font_name='Arial', font_size=18, - x=10, y=self.height - 10, anchor_x='left', anchor_y='top', - color=(0, 0, 0, 255)) - - # This call schedules the `update()` method to be called - # TICKS_PER_SEC. This is the main game event loop. + x=10, y=self.height - 10, anchor_x='left', anchor_y='top', + color=(0, 0, 0, 255)) pyglet.clock.schedule_interval(self.update, 1.0 / TICKS_PER_SEC) def set_exclusive_mouse(self, exclusive): - """ If `exclusive` is True, the game will capture the mouse, if False - the game will ignore the mouse. - - """ - super(Window, self).set_exclusive_mouse(exclusive) + """ Capture the mouse into the window and hide the OS cursor completely. """ + super().set_exclusive_mouse(exclusive) self.exclusive = exclusive + self.set_mouse_visible(not exclusive) def get_sight_vector(self): - """ Returns the current line of sight vector indicating the direction - the player is looking. - - """ + """ Returns the current line of sight vector. """ x, y = self.rotation - # y ranges from -90 to 90, or -pi/2 to pi/2, so m ranges from 0 to 1 and - # is 1 when looking ahead parallel to the ground and 0 when looking - # straight up or down. m = math.cos(math.radians(y)) - # dy ranges from -1 to 1 and is -1 when looking straight down and 1 when - # looking straight up. dy = math.sin(math.radians(y)) dx = math.cos(math.radians(x - 90)) * m dz = math.sin(math.radians(x - 90)) * m - return (dx, dy, dz) + return dx, dy, dz def get_motion_vector(self): - """ Returns the current motion vector indicating the velocity of the - player. - - Returns - ------- - vector : tuple of len 3 - Tuple containing the velocity in x, y, and z respectively. - - """ + """ Returns the current motion vector indicating the velocity of the player. """ if any(self.strafe): x, y = self.rotation - strafe = math.degrees(math.atan2(*self.strafe)) + strafe = math.degrees(math.atan2(self.strafe[0], self.strafe[1])) y_angle = math.radians(y) x_angle = math.radians(x + strafe) if self.flying: m = math.cos(y_angle) dy = math.sin(y_angle) if self.strafe[1]: - # Moving left or right. dy = 0.0 m = 1 if self.strafe[0] > 0: - # Moving backwards. dy *= -1 - # When you are flying up or down, you have less left and right - # motion. dx = math.cos(x_angle) * m dz = math.sin(x_angle) * m else: @@ -556,19 +371,16 @@ def get_motion_vector(self): dy = 0.0 dx = 0.0 dz = 0.0 - return (dx, dy, dz) + return dx, dy, dz def update(self, dt): - """ This method is scheduled to be called repeatedly by the pyglet - clock. + """ Main game event loop scheduled to run continuously. """ + self.model.process_queue() - Parameters - ---------- - dt : float - The change in time since the last call. + # Aggressive mouse lock: Keep mouse centered and hidden while in game mode + if self.exclusive: + self.set_mouse_position(self.width // 2, self.height // 2) - """ - self.model.process_queue() sector = sectorize(self.position) if sector != self.sector: self.model.change_sectors(self.sector, sector) @@ -577,71 +389,36 @@ def update(self, dt): self.sector = sector m = 8 dt = min(dt, 0.2) - for _ in xrange(m): + for _ in range(m): self._update(dt / m) def _update(self, dt): - """ Private implementation of the `update()` method. This is where most - of the motion logic lives, along with gravity and collision detection. - - Parameters - ---------- - dt : float - The change in time since the last call. - - """ - # walking + """ Update player position, check collisions, and apply physics. """ speed = FLYING_SPEED if self.flying else WALKING_SPEED - d = dt * speed # distance covered this tick. + d = dt * speed dx, dy, dz = self.get_motion_vector() - # New position in space, before accounting for gravity. dx, dy, dz = dx * d, dy * d, dz * d - # gravity if not self.flying: - # Update your vertical speed: if you are falling, speed up until you - # hit terminal velocity; if you are jumping, slow down until you - # start falling. self.dy -= dt * GRAVITY self.dy = max(self.dy, -TERMINAL_VELOCITY) dy += self.dy * dt - # collisions x, y, z = self.position x, y, z = self.collide((x + dx, y + dy, z + dz), PLAYER_HEIGHT) self.position = (x, y, z) def collide(self, position, height): - """ Checks to see if the player at the given `position` and `height` - is colliding with any blocks in the world. - - Parameters - ---------- - position : tuple of len 3 - The (x, y, z) position to check for collisions at. - height : int or float - The height of the player. - - Returns - ------- - position : tuple of len 3 - The new position of the player taking into account collisions. - - """ - # How much overlap with a dimension of a surrounding block you need to - # have to count as a collision. If 0, touching terrain at all counts as - # a collision. If .49, you sink into the ground, as if walking through - # tall grass. If >= .5, you'll fall through the ground. + """ Checks if the player is colliding with any blocks in the world. """ pad = 0.25 p = list(position) np = normalize(position) - for face in FACES: # check all surrounding blocks - for i in xrange(3): # check each dimension independently + for face in FACES: + for i in range(3): if not face[i]: continue - # How much overlap you have with this dimension. d = (p[i] - np[i]) * face[i] if d < pad: continue - for dy in xrange(height): # check each height + for dy in range(height): op = list(np) op[1] -= dy op[i] += face[i] @@ -649,75 +426,46 @@ def collide(self, position, height): continue p[i] -= (d - pad) * face[i] if face == (0, -1, 0) or face == (0, 1, 0): - # You are colliding with the ground or ceiling, so stop - # falling / rising. self.dy = 0 break return tuple(p) def on_mouse_press(self, x, y, button, modifiers): - """ Called when a mouse button is pressed. See pyglet docs for button - amd modifier mappings. - - Parameters - ---------- - x, y : int - The coordinates of the mouse click. Always center of the screen if - the mouse is captured. - button : int - Number representing mouse button that was clicked. 1 = left button, - 4 = right button. - modifiers : int - Number representing any modifying keys that were pressed when the - mouse button was clicked. - - """ - if self.exclusive: - vector = self.get_sight_vector() - block, previous = self.model.hit_test(self.position, vector) - if (button == mouse.RIGHT) or \ - ((button == mouse.LEFT) and (modifiers & key.MOD_CTRL)): - # ON OSX, control + left click = right click. - if previous: - self.model.add_block(previous, self.block) - elif button == pyglet.window.mouse.LEFT and block: - texture = self.model.world[block] - if texture != STONE: - self.model.remove_block(block) - else: + """ Triggered when a mouse button is pressed. Used for block interaction or resuming. """ + if not self.exclusive: self.set_exclusive_mouse(True) + return - def on_mouse_motion(self, x, y, dx, dy): - """ Called when the player moves the mouse. + vector = self.get_sight_vector() + block, previous = self.model.hit_test(self.position, vector) + if (button == mouse.RIGHT) or ((button == mouse.LEFT) and (modifiers & key.MOD_CTRL)): + if previous: + self.model.add_block(previous, self.block) + elif button == pyglet.window.mouse.LEFT and block: + texture = self.model.world[block] + if texture != BEDROCK: + self.model.remove_block(block) - Parameters - ---------- - x, y : int - The coordinates of the mouse click. Always center of the screen if - the mouse is captured. - dx, dy : float - The movement of the mouse. + def on_mouse_motion(self, x, y, dx, dy): + """ Controls the camera view based on mouse movement. """ + if self.exclusive: + m = 0.15 + rot_x, rot_y = self.rotation + rot_x, rot_y = rot_x + dx * m, rot_y + dy * m + rot_y = max(-90.0, min(90.0, rot_y)) + self.rotation = (rot_x, rot_y) - """ + def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): + """ Controls the camera view even while holding a mouse button (e.g., placing/breaking blocks). """ if self.exclusive: m = 0.15 - x, y = self.rotation - x, y = x + dx * m, y + dy * m - y = max(-90, min(90, y)) - self.rotation = (x, y) + rot_x, rot_y = self.rotation + rot_x, rot_y = rot_x + dx * m, rot_y + dy * m + rot_y = max(-90.0, min(90.0, rot_y)) + self.rotation = (rot_x, rot_y) def on_key_press(self, symbol, modifiers): - """ Called when the player presses a key. See pyglet docs for key - mappings. - - Parameters - ---------- - symbol : int - Number representing the key that was pressed. - modifiers : int - Number representing any modifying keys that were pressed. - - """ + """ Handles keyboard inputs (movement, jumping, block selection). """ if symbol == key.W: self.strafe[0] -= 1 elif symbol == key.S: @@ -731,6 +479,7 @@ def on_key_press(self, symbol, modifiers): self.dy = JUMP_SPEED elif symbol == key.ESCAPE: self.set_exclusive_mouse(False) + return pyglet.event.EVENT_HANDLED elif symbol == key.TAB: self.flying = not self.flying elif symbol in self.num_keys: @@ -738,17 +487,7 @@ def on_key_press(self, symbol, modifiers): self.block = self.inventory[index] def on_key_release(self, symbol, modifiers): - """ Called when the player releases a key. See pyglet docs for key - mappings. - - Parameters - ---------- - symbol : int - Number representing the key that was pressed. - modifiers : int - Number representing any modifying keys that were pressed. - - """ + """ Resets movement flags when movement keys are released. """ if symbol == key.W: self.strafe[0] += 1 elif symbol == key.S: @@ -759,24 +498,18 @@ def on_key_release(self, symbol, modifiers): self.strafe[1] -= 1 def on_resize(self, width, height): - """ Called when the window is resized to a new `width` and `height`. - - """ - # label + """ Re-calculates UI elements when the window is resized. """ self.label.y = height - 10 - # reticle if self.reticle: self.reticle.delete() x, y = self.width // 2, self.height // 2 n = 10 - self.reticle = pyglet.graphics.vertex_list(4, - ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n)) + self.reticle = pyglet.graphics.vertex_list( + 4, ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n)) ) def set_2d(self): - """ Configure OpenGL to draw in 2d. - - """ + """ Configure OpenGL to draw 2D elements like the UI and crosshair. """ width, height = self.get_size() glDisable(GL_DEPTH_TEST) viewport = self.get_viewport_size() @@ -788,9 +521,7 @@ def set_2d(self): glLoadIdentity() def set_3d(self): - """ Configure OpenGL to draw in 3d. - - """ + """ Configure OpenGL to draw the 3D world. """ width, height = self.get_size() glEnable(GL_DEPTH_TEST) viewport = self.get_viewport_size() @@ -807,23 +538,111 @@ def set_3d(self): glTranslatef(-x, -y, -z) def on_draw(self): - """ Called by pyglet to draw the canvas. - - """ + """ Primary rendering function called by Pyglet. """ self.clear() self.set_3d() glColor3d(1, 1, 1) self.model.batch.draw() - self.draw_focused_block() + + if self.exclusive: + self.draw_focused_block() + + self.draw_viewmodel() + self.set_2d() self.draw_label() - self.draw_reticle() - def draw_focused_block(self): - """ Draw black edges around the block that is currently under the - crosshairs. + if self.exclusive: + self.draw_reticle() + else: + self.draw_pause_screen() + + self.draw_hotbar() + + def draw_viewmodel(self): + """ Draw the currently selected block in the bottom right corner (Hand). """ + glMatrixMode(GL_PROJECTION) + glPushMatrix() + glLoadIdentity() + gluPerspective(65.0, self.width / float(self.height), 0.1, 60.0) + + glMatrixMode(GL_MODELVIEW) + glPushMatrix() + glLoadIdentity() - """ + glClear(GL_DEPTH_BUFFER_BIT) + + glTranslatef(0.6, -0.5, -1.5) + glRotatef(-30, 1, 0, 0) + glRotatef(45, 0, 1, 0) + + texture_data = list(self.block) + vertex_data = cube_vertices(0, 0, 0, 0.25) + + glEnable(GL_TEXTURE_2D) + glBindTexture(GL_TEXTURE_2D, self.model.group.texture.id) + + glColor3d(1, 1, 1) + pyglet.graphics.draw(24, GL_QUADS, + ('v3f/static', vertex_data), + ('t2f/static', texture_data) + ) + + glPopMatrix() + glMatrixMode(GL_PROJECTION) + glPopMatrix() + glMatrixMode(GL_MODELVIEW) + + def draw_hotbar(self): + """ Draw the 2D Hotbar at the bottom of the screen. """ + glDisable(GL_DEPTH_TEST) + slot_size = 40 + padding = 10 + total_width = len(self.inventory) * (slot_size + padding) - padding + start_x = (self.width - total_width) // 2 + y_pos = 20 + + glDisable(GL_TEXTURE_2D) + + for i in range(len(self.inventory)): + x = start_x + i * (slot_size + padding) + + if self.inventory[i] == self.block: + glColor4f(1.0, 1.0, 1.0, 0.8) + else: + glColor4f(0.0, 0.0, 0.0, 0.5) + + pyglet.graphics.draw(4, GL_QUADS, + ('v2f', [x, y_pos, x + slot_size, y_pos, x + slot_size, y_pos + slot_size, x, + y_pos + slot_size]) + ) + + if self.inventory[i] == self.block: + glColor4f(0.2, 0.2, 0.2, 0.8) + bx, by, bs = x + 2, y_pos + 2, slot_size - 4 + pyglet.graphics.draw(4, GL_QUADS, + ('v2f', [bx, by, bx + bs, by, bx + bs, by + bs, bx, by + bs]) + ) + + glEnable(GL_TEXTURE_2D) + glBindTexture(GL_TEXTURE_2D, self.model.group.texture.id) + glColor3d(1, 1, 1) + + for i, tex in enumerate(self.inventory): + x = start_x + i * (slot_size + padding) + slot_size / 2 + y_center = y_pos + slot_size / 2 + + t_coords = tex[16:24] + s = slot_size * 0.7 / 2 + vx = [x - s, y_center - s, x + s, y_center - s, x + s, y_center + s, x - s, y_center + s] + + pyglet.graphics.draw(4, GL_QUADS, + ('v2f', vx), + ('t2f', t_coords) + ) + + def draw_focused_block(self): + """ Draws a wireframe outline around the block the player is currently looking at. """ vector = self.get_sight_vector() block = self.model.hit_test(self.position, vector)[0] if block: @@ -835,68 +654,74 @@ def draw_focused_block(self): glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) def draw_label(self): - """ Draw the label in the top left of the screen. - - """ + """ Displays FPS and debug info in the top left corner. """ 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)) + len(self.model.shown_batch_items), len(self.model.world)) self.label.draw() def draw_reticle(self): - """ Draw the crosshairs in the center of the screen. - - """ + """ Draw the central aiming crosshair. """ + glDisable(GL_TEXTURE_2D) + glLineWidth(2.0) glColor3d(0, 0, 0) self.reticle.draw(GL_LINES) + def draw_pause_screen(self): + """ Draw a semi-transparent overlay and PAUSED text when the game is paused. """ + glDisable(GL_DEPTH_TEST) + glDisable(GL_TEXTURE_2D) + glEnable(GL_BLEND) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) -def setup_fog(): - """ Configure the OpenGL fog properties. + glColor4f(0.0, 0.0, 0.0, 0.6) + pyglet.graphics.draw(4, GL_QUADS, + ('v2f', [0, 0, self.width, 0, self.width, self.height, 0, self.height]) + ) - """ - # Enable fog. Fog "blends a fog color with each rasterized pixel fragment's - # post-texturing color." + label = pyglet.text.Label('GAME PAUSED', font_name='Arial', font_size=40, bold=True, + x=self.width // 2, y=self.height // 2 + 20, + anchor_x='center', anchor_y='center', + color=(255, 255, 255, 255)) + + sub_label = pyglet.text.Label('Click anywhere to resume', font_name='Arial', font_size=16, + x=self.width // 2, y=self.height // 2 - 30, + anchor_x='center', anchor_y='center', + color=(200, 200, 200, 255)) + label.draw() + sub_label.draw() + + +def setup_fog(): + """ Configure OpenGL depth fog to hide block pop-in distances. """ glEnable(GL_FOG) - # Set the fog color. glFogfv(GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.69, 1.0, 1)) - # Say we have no preference between rendering speed and quality. glHint(GL_FOG_HINT, GL_DONT_CARE) - # Specify the equation used to compute the blending factor. glFogi(GL_FOG_MODE, GL_LINEAR) - # How close and far away fog starts and ends. The closer the start and end, - # the denser the fog in the fog range. glFogf(GL_FOG_START, 20.0) glFogf(GL_FOG_END, 60.0) def setup(): - """ Basic OpenGL configuration. - - """ - # Set the color of "clear", i.e. the sky, in rgba. + """ Prepare OpenGL states for rendering our 3D world and 2D UI. """ glClearColor(0.5, 0.69, 1.0, 1) - # Enable culling (not rendering) of back-facing facets -- facets that aren't - # visible to you. glEnable(GL_CULL_FACE) - # Set the texture minification/magnification function to GL_NEAREST (nearest - # in Manhattan distance) to the specified texture coordinates. GL_NEAREST - # "is generally faster than GL_LINEAR, but it can produce textured images - # with sharper edges because the transition between texture elements is not - # as smooth." glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) + + glEnable(GL_BLEND) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + setup_fog() def main(): - window = Window(width=800, height=600, caption='Pyglet', resizable=True) - # Hide the mouse cursor and prevent the mouse from leaving the window. - window.set_exclusive_mouse(True) + window = Window(width=800, height=600, caption='Pyglet Minecraft Clone', resizable=True) + window.set_exclusive_mouse(False) setup() pyglet.app.run() if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/texture.png b/texture.png index 9d05a7e2db1eecfe427228730ba1a9d7f5e38515..bc96300cdd7a2c2eafe440b9bb57053cd9bc120f 100644 GIT binary patch literal 8797 zcmeHti$Bxt|NpccN~}_;+hLS)cULHtwl=F+_=G8yoRh<7h0MY*Iyx1Vx{KJDio#Y& zG7V9=D>mnKVx;VZVJ92gzU%(pzx(^u_h0xu_Sj?Bb?v?D@VZ{F=j-{ru4Q?7x)?0} zZ7~1iS%RT^wVan4~7NYlh>;(XxHv=2-v$hDeMJ3B`oRTbu|-M@7S}g$+&C7ExhvYo8q+ zb{?@#;gM0U__%OyyyxLiJSG$pW{q$(SPV;qYI-;w9v@z`rvvA3Y-n6mYxs4h3?CmA@jv57WB)OO#vryozp>qFWA}5)Kg&>5 zTvWJb7C(n{+zR{q`+03J+n*EpUlViu?-tEkHKl(o^V3ZKS~omeW6}hT?Ka=MqYnUB zK;4}89!?AzFGk-ag%`XnuXBHQv;Ce!cQSD8MXM5vgZKQ7YOnPOKiv$eTHKJGe*Wo+ zUCCdOtGxCs4ZOBC@IMy6FVy4F(aX2xw};_lX0MJ&K0uNf$s6R~u*$|jQJPvf8&fX| zl404h{Ld^F>-LE&SvR(;Uad9)83NuqUje3XT{Z$Z?*4igV71ZK|KId~Eb+J1+7NGF zZ>jsbmUjO>GX9XxlGPUYq2_bscm37=NL10TgYl`Ubnb{!F`;~2O|E42k(}Nfct~~= ztWzZRl+nrhjgQoAlT%MK#PS^nW@XqVfq6pC4c*b~QACF1OC=Ho4z?^5OZk$W6R^$D zg-lZ6BWl9H^FO+<50)4Y^!2TW!r_72nVj8#(6w*1n(t(u0oZLgQ3Tv$n0^t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Ps>EGHRw17w< zO}q@{@XCB-;*4}BA8^rVmX>z!>54%aiVKX922iR#Ehy~S%R~4grP6!3-NP1$1)pyo tZXY)`ICb#Xax+y7?`HqVj7PH^u;uCX Date: Mon, 8 Jun 2026 20:29:26 +0300 Subject: [PATCH 2/2] my commits --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..4fdfa371 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyglet~=1.5.27 \ No newline at end of file