Godot, scripts para Godot estudios y aprendizajes, Creacion de videojuegos. Creacion y publicacion de videojuegos en internet. Como hacer videojuegos. C# unity. Animaciones unity blender. Personajes videojuegos graficos dibujos. Diseño grafico. Comic. Animaciones gif. Dibujo de retratos. Realidad virtual. Cine y realidad virtual.
domingo, 13 de abril de 2025
Ejemplo de IA persecucion de enemigos con Godot 4.4; Y GDScript que corrige que el enemigo mientras persige, no lo aga de espaldas;
sábado, 12 de abril de 2025
Ejemplo de animar por GDScript en Godot 4.4.;
extends Node3D
var animacion_actual = "Default simplified|GRITANDO"
var animacion_idle = "Default simplified|GRITANDO" # ANIMACION DE ESTAR QUIETO
func _ready():
$AnimationPlayer.play(animacion_actual)
pass
func _physics_process(delta):
var alguna_tecla_pulsada = false
if Input.is_action_pressed("ui_accept") or \
Input.is_action_pressed("mouse_left") or \
Input.is_action_pressed("luzcasco") or \
Input.is_action_pressed("ANDAATRASCONS") or \
Input.is_action_pressed("ANDAALANTECONW") or \
Input.is_action_pressed("ANDAALNTECONE") or \
Input.is_action_pressed("GIRADERECHACOND") or \
Input.is_action_pressed("A") or \
Input.is_action_pressed("D"):
alguna_tecla_pulsada = true
if alguna_tecla_pulsada:
# Agacharse (al presionar "luzcasco")
if Input.is_action_just_pressed("luzcasco"):
if animacion_actual != "Default simplified|ANDAR":
$AnimationPlayer.play("Default simplified|ANDAR")
animacion_actual = "Default simplified|ANDAR"
# Volver a correr (al soltar "mouse_left")
if Input.is_action_just_released("mouse_left"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
# Andar hacia atrás (al presionar "ANDAATRASCONS")
if Input.is_action_just_pressed("ANDAATRASCONS"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
# Volver a andar normal (al soltar "ANDAALANTECONW")
if Input.is_action_just_released("ANDAALANTECONW"):
if animacion_actual != "Default simplified|ANDAR":
$AnimationPlayer.play("Default simplified|ANDAR")
animacion_actual = "Default simplified|ANDAR"
# Otra acción para correr (al presionar "ANDAALNTECONE")
if Input.is_action_just_pressed("ANDAALNTECONE"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
# Volver a gritar (al soltar "GIRADERECHACOND")
if Input.is_action_just_released("GIRADERECHACOND"):
if animacion_actual != "Default simplified|GRITANDO":
$AnimationPlayer.play("Default simplified|GRITANDO")
animacion_actual = "Default simplified|GRITANDO"
# Correr con "A" (al presionar)
if Input.is_action_just_pressed("A"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
# Gritar con "A" (al soltar)
if Input.is_action_just_released("A"):
if animacion_actual != "Default simplified|GRITAR":
$AnimationPlayer.play("Default simplified|GRITAR")
animacion_actual = "Default simplified|GRITAR"
# Correr con "D" (al presionar)
if Input.is_action_just_pressed("D"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
# Correr con "D" (al soltar) - REVISA ESTA LÓGICA
if Input.is_action_just_released("D"):
if animacion_actual != "Default simplified|correr":
$AnimationPlayer.play("Default simplified|correr")
animacion_actual = "Default simplified|correr"
else:
# Si no se presiona ninguna tecla, reproduce la animación de estar quieto
if animacion_actual != animacion_idle:
$AnimationPlayer.play(animacion_idle)
animacion_actual = animacion_idle
miércoles, 9 de abril de 2025
Godot 4.4 instancia la caida de dos piedras, dos GDScript, en el segundo GDScript hay un intervalo de 3 segundos de una piedra en otra;
extends Area3D
#var Esferauno = preload("res://PERSONAJES MACABROS/ARAÑA/EXPLOTADA ARAÑA.tscn")
var Esferauno = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-2-.tscn")
var EsferaDOS = preload("res://CONSTRUCCIONES/rigid_body_3d_piedra_cae-3-.tscn")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
#translate(Vector3(0,0,-0.001))
pass
func _on_area_entered(area: Area3D) -> void:
var parent = get_parent()
var CollisionShape3Dcubo = parent.get_node("CollisionShape3D")
get_node("CollisionShape3D").queue_free()
$"../RigidBody3D PIEDRA CAE".queue_free()
pass # Replace with function body.
func _on_area_exited(area: Area3D) -> void:
var Esferauno = Esferauno.instantiate()
add_child(Esferauno)
var EsferaDOS = EsferaDOS.instantiate()
add_child(EsferaDOS)
pass # Replace with function body.
lunes, 7 de abril de 2025
miércoles, 2 de abril de 2025
IA genera videojuego html
¡Claro! Aquí te dejo un ejemplo básico de un videojuego en HTML, CSS y JavaScript. Se trata de un juego de "Pong" clásico.
*index.html*
```
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pong</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<canvas id="canvas" width="600" height="400"></canvas>
<script src="script.js"></script>
</body>
</html>
```
*styles.css*
```
body {
background-color: #f0f0f0;
}
#canvas {
border: 1px solid #000;
}
```
*script.js*
```
// Obtener el canvas
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
// Definir constantes
const WIDTH = canvas.width;
const HEIGHT = canvas.height;
const BALL_SIZE = 20;
const PADDLE_WIDTH = 10;
const PADDLE_HEIGHT = 100;
const FPS = 60;
// Definir variables
let ballX = WIDTH / 2;
let ballY = HEIGHT / 2;
let ballVelX = 5;
let ballVelY = 5;
let paddle1Y = HEIGHT / 2 - PADDLE_HEIGHT / 2;
let paddle2Y = HEIGHT / 2 - PADDLE_HEIGHT / 2;
let score1 = 0;
let score2 = 0;
// Función para dibujar el canvas
function draw() {
ctx.clearRect(0, 0, WIDTH, HEIGHT);
ctx.fillStyle = '#000';
ctx.fillRect(0, paddle1Y, PADDLE_WIDTH, PADDLE_HEIGHT);
ctx.fillRect(WIDTH - PADDLE_WIDTH, paddle2Y, PADDLE_WIDTH, PADDLE_HEIGHT);
ctx.beginPath();
ctx.arc(ballX, ballY, BALL_SIZE / 2, 0, 2 * Math.PI);
ctx.fill();
ctx.font = '36px Arial';
ctx.textAlign = 'left';
ctx.textBaseline = 'top';
ctx.fillStyle = '#000';
ctx.fillText(score1, 10, 10);
ctx.textAlign = 'right';
ctx.fillText(score2, WIDTH - 10, 10);
}
// Función para actualizar el juego
function update() {
ballX += ballVelX;
ballY += ballVelY;
if (ballY < 0 || ballY > HEIGHT - BALL_SIZE) {
ballVelY = -ballVelY;
}
if (ballX < 0) {
score2++;
ballX = WIDTH / 2;
ballY = HEIGHT / 2;
ballVelX = -ballVelX;
}
if (ballX > WIDTH - BALL_SIZE) {
score1++;
ballX = WIDTH / 2;
ballY = HEIGHT / 2;
ballVelX = -ballVelX;
}
if (ballX < PADDLE_WIDTH && ballY > paddle1Y && ballY < paddle1Y + PADDLE_HEIGHT) {
ballVelX = -ballVelX;
}
if (ballX > WIDTH - PADDLE_WIDTH - BALL_SIZE && ballY > paddle2Y && ballY < paddle2Y + PADDLE_HEIGHT) {
ballVelX = -ballVelX;
}
}
// Función para manejar los eventos del teclado
function handleKeyDown(event) {
if (event.key === 'w') {
paddle1Y -= 10;
}
if (event.key === 's') {
paddle1Y += 10;
}
if (event.key === 'ArrowUp') {
paddle2Y -= 10;
}
if (event.key === 'ArrowDown') {
paddle2Y += 10;
}
}
// Agregar eventos
document.addEventListener('keydown', handleKeyDown);
// Función principal
function main() {
update();
draw();
setTimeout(main, 1000 / FPS);
}
// Iniciar el juego
main();
```
Puedes abrir el archivo `index.html` en un navegador web para jugar. Utiliza las teclas "W" y "S" para controlar la paleta izquierda, y las flechas "Arriba" y "Abajo" para controlar la paleta derecha.
lunes, 31 de marzo de 2025
Subir y bajar una puerta con Godot 4.4; perfecto; en GDScript;
extends Area3D
@export var velocidad_subida: float = 3.3
@export var velocidad_bajada: float = 3.3 # Cambié el nombre para mayor claridad
@export var altura_maxima: float = 5.0 # Altura máxima que subirá el objeto
@export var altura_inicial: float = 0.0 # Altura inicial del objeto
var objeto: Node3D # Variable para almacenar el nodo CSGBox3D7
var subiendo: bool = false
var bajando: bool = false
var altura_actual: float = 0.0
func _ready():
objeto = $CSGBox3D7 # Asignamos el nodo a la variable
altura_actual = objeto.position.y # Obtiene la altura inicial del objeto
altura_inicial = altura_actual # guarda la altura inicial
func _physics_process(delta):
if objeto: # Verifica si el objeto existe
if subiendo:
altura_actual += velocidad_subida * delta
altura_actual = min(altura_actual, altura_inicial + altura_maxima) # Limita la altura máxima
objeto.position.y = altura_actual
if altura_actual >= altura_inicial + altura_maxima:
subiendo = false # Detiene la subida al alcanzar la altura máxima
elif bajando:
altura_actual -= velocidad_bajada * delta
altura_actual = max(altura_actual, altura_inicial) # Limita la altura mínima
objeto.position.y = altura_actual
if altura_actual <= altura_inicial:
bajando = false # Detiene la bajada al alcanzar la altura inicial
func _on_area_entered(area: Area3D) -> void:
subiendo = true
bajando = false
func _on_area_exited(area: Area3D) -> void:
subiendo = false
bajando = true
domingo, 30 de marzo de 2025
puerta en Godot 4.4 abrirla;
extends Area3D
@export var velocidad_subida: float = 1.3
var subiendo: bool = false
func _physics_process(delta):
if subiendo:
if $CSGBox3D7: # verifica si el nodo existe
$CSGBox3D7.translate(Vector3(0, velocidad_subida, 0) * delta)
func _on_area_entered(area: Area3D) -> void:
subiendo = true
func _on_area_exited(area: Area3D) -> void:
subiendo = false