Files
dusk/tools/editortool/map/selectbox.py
Dominic Masters d788de8637
Some checks failed
Build Dusk / run-tests (push) Successful in 1m56s
Build Dusk / build-linux (push) Successful in 1m44s
Build Dusk / build-psp (push) Failing after 1m35s
Starting refactor of tools, thank gosh
2026-01-25 21:07:31 -06:00

44 lines
1.5 KiB
Python

import OpenGL.GL as gl
from tools.dusk.defs import defs
import colorsys
from tools.dusk.defs import TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH
class SelectBox:
def __init__(self, parent):
self.parent = parent
self.hue = 0.0
def draw(self):
position = [
self.parent.map.position[0] * TILE_WIDTH - (TILE_WIDTH / 2.0),
self.parent.map.position[1] * TILE_HEIGHT - (TILE_HEIGHT / 2.0),
self.parent.map.position[2] * TILE_DEPTH - (TILE_DEPTH / 2.0)
]
vertices = [
(position[0], position[1], position[2]),
(position[0]+TILE_WIDTH, position[1], position[2]),
(position[0]+TILE_WIDTH, position[1]+TILE_HEIGHT, position[2]),
(position[0], position[1]+TILE_HEIGHT, position[2]),
(position[0], position[1], position[2]+TILE_DEPTH),
(position[0]+TILE_WIDTH, position[1], position[2]+TILE_DEPTH),
(position[0]+TILE_WIDTH, position[1]+TILE_HEIGHT, position[2]+TILE_DEPTH),
(position[0], position[1]+TILE_HEIGHT, position[2]+TILE_DEPTH)
]
edges = [
(0, 1), (1, 2), (2, 3), (3, 0), # bottom face
(4, 5), (5, 6), (6, 7), (7, 4), # top face
(4, 5), (5, 6), (6, 7), (7, 4), # top face
(0, 4), (1, 5), (2, 6), (3, 7) # vertical edges
]
# Cycle hue
self.hue = (self.hue + 0.01) % 1.0
r, g, b = colorsys.hsv_to_rgb(self.hue, 1.0, 1.0)
gl.glColor3f(r, g, b)
gl.glLineWidth(2.0)
gl.glBegin(gl.GL_LINES)
for edge in edges:
for vertex in edge:
gl.glVertex3f(*vertices[vertex])
gl.glEnd()