— Добавляем физику к пуле local bodyVelocity = Instance.new(«BodyVelocity») bodyVelocity.Velocity = tool.Handle.CFrame.LookVector * 100 — Скорость пули bodyVelocity.Parent = bullet
— Уничтожаем пулю через 2 секунды game.Debris:AddItem(bullet, 2)
— Обработка столкновения пули bullet.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local humanoid = hit.Parent:FindFirstChildOfClass(«Humanoid») if humanoid then humanoid:TakeDamage(damage) bullet:Destroy() — Уничтожаем пулю при столкновении end end end)
wait(reloadTime) canShoot = true print(«Перезарядка завершена!») else print(«Ожидание перезарядки или выстрел уже произведен...») end end
local function reload() if isReloading then print(«Перезарядка уже идет...») return end
local userInputService = game:GetService(«UserInputService») userInputService.InputBegan:Connect(function(input, gameProcessedEvent) if not gameProcessedEvent then if input.KeyCode == Enum.KeyCode.E then reload() end end end)
def print_board(): for row in b: print('|'.join(row)) print()
def check_winner(): for row in b: if row[0] == row[1] == row[2] != ' ': return True for col in range(3): if b[0][col] == b[1][col] == b[2][col] != ' ': return True if b[0][0] == b[1][1] == b[2][2] != ' ': return True if b[0][2] == b[1][1] == b[2][0] != ' ': return True return False
def start_game(): global p while True: print_board() r, c = map(int, input(f"{p} ход (строка, столбец): ").split()) if b[r][c] == ' ': b[r][c] = p if check_winner(): print_board() print(f"{p} победил!") break p = 'O' if p == 'X' else 'X' else: print(«Ячейка занята, попробуй снова.»)
if __name__ == "__main__": command = input(«Введите 'старт' для начала игры: „) if command.lower() == 'старт': start_game()
def print_board(): print('\n'.join([' | '.join(board[i:i + 3]) for i in range(0, 9, 3)]))
def check_winner(): for i in range(0, 9, 3): if board[i] == board[i + 1] == board[i + 2] != ' ': return board[i] for i in range(3): if board[i] == board[i + 3] == board[i + 6] != ' ': return board[i] if board[0] == board[4] == board[8] != ' ' or board[2] == board[4] == board[6] != ' ': return board[4] return None
def game(): for turn in range(9): print_board() player = 'X' if turn % 2 == 0 else 'O' if player == 'X': move = int(input(«Ваш ход (0-8): „)) else: move = random.choice([i for i in range(9) if board[i] == ' ']) print(f“Бот выбрал {move}»)
if board[move] == ' ': board[move] = player winner = check_winner() if winner: print_board() print(f«Победитель: {winner}») return print_board() print(«Ничья»)
import pygame, random pygame.init() s = pygame.display.set_mode((400, 300)) clock = pygame.time.Clock() snake, food, dx, dy = [[100, 50]], [random.randint(0, 39)*10, random.randint(0, 29)*10], 10, 0
while True: for e in pygame.event.get(): if e.type == pygame.QUIT: pygame.quit(); exit() if e.type == pygame.KEYDOWN: if e.key == pygame.K_UP: dx, dy = 0, -10 if e.key == pygame.K_DOWN: dx, dy = 0, 10 if e.key == pygame.K_LEFT: dx, dy = -10, 0 if e.key == pygame.K_RIGHT: dx, dy = 10, 0
head = [snake[0][0] + dx, snake[0][1] + dy] snake.insert(0, head) if head == food: food = [random.randint(0, 39)*10, random.randint(0, 29)*10] else: snake.pop() if head[0]<0 or head[0]>=400 or head[1]<0 or head[1]>=300 or head in snake[1:]: pygame.quit(); exit()
s.fill((0,0,0)) for segment in snake: pygame.draw.rect(s, (255,255,255), (segment[0], segment[1], 10, 10)) pygame.draw.rect(s, (255,0,0), (*food, 10, 10)) pygame.display.flip() clock.tick(15)
local isReloading = false
local reloadTime = 15
local damage = 100 — Урон, который будет наноситься
local canShoot = true
local function shoot()
if canShoot and not isReloading then
canShoot = false
print(«Выстрел!»)
— Создаем пулю
local bullet = Instance.new(«Part»)
bullet.Size = Vector3.new(0.2, 0.2, 2)
bullet.Color = Color3.fromRGB(255, 0, 0) — Красный цвет
bullet.Position = tool.Handle.Position + (tool.Handle.CFrame.LookVector * 2)
bullet.Anchored = false
bullet.CanCollide = true
bullet.Parent = game.Workspace
— Добавляем физику к пуле
local bodyVelocity = Instance.new(«BodyVelocity»)
bodyVelocity.Velocity = tool.Handle.CFrame.LookVector * 100 — Скорость пули
bodyVelocity.Parent = bullet
— Уничтожаем пулю через 2 секунды
game.Debris:AddItem(bullet, 2)
— Обработка столкновения пули
bullet.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local humanoid = hit.Parent:FindFirstChildOfClass(«Humanoid»)
if humanoid then
humanoid:TakeDamage(damage)
bullet:Destroy() — Уничтожаем пулю при столкновении
end
end
end)
wait(reloadTime)
canShoot = true
print(«Перезарядка завершена!»)
else
print(«Ожидание перезарядки или выстрел уже произведен...»)
end
end
local function reload()
if isReloading then
print(«Перезарядка уже идет...»)
return
end
print(«Начинаю перезарядку...»)
isReloading = true
wait(reloadTime)
isReloading = false
print(«Перезарядка завершена!»)
end
tool.Activated:Connect(shoot)
local userInputService = game:GetService(«UserInputService»)
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.E then
reload()
end
end
end)
class Game:
def __init__(self):
self.health = 100
def attack(self):
return «You've attacked the enemy!»
def heal(self):
self.health += 20
return «You've healed yourself!»
def enemy_attack(self):
damage = random.randint(5, 15)
self.health -= damage
return f«The enemy attacks you for {damage} damage!»
game = Game()
print(game.attack())
print(game.enemy_attack())
print(game.heal())
print(f«Current health: {game.health}»)
p = 'X'
def print_board():
for row in b:
print('|'.join(row))
print()
def check_winner():
for row in b:
if row[0] == row[1] == row[2] != ' ':
return True
for col in range(3):
if b[0][col] == b[1][col] == b[2][col] != ' ':
return True
if b[0][0] == b[1][1] == b[2][2] != ' ':
return True
if b[0][2] == b[1][1] == b[2][0] != ' ':
return True
return False
def start_game():
global p
while True:
print_board()
r, c = map(int, input(f"{p} ход (строка, столбец): ").split())
if b[r][c] == ' ':
b[r][c] = p
if check_winner():
print_board()
print(f"{p} победил!")
break
p = 'O' if p == 'X' else 'X'
else:
print(«Ячейка занята, попробуй снова.»)
if __name__ == "__main__":
command = input(«Введите 'старт' для начала игры: „)
if command.lower() == 'старт':
start_game()
board = [' ' for _ in range(9)]
def print_board():
print('\n'.join([' | '.join(board[i:i + 3]) for i in range(0, 9, 3)]))
def check_winner():
for i in range(0, 9, 3):
if board[i] == board[i + 1] == board[i + 2] != ' ':
return board[i]
for i in range(3):
if board[i] == board[i + 3] == board[i + 6] != ' ':
return board[i]
if board[0] == board[4] == board[8] != ' ' or board[2] == board[4] == board[6] != ' ':
return board[4]
return None
def game():
for turn in range(9):
print_board()
player = 'X' if turn % 2 == 0 else 'O'
if player == 'X':
move = int(input(«Ваш ход (0-8): „))
else:
move = random.choice([i for i in range(9) if board[i] == ' '])
print(f“Бот выбрал {move}»)
if board[move] == ' ':
board[move] = player
winner = check_winner()
if winner:
print_board()
print(f«Победитель: {winner}»)
return
print_board()
print(«Ничья»)
game()
pygame.init()
s = pygame.display.set_mode((400, 300))
clock = pygame.time.Clock()
snake, food, dx, dy = [[100, 50]], [random.randint(0, 39)*10, random.randint(0, 29)*10], 10, 0
while True:
for e in pygame.event.get():
if e.type == pygame.QUIT: pygame.quit(); exit()
if e.type == pygame.KEYDOWN:
if e.key == pygame.K_UP: dx, dy = 0, -10
if e.key == pygame.K_DOWN: dx, dy = 0, 10
if e.key == pygame.K_LEFT: dx, dy = -10, 0
if e.key == pygame.K_RIGHT: dx, dy = 10, 0
head = [snake[0][0] + dx, snake[0][1] + dy]
snake.insert(0, head)
if head == food: food = [random.randint(0, 39)*10, random.randint(0, 29)*10]
else: snake.pop()
if head[0]<0 or head[0]>=400 or head[1]<0 or head[1]>=300 or head in snake[1:]:
pygame.quit(); exit()
s.fill((0,0,0))
for segment in snake: pygame.draw.rect(s, (255,255,255), (segment[0], segment[1], 10, 10))
pygame.draw.rect(s, (255,0,0), (*food, 10, 10))
pygame.display.flip()
clock.tick(15)