Created
October 19, 2023 12:21
Revisions
-
bradmartin333 created this gist
Oct 19, 2023 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ from pyray import * import math show_instruction = True cone_deg_half = 25 heading = 340 window_size = Vector2(800, 500) text_size = int(window_size.y / 20) center = Vector2(window_size.x / 2, window_size.y / 2) init_window(int(window_size.x), int(window_size.y), "Negative Yaw Sim") hide_cursor() while not window_should_close(): begin_drawing() clear_background(WHITE) mouse_offset_x = get_mouse_x() - center.x mouse_offset_y = get_mouse_y() - center.y angle = math.atan2(mouse_offset_y, mouse_offset_x) angle = (angle + math.pi / 2) % (2 * math.pi) angle = angle * 180 / math.pi if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT): heading = angle show_instruction = False cone_a = heading - cone_deg_half cone_b = heading + cone_deg_half # Need to adjust angles for raylib draw_circle_sector( center, window_size.x / 4, -cone_a + 180, -cone_b + 180, 100, BLUE ) mouse_color = ( GREEN if ( (angle >= cone_a and angle <= cone_b) or angle >= cone_a + 360 or angle <= cone_b - 360 ) else RED ) mouse_color = ( BLACK if ( (angle < cone_a or angle > cone_b) and angle < cone_a + 360 and angle > cone_b - 360 ) else mouse_color ) draw_circle(get_mouse_x(), get_mouse_y(), 10, mouse_color) draw_text(("Heading: {}°".format(round(heading))), 10, 10, text_size, BLACK) draw_text(("Cursor: {}°".format(round(angle))), 10, int(text_size * 2.1), text_size, BLACK) if show_instruction: draw_text( "Left click to change heading", 10, int(window_size.y - text_size * 1.1), text_size, BLACK ) end_drawing() close_window()