ludo.py
ludo.py
import sys
import random
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 600, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Custom Ludo Game")
# Fonts
font = pygame.font.Font(None, 36)
# Dice configuration
dice_faces = [
pygame.image.load(f"dice_{i}.png") for i in range(1, 7)
]
dice_faces = [pygame.transform.scale(face, (50, 50)) for face in dice_faces]
# Players
players = ["Red", "Green", "Black", "White"]
colors = [RED, GREEN, BLACK, WHITE]
positions = [0, 0, 0, 0] # Starting positions
current_player = 0
scores = [0, 0, 0, 0] # Track player scores
# Board setup
TILE_SIZE = 50
NUM_TILES = 28 # Simplified board with 28 tiles
SAFE_ZONES = [4, 10, 16, 22] # Safe zone tiles
BONUS_TILES = [6, 14, 20] # Bonus tiles
TRAP_TILES = [8, 18, 24] # Trap tiles
# Draw tiles
for i in range(NUM_TILES):
x = (i % 7) * TILE_SIZE + 100
y = (i // 7) * TILE_SIZE + 100
# Display dice
screen.blit(dice_faces[dice_value - 1], (WIDTH - 100, HEIGHT // 2))
# Display scores
for i, score in enumerate(scores):
score_text = font.render(f"{players[i]}: {score}", True, colors[i])
screen.blit(score_text, (10, 50 + i * 30))
pygame.display.flip()
pygame.quit()
sys.exit()