If you're looking for the source code of Subway Surfers, I need to clarify that the game's code is proprietary and not publicly available. Subway Surfers is developed by Kiloo and SYBO Games, and its codebase is closed-source to protect their intellectual property.
However, if you're interested in creating a similar endless runner game (like Subway Surfers) for learning purposes, here’s a simple example using Python and the Pygame library. This is a basic implementation to get you started:
Simple Endless Runner Game (Python + Pygame)
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Simple Endless Runner")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
# Player settings
player_width = 50
player_height = 50
player_x = 100
player_y = HEIGHT - player_height - 50
player_speed = 5
jump_count = 10
is_jump = False
# Obstacle settings
obstacle_width = 50
obstacle_height = 50
obstacle_x = WIDTH
obstacle_y = HEIGHT - obstacle_height - 50
obstacle_speed = 5
# Score
score = 0
font = pygame.font.Font(None, 36)
# Game loop
clock = pygame.time.Clock()
running = True
def draw_player(x, y):
pygame.draw.rect(screen, BLACK, [x, y, player_width, player_height])
def draw_obstacle(x, y):
pygame.draw.rect(screen, (255, 0, 0), [x, y, obstacle_width, obstacle_height])
def display_score(score):
text = font.render(f"Score: {score}", True, BLACK)
screen.blit(text, (10, 10))
while running:
screen.fill(WHITE)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and not is_jump:
is_jump = True
# Player movement
if is_jump:
if jump_count >= -10:
neg = 1
if jump_count < 0:
neg = -1
player_y -= (jump_count ** 2) * 0.5 * neg
jump_count -= 1
else:
is_jump = False
jump_count = 10
# Obstacle movement
obstacle_x -= obstacle_speed
if obstacle_x < -obstacle_width:
obstacle_x = WIDTH
score += 1
# Collision detection
if (player_x < obstacle_x + obstacle_width and
player_x + player_width > obstacle_x and
player_y < obstacle_y + obstacle_height and
player_y + player_height > obstacle_y):
running = False
# Draw everything
draw_player(player_x, player_y)
draw_obstacle(obstacle_x, obstacle_y)
display_score(score)
pygame.display.update()
clock.tick(30)
pygame.quit()
sys.exit()
How It Works: