Rotate the Square Around Paddle 1 - Demo 13¶
Purpose¶
Rotate the square around paddle1’s center.
Move the Paddles using the Keyboard¶
Keyboard Input |
Action |
---|---|
w |
Move Left Paddle Up |
s |
Move Left Paddle Down |
k |
Move Right Paddle Down |
i |
Move Right Paddle Up |
d |
Increase Left Paddle’s Rotation |
a |
Decrease Left Paddle’s Rotation |
l |
Increase Right Paddle’s Rotation |
j |
Decrease Right Paddle’s Rotation |
UP |
Move the camera up, moving the objects down |
DOWN |
Move the camera down, moving the objects up |
LEFT |
Move the camera left, moving the objects right |
RIGHT |
Move the camera right, moving the objects left |
q |
Rotate the square around it’s center |
e |
Rotate the square around paddle 1’s center |
Description¶
Cayley Graph¶
rotation_around_paddle1: float = 0.0
Event Loop¶
while not glfw.window_should_close(window):
...
glColor3f(0.0, 0.0, 1.0)
glBegin(GL_QUADS)
for model_space in square:
paddle_1_space: Vertex = model_space.rotate(square_rotation) \
.translate(tx=20.0,
ty=0.0) \
.rotate(rotation_around_paddle1)
world_space: Vertex = paddle_1_space.rotate(paddle1.rotation) \
.translate(tx=paddle1.position.x,
ty=paddle1.position.y)
camera_space: Vertex = world_space.translate(tx=-camera.position_worldspace.x,
ty=-camera.position_worldspace.y)
ndc_space: Vertex = camera_space.scale(scale_x=1.0 / 100.0,
scale_y=1.0 / 100.0)
glVertex2f(ndc_space.x, ndc_space.y)
glEnd()