extends Node3D
# ============================================================
# NEON STRIKE: CYBER BEACH - Procedural FPS
# Godot 4.x
# ============================================================
const WORLD_SIZE := 90.0
const PLAYER_SPEED := 6.5
const PLAYER_RUN_SPEED := 11.5
const JUMP_FORCE := 8.0
const GRAVITY := 22.0
const MAX_HEALTH := 100
const MAX_AMMO := 35
const MAX_ENEMIES := 15
var player: CharacterBody3D
var camera: Camera3D
var weapon: Node3D
var muzzle: MeshInstance3D
var health := MAX_HEALTH
var ammo := MAX_AMMO
var score := 0
var kills := 0
var game_over := false
var victory := false
var yaw := 0.0
var pitch := 0.0
var fire_cooldown := 0.0
var damage_flash := 0.0
var dash_cooldown := 0.0
var enemies: Array[CharacterBody3D] = []
var pickups: Array[Area3D] = []
var health_bar: ProgressBar
var ammo_label: Label
var score_label: Label
var objective_label: Label
var crosshair: Label
var message_label: Label
var damage_overlay: ColorRect
var rng := RandomNumberGenerator.new()
# ============================================================
# READY
# ============================================================
func _ready():
rng.randomize()
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
create_environment()
create_world()
create_player()
create_weapon()
create_enemies()
create_pickups()
create_hud()
update_hud()
# ============================================================
# PROCESS
# ============================================================
func _process(delta):
if game_over or victory:
return
fire_cooldown = max(0.0, fire_cooldown - delta)
dash_cooldown = max(0.0, dash_cooldown - delta)
damage_flash = max(0.0, damage_flash - delta)
if damage_flash <= 0.0:
damage_overlay.color.a = 0.0
# Efeito leve de oscilação na arma (respiração)
if weapon:
weapon.position.y = lerp(weapon.position.y, -0.35 + sin(Time.get_ticks_msec() * 0.006) * 0.003, delta * 10.0)
update_hud()
# ============================================================
# PHYSICS
# ============================================================
func _physics_process(delta):
if game_over or victory:
return
handle_player(delta)
handle_pickups(delta)
# ============================================================
# INPUT
# ============================================================
func _input(event):
if game_over or victory:
if event is InputEventKey and event.pressed and event.keycode == KEY_R:
get_tree().reload_current_scene()
return
if event is InputEventMouseMotion:
var sensitivity := 0.0022
yaw -= event.relative.x * sensitivity
pitch -= event.relative.y * sensitivity
pitch = clamp(pitch, deg_to_rad(-85), deg_to_rad(85))
player.rotation.y = yaw
camera.rotation.x = pitch
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
shoot()
if event is InputEventKey and event.pressed:
if event.keycode == KEY_ESCAPE:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if event.keycode == KEY_R:
reload_weapon()
# ============================================================
# AMBIENTE (CYBER BEACH)
# ============================================================
func create_environment():
var world_environment := WorldEnvironment.new()
var environment := Environment.new()
environment.background_mode = Environment.BG_COLOR
environment.background_color = Color("#02040a")
environment.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
environment.ambient_light_color = Color("#2a3b60")
environment.ambient_light_energy = 0.6
environment.tonemap_mode = Environment.TONE_MAPPER_FILMIC
environment.glow_enabled = true
environment.glow_intensity = 1.2
environment.glow_bloom = 0.2
world_environment.environment = environment
add_child(world_environment)
# Luau / Lua Neon (Sol/Lua Noturna)
var moon := DirectionalLight3D.new()
moon.name = "MoonLight"
moon.rotation_degrees = Vector3(-45, -30, 0)
moon.light_color = Color("#80aaff")
moon.light_energy = 1.0
moon.shadow_enabled = true
add_child(moon)
# ============================================================
# MATERIAIS
# ============================================================
func material(color: Color, metallic := 0.0, roughness := 0.7) -> StandardMaterial3D:
var mat := StandardMaterial3D.new()
mat.albedo_color = color
mat.metallic = metallic
mat.roughness = roughness
return mat
func emissive_material(color: Color, energy := 4.0) -> StandardMaterial3D:
var mat := StandardMaterial3D.new()
mat.albedo_color = color
mat.emission_enabled = true
mat.emission = color
mat.emission_energy_multiplier = energy
return mat
# ============================================================
# MESH HELPERS
# ============================================================
func create_box(pos: Vector3, size: Vector3, color: Color, parent: Node = self, collision := true) -> MeshInstance3D:
var mesh_instance := MeshInstance3D.new()
var mesh := BoxMesh.new()
mesh.size = size
mesh_instance.mesh = mesh
mesh_instance.material_override = material(color)
mesh_instance.position = pos
parent.add_child(mesh_instance)
if collision:
var body := StaticBody3D.new()
body.position = pos
var shape := CollisionShape3D.new()
var box_shape := BoxShape3D.new()
box_shape.size = size
shape.shape = box_shape
body.add_child(shape)
parent.add_child(body)
return mesh_instance
func create_cylinder(pos: Vector3, radius: float, height: float, color: Color, parent: Node = self) -> MeshInstance3D:
var mesh_instance := MeshInstance3D.new()
var mesh := CylinderMesh.new()
mesh.top_radius = radius
mesh.bottom_radius = radius
mesh.height = height
mesh_instance.mesh = mesh
mesh_instance.material_override = material(color)
mesh_instance.position = pos
parent.add_child(mesh_instance)
var body := StaticBody3D.new()
body.position = pos
var collision := CollisionShape3D.new()
var shape := CylinderShape3D.new()
shape.radius = radius
shape.height = height
collision.shape = shape
body.add_child(collision)
parent.add_child(body)
return mesh_instance
# ============================================================
# CENÁRIO: CYBER BEACH
# ============================================================
func create_world():
# AREIA DA PRAIA (Tom escuro neon)
create_box(Vector3(0, -0.5, 0), Vector3(WORLD_SIZE, 1, WORLD_SIZE), Color("#12111a"))
# OCEANO / MAR FUTURISTA (Lado esquerdo ou fundo)
var water := create_box(Vector3(-WORLD_SIZE * 0.5 - 20, -0.2, 0), Vector3(40, 0.8, WORLD_SIZE + 40), Color("#003b5c"))
water.material_override = emissive_material(Color("#0077aa"), 1.5)
# CALÇADÃO / PASSARELA DE NEON
create_box(Vector3(0, 0.1, 0), Vector3(WORLD_SIZE - 10, 0.2, WORLD_SIZE - 10), Color("#191b28"))
# PAREDES DA ARENA / PIER DE CONTENÇÃO
var wall_height = 8.0
create_box(Vector3(0, wall_height/2, -WORLD_SIZE/2), Vector3(WORLD_SIZE, wall_height, 1), Color("#1f2438"))
create_box(Vector3(0, wall_height/2, WORLD_SIZE/2), Vector3(WORLD_SIZE, wall_height, 1), Color("#1f2438"))
create_box(Vector3(-WORLD_SIZE/2, wall_height/2, 0), Vector3(1, wall_height, WORLD_SIZE), Color("#1f2438"))
create_box(Vector3(WORLD_SIZE/2, wall_height/2, 0), Vector3(1, wall_height, WORLD_SIZE), Color("#1f2438"))
# QUIOSQUES / COBERTURAS ESTILO BEACH CLUB CYBERPUNK
var beach_huts := [
Vector3(-20, 2, -20), Vector3(20, 2, -20),
Vector3(-20, 2, 20), Vector3(20, 2, 20),
Vector3(0, 2, -28), Vector3(0, 2, 28)
]
for pos in beach_huts:
create_box(pos, Vector3(6, 4, 6), Color("#282b42"))
# Teto inclinado improvisado
create_box(pos + Vector3(0, 2.5, 0), Vector3(7, 0.5, 7), Color("#ff2a6d"))
# PALMEIRAS NEON
var palm_positions := [
Vector3(-35, 0, -35), Vector3(35, 0, -35),
Vector3(-35, 0, 35), Vector3(35, 0, 35),
Vector3(-35, 0, 0), Vector3(35, 0, 0)
]
for p in palm_positions:
create_cylinder(Vector3(p.x, 4, p.z), 0.3, 8.0, Color("#302030"))
# Folhas estilizadas com emissivo verde/azul neon
var leaves := create_box(Vector3(p.x, 8.2, p.z), Vector3(4.0, 0.2, 4.0), Color("#000000"), self, false)
leaves.material_override = emissive_material(Color("#05ffa1"), 3.0)
# LINHAS DE NÉON NO CHÃO (CALÇADÃO)
for x in [-30, -15, 0, 15, 30]:
var neon = create_box(Vector3(x, 0.25, 0), Vector3(0.15, 0.05, WORLD_SIZE - 10), Color("#000000"), self, false)
neon.material_override = emissive_material(Color("#00f0ff"), 3.0)
for z in [-30, -15, 0, 15, 30]:
var neon = create_box(Vector3(0, 0.25, z), Vector3(WORLD_SIZE - 10, 0.05, 0.15), Color("#000000"), self, false)
neon.material_override = emissive_material(Color("#ff007f"), 3.0)
# ILUMINAÇÃO DA ORLA
create_area_light(Vector3(-25, 9, -25), Color("#00f0ff"))
create_area_light(Vector3(25, 9, -25), Color("#ff007f"))
create_area_light(Vector3(-25, 9, 25), Color("#7928ca"))
create_area_light(Vector3(25, 9, 25), Color("#05ffa1"))
func create_area_light(pos: Vector3, color: Color):
var light := OmniLight3D.new()
light.position = pos
light.light_color = color
light.light_energy = 6.0
light.omni_range = 22.0
add_child(light)
var bulb := MeshInstance3D.new()
var sphere := SphereMesh.new()
sphere.radius = 0.3
sphere.height = 0.6
bulb.mesh = sphere
bulb.material_override = emissive_material(color, 5.0)
bulb.position = pos
add_child(bulb)
# ============================================================
# PLAYER
# ============================================================
func create_player():
player = CharacterBody3D.new()
player.name = "Player"
player.position = Vector3(0, 2, 32)
add_child(player)
var collision := CollisionShape3D.new()
var capsule := CapsuleShape3D.new()
capsule.radius = 0.45
capsule.height = 1.8
collision.shape = capsule
collision.position.y = 0.9
player.add_child(collision)
camera = Camera3D.new()
camera.name = "FPSCamera"
camera.position = Vector3(0, 1.55, 0)
camera.current = true
player.add_child(camera)
# Lanterna frontal no player
var flashlight := SpotLight3D.new()
flashlight.position = Vector3(0, 1.4, 0)
flashlight.rotation_degrees.x = -8
flashlight.light_energy = 2.5
flashlight.spot_range = 25.0
flashlight.spot_angle = 40.0
camera.add_child(flashlight)
# ============================================================
# MOVIMENTO & DASH
# ============================================================
func handle_player(delta):
var input_vector := Vector2(
Input.get_axis("ui_left", "ui_right") if Input.get_axis("ui_left", "ui_right") != 0 else Input.get_axis("move_left", "move_right"),
Input.get_axis("ui_up", "ui_down") if Input.get_axis("ui_up", "ui_down") != 0 else Input.get_axis("move_forward", "move_backward")
)
var direction := Vector3(input_vector.x, 0, input_vector.y).rotated(Vector3.UP, yaw)
var speed := PLAYER_SPEED
if Input.is_key_pressed(KEY_SHIFT):
speed = PLAYER_RUN_SPEED
player.velocity.x = direction.x * speed
player.velocity.z = direction.z * speed
if not player.is_on_floor():
player.velocity.y -= GRAVITY * delta
else:
player.velocity.y = -0.5
if Input.is_key_pressed(KEY_SPACE):
player.velocity.y = JUMP_FORCE
player.move_and_slide()
# ============================================================
# ARMA & TIRO
# ============================================================
func create_weapon():
weapon = Node3D.new()
weapon.name = "Weapon"
camera.add_child(weapon)
weapon.position = Vector3(0.4, -0.32, -0.65)
# Corpo da arma (Rifle Cyberpunk)
var gun := MeshInstance3D.new()
var mesh := BoxMesh.new()
mesh.size = Vector3(0.22, 0.2, 1.0)
gun.mesh = mesh
gun.material_override = material(Color("#1a1e29"), 0.85, 0.2)
gun.position.z = -0.3
weapon.add_child(gun)
# Detalhe Neon na arma
var strip := create_box(Vector3(0, 0.08, -0.3), Vector3(0.24, 0.04, 0.6), Color("#000000"), weapon, false)
strip.material_override = emissive_material(Color("#00f0ff"), 3.0)
# Cano
var barrel := CylinderMesh.new()
barrel.top_radius = 0.05
barrel.bottom_radius = 0.05
barrel.height = 0.4
var barrel_mesh := MeshInstance3D.new()
barrel_mesh.mesh = barrel
barrel_mesh.rotation_degrees.x = 90
barrel_mesh.position = Vector3(0, 0.02, -0.85)
barrel_mesh.material_override = material(Color("#0d0f14"), 0.9, 0.1)
weapon.add_child(barrel_mesh)
# Muzzle Flash
muzzle = MeshInstance3D.new()
var muzzle_mesh := SphereMesh.new()
muzzle_mesh.radius = 0.07
muzzle_mesh.height = 0.14
muzzle.mesh = muzzle_mesh
muzzle.material_override = emissive_material(Color("#ffea00"), 6.0)
muzzle.position = Vector3(0, 0.02, -1.1)
weapon.add_child(muzzle)
muzzle.visible = false
func shoot():
if fire_cooldown > 0:
return
if ammo <= 0:
reload_weapon()
return
ammo -= 1
fire_cooldown = 0.1
muzzle.visible = true
await get_tree().create_timer(0.03).timeout
if is_instance_valid(muzzle):
muzzle.visible = false
var from := camera.global_position
var direction := -camera.global_transform.basis.z
var to := from + direction * 1000
var query := PhysicsRayQueryParameters3D.create(from, to)
query.exclude = [player]
var result := get_world_3d().direct_space_state.intersect_ray(query)
if result:
var collider = result.collider
if collider and collider.has_method("take_damage"):
collider.take_damage(35)
# Recuo dinâmico na câmera
camera.rotation.x += deg_to_rad(0.8)
yaw += deg_to_rad(randf_range(-0.3, 0.3))
func reload_weapon():
if ammo >= MAX_AMMO:
return
ammo = MAX_AMMO
# ============================================================
# INIMIGOS (VARIADOS: DRONES E CYBER-GUARDS)
# ============================================================
func create_enemies():
var spawn_points := [
Vector3(-30, 1, -30), Vector3(30, 1, -30),
Vector3(-30, 1, 30), Vector3(30, 1, 30),
Vector3(-15, 1, -25), Vector3(15, 1, -25),
Vector3(-15, 1, 25), Vector3(15, 1, 25),
Vector3(-35, 1, 0), Vector3(35, 1, 0),
Vector3(0, 1, -32), Vector3(0, 1, 32),
Vector3(-22, 1, -12), Vector3(22, 1, 12), Vector3(0, 1, 0)
]
for i in range(min(MAX_ENEMIES, spawn_points.size())):
create_enemy(spawn_points[i])
func create_enemy(pos: Vector3):
var enemy := CharacterBody3D.new()
enemy.name = "Enemy"
enemy.position = pos
add_child(enemy)
var collision := CollisionShape3D.new()
var capsule := CapsuleShape3D.new()
capsule.radius = 0.45
capsule.height = 1.8
collision.shape = capsule
collision.position.y = 0.9
enemy.add_child(collision)
# Corpo do Inimigo Cyber Guard
var mesh := MeshInstance3D.new()
var capsule_mesh := CapsuleMesh.new()
capsule_mesh.radius = 0.45
capsule_mesh.height = 1.8
mesh.mesh = capsule_mesh
mesh.position.y = 0.9
mesh.material_override = material(Color("#ff0055"), 0.2, 0.4)
enemy.add_child(mesh)
# Visor Neon do Inimigo
var visor := MeshInstance3D.new()
var box := BoxMesh.new()
box.size = Vector3(0.5, 0.15, 0.3)
visor.mesh = box
visor.position = Vector3(0, 1.4, -0.2)
visor.material_override = emissive_material(Color("#ffea00"), 4.0)
enemy.add_child(visor)
enemy.set_script(load_enemy_script())
enemies.append(enemy)
func load_enemy_script() -> Script:
var script_text := """
extends CharacterBody3D
var hp := 100
var attack_timer := 0.0
func _ready():
hp = 100
func _physics_process(delta):
if not is_instance_valid(get_parent().player):
return
var target = get_parent().player
var distance = global_position.distance_to(target.global_position)
if distance > 2.0:
var direction = global_position.direction_to(target.global_position)
direction.y = 0
velocity.x = direction.x * 3.2
velocity.z = direction.z * 3.2
if not is_on_floor():
velocity.y -= 22.0 * delta
else:
velocity.y = -0.5
look_at(Vector3(target.global_position.x, global_position.y, target.global_position.z), Vector3.UP)
move_and_slide()
else:
velocity = Vector3.ZERO
attack_timer -= delta
if attack_timer <= 0:
attack_timer = 0.75
get_parent().damage_player(10)
func take_damage(amount):
hp -= amount
if hp <= 0:
get_parent().enemy_killed(self)
queue_free()
"""
var script := GDScript.new()
script.source_code = script_text
script.reload()
return script
func enemy_killed(enemy):
kills += 1
score += 150
enemies.erase(enemy)
create_death_effect(enemy.global_position)
if kills >= MAX_ENEMIES:
win_game()
func create_death_effect(pos: Vector3):
for i in range(10):
var particle := MeshInstance3D.new()
var sphere := SphereMesh.new()
sphere.radius = 0.09
particle.mesh = sphere
particle.material_override = emissive_material(Color("#ff0055"), 5.0)
particle.position = pos + Vector3(0, 1, 0)
add_child(particle)
var target := particle.position + Vector3(rng.randf_range(-3, 3), rng.randf_range(0, 4), rng.randf_range(-3, 3))
var tween := create_tween()
tween.tween_property(particle, "position", target, 0.4)
tween.parallel().tween_property(particle, "scale", Vector3.ZERO, 0.4)
tween.tween_callback(particle.queue_free)
# ============================================================
# DANO & ESTADOS DE JOGO
# ============================================================
func damage_player(amount):
if game_over or victory:
return
health -= amount
damage_flash = 0.15
damage_overlay.color = Color(1, 0, 0, 0.4)
if health <= 0:
health = 0
lose_game()
func lose_game():
game_over = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
message_label.text = "\nFIM DE JOGO\n\nEliminações: %d\nPontuação: %d\n\nPressione [R] para tentar novamente" % [kills, score]
message_label.visible = true
func win_game():
victory = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
message_label.text = "\nMISSÃO CUMPRIDA!\nA praia foi limpa com sucesso.\n\nEliminações: %d\nPontuação: %d\n\nPressione [R] para jogar novamente" % [kills, score]
message_label.visible = true
# ============================================================
# PICKUPS (VIDA & MUNIÇÃO)
# ============================================================
func create_pickups():
create_pickup(Vector3(-25, 1, 10), "health")
create_pickup(Vector3(25, 1, 10), "health")
create_pickup(Vector3(0, 1, -22), "ammo")
create_pickup(Vector3(0, 1, 22), "ammo")
func create_pickup(pos: Vector3, type: String):
var area := Area3D.new()
area.position = pos
area.set_meta("type", type)
add_child(area)
var collision := CollisionShape3D.new()
var shape := SphereShape3D.new()
shape.radius = 1.0
collision.shape = shape
area.add_child(collision)
var mesh := MeshInstance3D.new()
var sphere := SphereMesh.new()
sphere.radius = 0.35
mesh.mesh = sphere
if type == "health":
mesh.material_override = emissive_material(Color("#00ff88"), 4.0)
else:
mesh.material_override = emissive_material(Color("#ffcc00"), 4.0)
area.add_child(mesh)
pickups.append(area)
func handle_pickups(delta):
for pickup in pickups:
if not is_instance_valid(pickup):
continue
pickup.rotation.y += delta * 2.5
if pickup.global_position.distance_to(player.global_position) < 2.0:
var type: String = pickup.get_meta("type")
if type == "health" and health < MAX_HEALTH:
health = min(MAX_HEALTH, health + 40)
pickup.queue_free()
elif type == "ammo":
ammo = MAX_AMMO
pickup.queue_free()
# ============================================================
# HUD
# ============================================================
func create_hud():
var layer := CanvasLayer.new()
layer.name = "HUD"
add_child(layer)
# Barra de Vida
health_bar = ProgressBar.new()
health_bar.position = Vector2(30, 30)
health_bar.size = Vector2(280, 24)
health_bar.max_value = MAX_HEALTH
layer.add_child(health_bar)
# Munição
ammo_label = Label.new()
ammo_label.position = Vector2(30, 65)
ammo_label.add_theme_font_size_override("font_size", 22)
layer.add_child(ammo_label)
# Pontuação
score_label = Label.new()
score_label.position = Vector2(30, 100)
score_label.add_theme_font_size_override("font_size", 18)
layer.add_child(score_label)
# Objetivo
objective_label = Label.new()
objective_label.position = Vector2(30, 605)
objective_label.add_theme_font_size_override("font_size", 16)
layer.add_child(objective_label)
# Mira (Crosshair)
crosshair = Label.new()
crosshair.text = "+"
crosshair.position = Vector2(1152.0 / 2.0 - 8, 648.0 / 2.0 - 18)
crosshair.add_theme_font_size_override("font_size", 26)
crosshair.modulate = Color("#00f0ff")
layer.add_child(crosshair)
# Mensagem de Vitória/Derrota
message_label = Label.new()
message_label.position = Vector2(1152.0 / 2.0 - 250, 648.0 / 2.0 - 125)
message_label.size = Vector2(500, 250)
message_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
message_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
message_label.add_theme_font_size_override("font_size", 24)
message_label.visible = false
layer.add_child(message_label)
# Overlay de Dano (Flash Vermelho)
damage_overlay = ColorRect.new()
damage_overlay.position = Vector2.ZERO
damage_overlay.size = Vector2(1152.0, 648.0)
damage_overlay.color = Color(1, 0, 0, 0)
layer.add_child(damage_overlay)
func update_hud():
if not is_instance_valid(health_bar):
return
health_bar.value = health
ammo_label.text = "MUNIÇÃO: %02d / %02d" % [ammo, MAX_AMMO]
score_label.text = "PLACAR: %05d ELIMINAÇÕES: %02d / %02d" % [score, kills, MAX_ENEMIES]
objective_label.text = "OBJETIVO: ELIMINE TODOS OS INIMIGOS NA CYBER BEACH"