Compare commits
	
		
			3 Commits
		
	
	
		
			43882f4fef
			...
			4775b59936
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 4775b59936 | ||
|   | a8103af866 | ||
|   | 34f790ca18 | 
							
								
								
									
										30
									
								
								.gitea/workflows/run_tests.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								.gitea/workflows/run_tests.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | name: Build Simulation and Test | ||||||
|  | on: | ||||||
|  |   push: | ||||||
|  |     branches: | ||||||
|  |       - master | ||||||
|  | 
 | ||||||
|  | jobs: | ||||||
|  |   tests: | ||||||
|  |     name: Run All Tests | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  | 
 | ||||||
|  |     steps: | ||||||
|  |     - uses: actions/checkout@v4 | ||||||
|  | 
 | ||||||
|  |     - name: Install uv | ||||||
|  |       uses: astral-sh/setup-uv@v5 | ||||||
|  |       with: | ||||||
|  |         enable-cache: true | ||||||
|  |         cache-dependency-glob: "uv.lock" | ||||||
|  | 
 | ||||||
|  |     - name: "Set up Python" | ||||||
|  |       uses: actions/setup-python@v5 | ||||||
|  |       with: | ||||||
|  |         python-version-file: "pyproject.toml" | ||||||
|  | 
 | ||||||
|  |     - name: Install the project | ||||||
|  |       run: uv sync --locked --all-extras --dev | ||||||
|  | 
 | ||||||
|  |     - name: Run tests | ||||||
|  |       run: uv run pytest tests.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html | ||||||
							
								
								
									
										44
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								main.py
									
									
									
									
									
								
							| @ -141,22 +141,36 @@ def draw_grid(screen, camera, showing_grid=True): | |||||||
| 
 | 
 | ||||||
|     # Draw vertical grid lines (only if zoom is high enough to see them clearly) |     # Draw vertical grid lines (only if zoom is high enough to see them clearly) | ||||||
|     if effective_cell_size > 4: |     if effective_cell_size > 4: | ||||||
|         for i in range(GRID_WIDTH + 1): |         # Precompute grid boundaries | ||||||
|             line_x = grid_left + i * effective_cell_size |         vertical_lines = [] | ||||||
|             if 0 <= line_x <= SCREEN_WIDTH: |         horizontal_lines = [] | ||||||
|                 start_y = max(0, grid_top) |  | ||||||
|                 end_y = min(SCREEN_HEIGHT, grid_bottom) |  | ||||||
|                 if start_y < end_y: |  | ||||||
|                     pygame.draw.line(screen, GRAY, (line_x, start_y), (line_x, end_y)) |  | ||||||
| 
 | 
 | ||||||
|         # Draw horizontal grid lines |         for i in range(max(GRID_WIDTH, GRID_HEIGHT) + 1): | ||||||
|         for i in range(GRID_HEIGHT + 1): |             # Vertical lines | ||||||
|             line_y = grid_top + i * effective_cell_size |             if i <= GRID_WIDTH: | ||||||
|             if 0 <= line_y <= SCREEN_HEIGHT: |                 line_x = grid_left + i * effective_cell_size | ||||||
|                 start_x = max(0, grid_left) |                 if 0 <= line_x <= SCREEN_WIDTH: | ||||||
|                 end_x = min(SCREEN_WIDTH, grid_right) |                     start_y = max(0, grid_top) | ||||||
|                 if start_x < end_x: |                     end_y = min(SCREEN_HEIGHT, grid_bottom) | ||||||
|                     pygame.draw.line(screen, GRAY, (start_x, line_y), (end_x, line_y)) |                     if start_y < end_y: | ||||||
|  |                         vertical_lines.append(((line_x, start_y), (line_x, end_y))) | ||||||
|  | 
 | ||||||
|  |             # Horizontal lines | ||||||
|  |             if i <= GRID_HEIGHT: | ||||||
|  |                 line_y = grid_top + i * effective_cell_size | ||||||
|  |                 if 0 <= line_y <= SCREEN_HEIGHT: | ||||||
|  |                     start_x = max(0, grid_left) | ||||||
|  |                     end_x = min(SCREEN_WIDTH, grid_right) | ||||||
|  |                     if start_x < end_x: | ||||||
|  |                         horizontal_lines.append(((start_x, line_y), (end_x, line_y))) | ||||||
|  | 
 | ||||||
|  |         # Draw all vertical lines in one batch | ||||||
|  |         for start, end in vertical_lines: | ||||||
|  |             pygame.draw.line(screen, GRAY, start, end) | ||||||
|  | 
 | ||||||
|  |         # Draw all horizontal lines in one batch | ||||||
|  |         for start, end in horizontal_lines: | ||||||
|  |             pygame.draw.line(screen, GRAY, start, end) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|  | |||||||
| @ -5,4 +5,5 @@ description = "Add your description here" | |||||||
| requires-python = ">=3.11" | requires-python = ">=3.11" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|     "pygame>=2.6.1", |     "pygame>=2.6.1", | ||||||
|  |     "pytest>=8.3.5", | ||||||
| ] | ] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user