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.
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
GDScript giro sobre si mismo en eje "y" alterna de izquierda a derecha y de derecha a izquierda; tambien en eje "Z" ;Godot4.4;
extends MeshInstance3D
@export var rotation_speed_y: float = 0.03
@export var rotation_speed_z: float = 0.02 # Velocidad para el eje Z (ajusta según necesites)
@export var direction_change_interval: float = 3.0
var rotation_direction_y: int = 1
var rotation_direction_z: int = 1
var time_since_direction_change: float = 0.0
func _ready() -> void:
pass
func _process(delta: float) -> void:
rotate_y(rotation_speed_y * rotation_direction_y)
rotate_z(rotation_speed_z * rotation_direction_z)
time_since_direction_change += delta
if time_since_direction_change >= direction_change_interval:
rotation_direction_y *= -1
rotation_direction_z *= -1
time_since_direction_change = 0.0
GDScript giro sobre si mismo en eje "y" alterna de izquierda a derecha y de derecha a izquierda; Godot4.4;
extends MeshInstance3D
@export var rotation_speed: float = 0.03
@export var direction_change_interval: float = 3.0 # Intervalo de cambio de dirección en segundos
var rotation_direction: int = 1
var time_since_direction_change: float = 0.0
func _ready() -> void:
pass
func _process(delta: float) -> void:
rotate_y(rotation_speed * rotation_direction)
time_since_direction_change += delta
if time_since_direction_change >= direction_change_interval:
rotation_direction *= -1
time_since_direction_change = 0.0
GDScript baja puntuacion y escala a reduccion Sprite2D y mesh_instance_3d; hace efectos de barra de vida; funciona;Godot4.4;
extends Area3D
var score = 10
@onready var mesh_instance_3d = $"../../CharacterBody3D/CollisionShape3D/PROTAGONISTA EXPLORADORA VARIOS MOVIMIENTOS ANDAR CORRER GRITAR_/MeshInstance3D2 PRUEBAS DE CORAZON"
@onready var sprite_rojo = $"Sprite2D rojo"
@onready var label_resta = $"Label resta"
func _ready():
actualizar_visualizacion()
func _on_area_entered(area: Area3D) -> void:
if area.is_ancestor_of(self): #evita que se active el trigger con el mismo objeto que contiene el script
return
#$AudioStreamPlayer3D.play() #si lo quieres activar descomentalo
score -= 1
actualizar_visualizacion()
if score < 0:
get_tree().change_scene_to_file("res://ESCENAS/1-world_environmentESCENA-1-.tscn")
func actualizar_visualizacion():
label_resta.text = str(score)
var escala = float(score) / 10.0
sprite_rojo.scale = Vector2(escala, escala)
mesh_instance_3d.scale = Vector3(escala, escala, escala) #se corrige para que trabaje en 3D
if score <= 0:
sprite_rojo.visible = false
mesh_instance_3d.visible = false
func _on_timer_timeout() -> void:
pass