1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: fix the sticky checks and disable vector

+13 -59
+1 -1
physics_engine.vhd
··· 331 331 vy := (others => '0'); 332 332 end if; 333 333 334 - elsif c_prev_top >= OBS_B(obs_i) then 334 + elsif c_prev_top >= OBS_B(obs_i) and vy(9) = '1' then 335 335 py := OBS_B(obs_i) + SIZE11; 336 336 bounced := '1'; 337 337 vy := (not vy) + 1;
+3 -51
renderer.vhd
··· 47 47 signal wc : std_logic_vector(10 downto 0); 48 48 signal wr : std_logic_vector(10 downto 0); 49 49 50 - signal char_on, ground_on, wall_on, ceiling_on, obs_on, arrow_on : std_logic; 50 + signal char_on, ground_on, wall_on, ceiling_on, obs_on : std_logic; 51 + signal arrow_on : std_logic := '0'; -- disabled 51 52 52 53 begin 53 54 ··· 89 90 90 91 end process render; 91 92 92 - -- ---------------------------------------------------------------- 93 - -- Velocity vector arrow 94 - -- Line from (char_x, char_y) to (char_x + 3*vx, char_y + 3*vy). 95 - -- Uses cross-product line-segment test: 96 - -- pixel on segment iff |dy*(px-x0) - dx*(py-y0)| <= max(|dx|,|dy|) 97 - -- and dx*(px-x0) + dy*(py-y0) in [0, dx^2+dy^2] 98 - -- ---------------------------------------------------------------- 99 - arrow_proc : process(wc, wr, char_x, char_y, vel_x_in, vel_y_in) 100 - variable wci, wri : integer; 101 - variable cx, cy : integer; 102 - variable vxi, vyi : integer; 103 - variable dx, dy : integer; 104 - variable cross : integer; 105 - variable dot_p : integer; 106 - variable len_sq : integer; 107 - variable maxd : integer; 108 - begin 109 - wci := CONV_INTEGER(wc); 110 - wri := CONV_INTEGER(wr); 111 - cx := CONV_INTEGER(char_x); 112 - cy := CONV_INTEGER(char_y); 113 - 114 - -- Convert 10-bit 2's complement velocity to signed integer 115 - if vel_x_in(9) = '1' then vxi := CONV_INTEGER(vel_x_in) - 1024; 116 - else vxi := CONV_INTEGER(vel_x_in); end if; 117 - if vel_y_in(9) = '1' then vyi := CONV_INTEGER(vel_y_in) - 1024; 118 - else vyi := CONV_INTEGER(vel_y_in); end if; 119 - 120 - -- Scale arrow by 3 for visibility 121 - dx := vxi * 3; 122 - dy := vyi * 3; 123 - 124 - -- Precompute line metrics 125 - cross := dy * (wci - cx) - dx * (wri - cy); 126 - dot_p := dx * (wci - cx) + dy * (wri - cy); 127 - len_sq := dx * dx + dy * dy; 128 - 129 - -- Chebyshev thickness (~1-2 world-pixels wide) 130 - maxd := dx; if maxd < 0 then maxd := -maxd; end if; 131 - if dy > maxd then maxd := dy; 132 - elsif -dy > maxd then maxd := -dy; end if; 133 - 134 - arrow_on <= '0'; 135 - if maxd > 4 then -- skip arrow when velocity is negligible 136 - if cross >= -maxd and cross <= maxd and 137 - dot_p >= 0 and dot_p <= len_sq then 138 - arrow_on <= '1'; 139 - end if; 140 - end if; 141 - end process arrow_proc; 93 + -- Velocity vector arrow disabled — arrow_on held '0' by signal initializer 142 94 143 95 -- ---------------------------------------------------------------- 144 96 -- Color output with priority
+9 -7
visualizer.py
··· 98 98 keys_held = {'w': False, 'a': False, 's': False, 'd': False} 99 99 trail = [] 100 100 show_trail = True 101 + show_vector = False 101 102 font = pygame.font.SysFont("monospace", 14) 102 103 103 104 running = True ··· 113 114 elif event.key == pygame.K_q: running = False 114 115 elif event.key == pygame.K_t: 115 116 show_trail = not show_trail; trail.clear() 117 + elif event.key == pygame.K_v: 118 + show_vector = not show_vector 116 119 elif event.key == pygame.K_r: 117 120 char_x, char_y = 100, 200 118 121 vel_x = vel_y = to_unsigned(0) ··· 266 269 svy = svy - loss if svy > 0 else svy + loss 267 270 if abs(svy) < 2: svy = 0 268 271 vy = to_unsigned(svy) 269 - elif prev_top >= ob: 272 + elif prev_top >= ob and to_signed(vy) < 0: 270 273 py = ob + SIZE 271 274 bounced = True 272 275 vy = negate(vy) ··· 412 415 # Velocity vector arrow (scale: 2px per unit of velocity) 413 416 svx = to_signed(vel_x) 414 417 svy = to_signed(vel_y) 415 - ARROW_SCALE = 2 416 - ax = char_x + svx * ARROW_SCALE 417 - ay = char_y + svy * ARROW_SCALE 418 - if svx != 0 or svy != 0: 418 + if show_vector and (svx != 0 or svy != 0): 419 + ARROW_SCALE = 2 420 + ax = char_x + svx * ARROW_SCALE 421 + ay = char_y + svy * ARROW_SCALE 419 422 pygame.draw.line(screen, (255, 255, 255), (char_x, char_y), (ax, ay), 2) 420 - # Arrowhead 421 423 angle = math.atan2(svy, svx) 422 424 head = 6 423 425 for side in (+0.5, -0.5): ··· 430 432 f"pos: ({char_x}, {char_y}) vel: ({svx}, {svy})", 431 433 f"squish: {squish} ground: {'yes' if on_ground else 'no'}", 432 434 "", 433 - "WASD: move/jump R: reset T: trail Q: quit", 435 + "WASD: move/jump R: reset T: trail V: vector Q: quit", 434 436 ] 435 437 for i, line in enumerate(info): 436 438 surf = font.render(line, True, (255, 255, 255))