Загрузка данных
import os
import time
import random
import sys
import threading
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
class NeonRunner:
def __init__(self):
self.width = 60
self.height = 15
self.ground_y = self.height - 3
self.player_x = 8
self.player_y = self.ground_y
self.velocity = 0
self.gravity = 1
self.is_jumping = False
self.score = 0
self.high_score = 0
self.speed = 0.15
self.obstacles = []
self.particles = []
self.game_over = False
self.running = True
self.combo = 0
def draw_player(self):
player = [
" O ",
" /|\\ ",
" / \\ "
]
for i, line in enumerate(player):
y = self.player_y - 2 + i
if 0 <= y < self.height:
print(f"\033[{y+1};{self.player_x}H{line}", end='')
def draw_obstacle(self, x, height):
obs = "█" * 3
for i in range(height):
y = self.ground_y - i
if 0 <= y < self.height:
print(f"\033[{y+1};{x}H{obs}", end='')
def draw_ground(self):
ground = "═" * self.width
print(f"\033[{self.ground_y+1};1H\033[93m{ground}\033[0m", end='')
def draw_hud(self):
print(f"\033[1;1H\033[95mSCORE: {self.score:06d} COMBO: x{self.combo} HIGH: {self.high_score:06d}\033[0m")
print(f"\033[2;1H\033[96mNEON RUNNER v2.0 | ↑ скорость растёт\033[0m")
def add_obstacle(self):
if not self.obstacles or self.obstacles[-1][0] < self.width - 15:
height = random.randint(2, 4)
self.obstacles.append([self.width, height])
def add_particle(self, x, y):
self.particles.append([x, y, 5]) # x, y, lifetime
def update(self):
# Player physics
if self.is_jumping:
self.velocity += self.gravity
self.player_y += self.velocity
if self.player_y >= self.ground_y:
self.player_y = self.ground_y
self.is_jumping = False
self.velocity = 0
# landing particles
for _ in range(5):
self.add_particle(self.player_x + random.randint(1, 3), self.ground_y + 1)
# Update obstacles
for obs in self.obstacles[:]:
obs[0] -= 2
if obs[0] < -5:
self.obstacles.remove(obs)
self.combo += 1
self.score += 10 * self.combo
# Particles
for p in self.particles[:]:
p[2] -= 1
if p[2] <= 0:
self.particles.remove(p)
# Collision
player_hitbox = (self.player_x, self.player_y)
for obs in self.obstacles:
if obs[0] <= self.player_x + 3 and obs[0] + 3 >= self.player_x:
if self.player_y >= self.ground_y - obs[1] + 1:
self.game_over = True
def draw(self):
clear()
self.draw_hud()
self.draw_ground()
# Draw obstacles
for obs in self.obstacles:
self.draw_obstacle(obs[0], obs[1])
# Draw particles
for p in self.particles:
if random.random() > 0.3:
print(f"\033[{p[1]};{p[0]}H\033[91m✦\033[0m", end='')
self.draw_player()
# Неоновые линии
for i in range(1, self.height-1, 3):
print(f"\033[{i};1H\033[36m─\033[0m" * (self.width//10), end='')
def jump(self):
if not self.is_jumping:
self.is_jumping = True
self.velocity = -3
# jump particles
for _ in range(8):
self.add_particle(self.player_x + random.randint(0, 4), self.player_y + 2)
def run(self):
print("\033[?25l") # hide cursor
while self.running:
start_time = time.time()
self.add_obstacle()
self.update()
self.draw()
if self.game_over:
self.show_game_over()
break
# Increase difficulty
if self.score > 0 and self.score % 300 == 0:
self.speed = max(0.08, self.speed - 0.01)
# Input handling
try:
import msvcrt
if msvcrt.kbhit():
key = msvcrt.getch()
if key == b' ':
self.jump()
elif key == b'q':
self.running = False
except ImportError:
# Linux/mac
import termios, tty
# simple non-blocking input (simplified)
pass
elapsed = time.time() - start_time
time.sleep(max(0.05, self.speed - elapsed))
def show_game_over(self):
clear()
print("\033[91m")
print("╔" + "═" * 58 + "╗")
print("║ GAME OVER ║")
print("╚" + "═" * 58 + "╝\033[0m")
print(f"\n\033[93mFINAL SCORE: {self.score}\033[0m")
print(f"\033[96mHIGH SCORE: {max(self.high_score, self.score)}\033[0m")
print(f"\n\033[95mТы продержался {self.score//10} метров в неоновом аду!\033[0m\n")
print("Нажми любую клавишу для возврата в меню...")
if self.score > self.high_score:
self.high_score = self.score
input()
def main_menu():
while True:
clear()
print("\033[95m")
print(" █▄▀ █▀█ █░█ █▀█ █▀█ █▀")
print(" █░█ █▄█ █▄█ █▀▄ █▄█ ▄█")
print("\033[0m")
print(" NEON RUNNER")
print("\n" + "═" * 60)
print(" [ SPACE ] — ПРЫЖОК")
print(" [ Q ] — Выйти")
print("═" * 60)
print("\n1. Начать игру")
print("2. Как играть")
print("3. Выход")
choice = input("\nВыбери: ").strip()
if choice == "1":
game = NeonRunner()
game.run()
elif choice == "2":
clear()
print("ПРОБЕЛ — прыгать через препятствия")
print("Чем дольше ты бежишь — тем быстрее становится мир")
print("Набери максимальный комбо!")
input("\nНажми Enter...")
elif choice == "3":
print("\033[92mСпасибо за игру! Беги дальше в реальной жизни ⚡\033[0m")
break
if __name__ == "__main__":
try:
main_menu()
except KeyboardInterrupt:
print("\n\n\033[91mNeon Runner отключён...\033[0m")
finally:
print("\033[?25h") # show cursor