游戏可以运行

This commit is contained in:
2026-05-20 20:21:27 +08:00
parent 00908667dd
commit 88b3255ab2
11 changed files with 690 additions and 0 deletions

68
game/config.py Normal file
View File

@@ -0,0 +1,68 @@
import pygame
# Window
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
UI_TOP_HEIGHT = 40
UI_BOTTOM_HEIGHT = 60
GAME_HEIGHT = WINDOW_HEIGHT - UI_TOP_HEIGHT - UI_BOTTOM_HEIGHT
FPS = 60
# Grid
CELL_SIZE = 40
GRID_COLS = WINDOW_WIDTH // CELL_SIZE
GRID_ROWS = GAME_HEIGHT // CELL_SIZE
# Colors
COLOR_BG = (34, 40, 49)
COLOR_GRASS = (44, 62, 44)
COLOR_PATH = (139, 119, 101)
COLOR_GRID_LINE = (50, 58, 50)
COLOR_WHITE = (255, 255, 255)
COLOR_BLACK = (0, 0, 0)
COLOR_RED = (220, 50, 50)
COLOR_DARK_RED = (160, 30, 30)
COLOR_GREEN = (50, 200, 50)
COLOR_BLUE = (70, 130, 230)
COLOR_YELLOW = (230, 200, 50)
COLOR_PURPLE = (150, 50, 200)
COLOR_ORANGE = (230, 150, 50)
COLOR_CYAN = (50, 200, 200)
COLOR_GRAY = (120, 120, 120)
COLOR_DARK_GRAY = (60, 60, 60)
COLOR_GOLD = (255, 215, 0)
COLOR_HIGHLIGHT = (255, 255, 255, 80)
# Game params
INITIAL_GOLD = 200
INITIAL_LIVES = 20
TOTAL_WAVES = 10
# Tower stats
TOWER_DATA = {
"arrow": {"damage": 20, "range": 120, "fire_rate": 0.5, "price": 50, "color": COLOR_BLUE, "name": "箭塔"},
"cannon": {"damage": 80, "range": 100, "fire_rate": 1.5, "price": 100, "color": COLOR_ORANGE, "name": "炮塔", "splash": 60},
"slow": {"damage": 5, "range": 130, "fire_rate": 0.8, "price": 75, "color": COLOR_CYAN, "name": "减速塔", "slow_factor": 0.5, "slow_duration": 2.0},
}
# Enemy stats
ENEMY_DATA = {
"normal": {"hp": 100, "speed": 2, "reward": 10, "color": COLOR_RED, "size": 12, "name": "普通兵"},
"fast": {"hp": 60, "speed": 4, "reward": 8, "color": COLOR_YELLOW, "size": 10, "name": "快速兵"},
"heavy": {"hp": 300, "speed": 1, "reward": 25, "color": COLOR_PURPLE, "size": 14, "name": "重装兵"},
"boss": {"hp": 800, "speed": 0.8, "reward": 100, "color": COLOR_DARK_RED, "size": 20, "name": "BOSS"},
}
# Path waypoints (pixel coordinates)
PATH_WAYPOINTS = [
(0, 180),
(160, 180),
(160, 340),
(400, 340),
(400, 100),
(600, 100),
(600, 340),
(760, 340),
(760, 220),
(800, 220),
]