miércoles, 31 de enero de 2024

Script para Godot3d 4.2 sencillisimo para instanciar un personaje cuando algo entra en el Area3d;

 extends Area3D


var Calva = preload("res://calva.tscn")


func _ready():


pass # Replace with function body.


func _on_area_entered(area):

var calva = Calva.instantiate()

add_child(calva)

pass # Replace with function body.

---------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
EXPLICACION: Dos semanas asta conseguir esto increible.......en fin , por fin consegui instanciar de diversas formas en godot3d version 4.2 , esta es muy buena para abatir enemigos y que los cambie por una copia con otra animacion o una explosion o lo que se tercie, en un area3d vacia cuando por ejemplo pasa un proyectil se instancia en este caso un personaje que tiene una animacion, tengo que seguir estudiando y trabajando, a partir de estos conocimientos no me sera complicado cambiar un enemigo vivo por uno muerto al ser impactado por una bala, y tambien podre cambiar escenas enteras espero, y jugar con camaras.............bueno hay estoy¡¡¡¡¡ (si alguien usa el script que recuerde usar el tema de "señales" de godot que elija func _on_area_entered(area):     cuando sale la flechita verde ala izquierda de la linea del script sabreis que funcionara si o si y que lo mejor para que el personaje este en la ruta correcta es que lo arrastreis el ",tscn" en este caso res://calva.tscn desde el sistema de archivos al parentesis -----var Calva = preload("res://calva.tscn")---------asi lo tengais donde lo tengais funcionara.
Aunque todo es insistir probar insistir probar y trabajar, quizas ayude alguien mis anotaciones............).

martes, 30 de enero de 2024

Usar LOOD en Godot4.2 reducir poligonos y reducir memoria para fluidez de los juegos en Godot;

Una pelicula vale mas que 1000 palabras, el sistema de LOOD o LOD sirve para reducir los poligonos que dibujan los objetos del juego, personajes, edificios, vegetacion, vehiculos, lo que sea.....cuando estas lejos pocos poligonos poca memoria necesita gana fluidez cuando estas mas cerca mas nitidez y mas poligonos, si se save jugar con la memoria de los desarrollos, importa un pimiento la que tengas en tu pc , .....claro que si puedes tener un buen pc aprobecha , pero es mas saber utilizar la maquina de la que se dispone, yo personalmente estoy muy entusiasmado con Godot quizas no es tan perfeccionista con los resultados pero, si no bas a ser profesional y trabajar para otro.....creo que no tienes nada que perder teniendo en cuenta que godot es totalmente gratuito y que encima hay posibilidares de ganar algo haciendo juegos con el, 

y ahora que empiezo a comprender el tema de instanciar objetos en las escenas con Godot4.2, me boy a poner las botas haciendo virgerias con este estupendo motor de juegos gratuito........Godot.
 

lunes, 29 de enero de 2024

instancia muy simple en godot4.2;

 extends Area3D

var Bullet = preload("res://cubo.tscn")


# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):


var bullet = Bullet.instantiate()

add_child(bullet)

pass



----------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------

extends Area3D

var Bullet = preload("res://cubo.tscn")

func _ready():

pass # Replace with function body.

func _process(delta):

var bullet = Bullet.instantiate()

add_child(bullet)

pass


----------------------------------------------------------------------------------------------------------

------------------------------------------------------------------

otra manera que funciona de instanciar en godot4.2

-------------------------------------------------------------------------------------------------------------

extends Area3D


var Bullet = preload("res://cubo.tscn")


var time = 0

var interval = 1.0  # Time interval between bullet instantiation


func _ready():

pass # Replace with function body.


func _process(delta):

time += delta


if time > interval:

time = 0


var bullet = Bullet.instantiate()

add_child(bullet)

-------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

este de debajo me falla pero creo que es por mi configuracion personalizada de teclas en godot algo que e de solucionar

--------------------------------------------------------------------------------------------------------------

extends Area3D


var Bullet = preload("res://cubo.tscn")


var pressed = false


func _ready():

pass # Replace with function body.


func _input(event):

if event is InputEventKey:

if event.scancode == KEY_SPACE:

if not pressed:

pressed = true

var bullet = Bullet.instantiate()

add_child(bullet)

---------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------

otro ejemplo, con el boton izquierdo del raton me funciona por que lo e configurado desde un principio asignandole esa bariacion de entradas de teclado desde Proyecto---configuracion de proyecto-----

------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

extends Area3D


var Bullet = preload("res://cubo.tscn")


func _ready():

pass # Replace with function body.


func _input(event):

if event is InputEventMouseButton:

if event.button_index == 1:

var bullet = Bullet.instantiate()

add_child(bullet)

------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
otro ejemplo al tocar un trigger
------------------------------------------------------------------------------------------------------


extends Area3D


var Bullet = preload("res://cubo.tscn")


func _ready():

    pass # Replace with function body.


func _physics_process(delta):

    # Check if the player is touching the trigger

    if $Trigger.is_colliding():

        var bullet = Bullet.instantiate()

        add_child(bullet)


--------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------

este script que funciona solo aplica una fuerza para lanzar un cubo 

-----------------------------------------------------------------------------------------------------


extends RigidBody3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass

translate(Vector3(111,0,0) * get_process_delta_time())








extends CharacterBody3D-------para godot4.2 a de tener una camara y solo es para CharacterBody3D-;

 extends CharacterBody3D


const SPEED = 5.0

const JUMP_VELOCITY = 4.5

const FRICTION = 25

const HORIZONTAL_ACCELERATION = 30

const MAX_SPEED=5

# Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")


@onready var camera = $Camera3D




func _ready():

Input.mouse_mode=Input.MOUSE_MODE_CAPTURED


func _unhandled_input(event):

if event is InputEventMouseMotion and Input.mouse_mode==Input.MOUSE_MODE_CAPTURED:

rotate_y(-event.relative.x * .005)

camera.rotate_x(-event.relative.y * .005)

camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)


func _unhandled_key_input(event):

if Input.is_action_just_pressed("ui_cancel"):

if Input.mouse_mode==Input.MOUSE_MODE_CAPTURED: 

Input.mouse_mode=Input.MOUSE_MODE_VISIBLE

else:

Input.mouse_mode=Input.MOUSE_MODE_CAPTURED


func _physics_process(delta):

# Add the gravity.

if not is_on_floor():

velocity.y -= gravity * delta


# Handle Jump.

if Input.is_action_just_pressed("ui_accept") and is_on_floor() and Input.mouse_mode==Input.MOUSE_MODE_CAPTURED:

velocity.y += JUMP_VELOCITY


# Get the input direction and handle the movement/deceleration.

# As good practice, you should replace UI actions with custom gameplay actions.

var input_dir = Vector3.ZERO

var movetoward = Vector3.ZERO

input_dir.x = Input.get_vector("move_left", "move_right", "move_forward", "move_backward").x

input_dir.y = Input.get_vector("move_left", "move_right", "move_forward", "move_backward").y

input_dir=input_dir.normalized()

var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

direction *= SPEED

velocity.x = move_toward(velocity.x,direction.x, HORIZONTAL_ACCELERATION * delta)

velocity.z = move_toward(velocity.z,direction.z, HORIZONTAL_ACCELERATION * delta)


var angle=5

#rotation_degrees=Vector3(input_dir.normalized().y*angle,rotation_degrees.y,-input_dir.normalized().x*angle)

var t = delta * 6

if Input.mouse_mode==Input.MOUSE_MODE_CAPTURED: 

rotation_degrees=rotation_degrees.lerp(Vector3(input_dir.normalized().y*angle,rotation_degrees.y,-input_dir.normalized().x*angle),t)

move_and_slide()

force_update_transform()


Script para Godot version3.5 mover un objeto con teclas;

 extends RigidBody


var velocity = Vector3()


func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()


# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 1

if Input.is_action_pressed("ui_right"):

velocity.x += 1

if Input.is_action_pressed("ui_up"):

velocity.y += 1

if Input.is_action_pressed("ui_down"):

velocity.y -= 1


# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)

-----------------------------------------------------------------------

otra forma

---------------------------------------------------------------------------------

extends RigidBody


var velocity = Vector2()


func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()


# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.y += 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.y -= 10 * delta


# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)

----------------------------------------------------------------------------------------------------------------------
otra combinacion

------------------------------------------------------------------------------------------------------------------

extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)




------------------------------------------------------------------------------------------------------------
otra version alante atras izquierda derecha suve y baja
------------------------------------------------------------------------------------------------------
extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



if Input.is_action_pressed("ui_accept"):
velocity.y += 10 * delta
if Input.is_action_just_pressed("ui_end"):
velocity.y -= 20 * delta






# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)


-------------------------------------------------------------
otra girando sobre si mismo una parte
-------------------------------------------------------------------------------

extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):
   rotate_y(-10 * delta)
#velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



if Input.is_action_pressed("ui_accept"):
velocity.y += 10 * delta
if Input.is_action_just_pressed("ui_end"):
velocity.y -= 20 * delta






# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)







domingo, 28 de enero de 2024

Instanciar en Godot solo me funciona en la version 3 de godot no en la 4.2;

 extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



# Called when the node enters the scene tree for the first time.

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





func _on_Timer_timeout():

spawn_ProjCopies()

-------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------

EXPLICACION : SI QUIERES INSTANCIAR OBJETOS DENTRO DE UNA ESCENA USA LA VERSION 3 DE GODOT DONDE TIENE EL NODO SPATIAL LA VERSION 4.2 LLEVO SEMANAS INTENTANDOLO Y NO ENCUENTRO NI EJEMPLOS POR INTERNET....

aqui facilito un video del tema es una practica que hice de otro que vi en internet y con paciencia logre el mismo resultado.........mi fallo usaba la version de godot4,2 y este video solo funciona si se usa godot3 en la version 3 recalco version 3.5.3 estable


extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



# Called when the node enters the scene tree for the first time.

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventMouseButton:

if event.button_index == BUTTON_LEFT:

spawn_ProjCopies()



-----------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------

EXPLICACION: AQUI FUNCIONA PRESIONANDO BOTON IZQUIERDO DEL MOUSE

----------------------------------------------------------------------------------------------------------------







extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



# Called when the node enters the scene tree for the first time.

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventKey:

if event.scancode == KEY_A:

spawn_ProjCopies()




-----------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------

EXPLICACION: AQUI FUNCIONA PRESIONANDO LETRA "A" DEL TECLADO

----------------------------------------------------------------------------------------------------------------




jueves, 25 de enero de 2024

https://gamejolt.com/@paco415/games;

😁😀😂😃😄😎😌😋😊😉😈😇😆😅😏😐😑😒😓

128 GAMES DE ESTE BLOG 

😁😀😂😃😄😎😌😋😊😉😈😇😆😅😏😐😑😒😓

martes, 23 de enero de 2024

Script GDScript para Godot3d 4.2 cuando algo entra en Area3d borra diversos elementos y escala uno y cuando sale provoca sonido;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

var parent = get_parent()

var Area3DBETA = parent.get_node("Area3DBETA")

#Area3DBETA.queue_free()

get_node("CollisionShape3DBETA").queue_free()

get_node("AMETRALLADOR DE BLENDER PINTADOBETA").queue_free()

get_node ("MeshInstance3DBETA")

scale.y+=5.0


scale.x+=5.2


scale.z+=5.2

pass # Replace with function body.



func _on_area_exited(area):

$AudioStreamPlayer.play()

pass # Replace with function body.


Script en GDScript para godot3d 4.2 , cuando algo entra en un Area3d produce un sonido, cuando algo sale del Area3d se borra su contenido;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_exited(area):

queue_free()

pass # Replace with function body.



func _on_area_entered(area):

$"../../AudioStreamPlayer".play()

pass # Replace with function body.

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
EXPLICACION:
Entra en Area3d
 algo func _on_area_entered(area):

$"../../AudioStreamPlayer".play()

pass # Replace with function body.

emite sonido.........

Sale algo del Area3d 

func _on_area_exited(area):

queue_free()

pass # Replace with function body.

se borra su contenido.

Como se pone un sonido de musica de fondo en Godot 3d 4.2 que este en bucle y suene una y otra vez?;




 




sábado, 20 de enero de 2024

Ejemplo de html;

<!DOCTYPE html>
<html>
<head>
<title>Girar un cuadrado verde</title>
<style>
.square {
width: 100px;
height: 100px;
background-color: green;
animation: rotate 2s infinite;
}

@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="square"></div>
</body>
</html>

Girar un cuadrado verde

Script para Godot3d 4.2 borra elementos hijos de un area3d al haber una colision y aumenta el tamaño de otro elemento;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

var parent = get_parent()

var Area3DBETA = parent.get_node("Area3DBETA")

#Area3DBETA.queue_free()

get_node("CollisionShape3DBETA").queue_free()

get_node("AMETRALLADOR DE BLENDER PINTADOBETA").queue_free()

get_node ("MeshInstance3DBETA")

scale.y+=2.2


scale.x+=2.2


scale.z+=2.2

pass # Replace with function body.

----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------

EXPLICACION:
Este script borra dos hijos de un Area 3d y proboca el escalado el aumento de otro de los hijos, quiero que al destruir un objeto aparezca otro desde dentro de el y creo que se puede conseguir el efecto con este metodo, lo perfecto seria no escalar si no borrar  e intanciar otro elemento, pero de momento no consigo hacerlo, pero ya lo are ya ....solo es trabajo y estudio y practica y contancia y tozudez y yo de eso boy sobrado¡¡¡¡¡

Script para Godot3d 4.2 ......3ª ejemplo de borrar hijos de nodos por colision;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

var parent = get_parent()

var Area3DBETA = parent.get_node("Area3DBETA")

#Area3DBETA.queue_free()

get_node("CollisionShape3DBETA").queue_free()

get_node("AMETRALLADOR DE BLENDER PINTADOBETA").queue_free()

pass # Replace with function body.




-----------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------

EXPLICACION: DE LINEAS FUNDAMENTALES.....

func _on_area_entered(area):-------------Area donde entra un objeto un proyectil por ejemplo.

var parent = get_parent()-------------------Parentesco.

var Area3DBETA = parent.get_node("Area3DBETA")------Nombre del padre desde donde salen los hijos a borrar al haber una colision.


#Area3DBETA.queue_free()---------------------No hace nada al haber este signo "#" si no lo tuviese borraria el Area3DBETA padre completa hijos incluidos


get_node("CollisionShape3DBETA").queue_free()--------------Este elemento se borra al haber colision.

get_node("AMETRALLADOR DE BLENDER PINTADOBETA").queue_free()----Este elemnto se borra al haber colision.

miércoles, 17 de enero de 2024

COMO SE CAMBIA EL AMBIENTE EL CIELO EN GODOT3D 4.2

 WorldEnvironment, la clave es poner este nodo de padre de todo el juego principal, como escena principal, a partir de hay es muy intuitivo cambiar el color de la ambientacion, en el video muestro los pasos principales,  a partir de hay ,,,,,,,,,,,,,,,,,,,¡¡¡¡¡¡¡¡¡¡¡

Crei en un principio que DirectionalLight3D era el que hacia la luz del cielo pero no es, .........es  WorldEnvironment y a de estar como raiz de todo, lo que si hace DirectionalLight3D es si se activa Shadow  son las sombras que las crea Godot, yo al aparato volar le puesto una luz linterna que queda muy bien con esa ambientacion oscura que me gusta dar a casi todos mis juegos...


domingo, 14 de enero de 2024

Demo de juego echo en godot3d 4.2;

 

EN CONSTRUCCION LA DESCARGA DEL JUEGO POR PROBLEMAS TECNICOS DE CONEXION INTERNET..........................................................................................................................................................................................................................................................17-1-24.......ESTOY EN ELLO----------



------------------------------------

sábado, 13 de enero de 2024

SCRIPT PARA GODOT3D 4.2 QUE TIENE MEJORAS EN MANEJAR UN APARATO VOLADOR;

 extends RigidBody3D



func _ready():



# Agrega el código que deseas ejecutar aquí.

pass




func _process(delta):

# Agrega el código que deseas ejecutar aquí.

pass

























#func _input(event: InputEvent):

#if event is InputEventKey and event.scancode == KEY_N and event.pressed:




#rotate_y(0.1)





















func _unhandled_input(event):

#if event is InputEventKey:

#if event.pressed and event.keycode == KEY_O:

if event is InputEventKey and event.pressed:

if event.keycode == KEY_J:

#queue_free()

translate(Vector3(111,0,0) * get_process_delta_time())

$AudioStreamPlayer.play()

pass


if event is InputEventKey and event.pressed:

if event.keycode == KEY_L:

 

#queue_free()

translate(Vector3(-111,0,0) * get_process_delta_time())

$AudioStreamPlayer.play()

pass

 

if event is InputEventKey and event.pressed:

if event.keycode == KEY_I:

translate(Vector3(0,0,111) * get_process_delta_time())

$AudioStreamPlayer.play()

pass








 

if event is InputEventKey and event.pressed:

if event.keycode == KEY_K:

 

#queue_free()

translate(Vector3(0,0,-111) * get_process_delta_time())

$AudioStreamPlayer.play()

pass


if event is InputEventKey and event.pressed:

if event.keycode == KEY_Z:

#queue_free()

translate(Vector3(0,111,0) * get_process_delta_time())

pass

 

if event is InputEventKey and event.pressed:

if event.keycode == KEY_R:

 

#queue_free()

translate(Vector3(0,-111,0) * get_process_delta_time())

pass 










#if event is InputEventKey and event.pressed:

#if event.keycode == KEY_O:

 

#queue_free()

#rotate_y(0.5) 

#pass 








 

#if event is InputEventKey and event.pressed:

#if event.keycode == KEY_P:

 

#queue_free()

#rotate_y(-0.5)

#pass 

#if event.keycode == KEY_9:

#add_constant_force(Vector3(0,-33,0))

#pass

#if event.keycode == KEY_8:

#add_constant_force(Vector3(0,33,0))

#pass

if event.keycode == KEY_Z:

apply_torque_impulse(Vector3(0,-0.1,0))

pass


if event.keycode == KEY_X:

apply_torque_impulse(Vector3(0, 0.1,0))

pass

if event.keycode == KEY_E: 


apply_impulse(Vector3(0,110,0))

pass


if event.keycode == KEY_W:

#move_and_slide(Vector3(0, 0, 40))

apply_impulse(Vector3(0,0,40))

pass





if event.keycode == KEY_S: 

apply_impulse(Vector3(0,0,-40))

pass

if event.keycode == KEY_A: 

apply_impulse(Vector3(40,0,0))

pass

if event.keycode == KEY_D: 

apply_impulse(Vector3(-40,0,0))

pass


if event.keycode == KEY_1:

rotate_z(1)

pass

if event.keycode == KEY_2:

rotate_x(1)

#queue_free()

pass


---------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------

EXPLICACION: FUNCIONA ELEVARSE -E- ALANTE ATRAS IZQUIERDA DERECHA W-A-S-D

GIRAR -Z-X- , TIENE EL DEFECTO QUE CUANDO A GIRADO AL PRESIONAR -W- YA NO AVANZA ADELANTE AVANZA HACIA ATRAS, Y AL GIRAR DE NUEVO , VUELVE A AVANZAR PRESIONANDO -W-, CON LA -S- OCURRE IGUAL VA HACIA ATRAS Y SI AGIRADO CAMBIA Y VA HACIA ADELANTE........YA LO CORREGIRE POCO A POCO....

viernes, 12 de enero de 2024

Ejercicios html 2

Toca con dedo cuadrado y se movera Mover Cuadrado

















TOCA EL CUADRADO Y SE MOVERA

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Mover Cuadrado</title>
    <style>
      .square {
        width: 100px;
        height: 100px;
        background-color: red;
        position: absolute;
        left: 0;
        transition: all 0.4s;
      }

      .square.move {
        left: calc(100% - 100px);
      }
    </style>
  </head>

  <body>
    <div class="square" ontouchstart="moveSquare()"></div>

    <script>
      function moveSquare() {
        var square = document.querySelector(".square");
        square.classList.add("move");

        setTimeout(function () {
          square.classList.remove("move");
        }, 400);
      }
    </script>
  </body>
</html>








Ejercicios html

Tocas el cuadrado y salen bolas hacia arriba Interactive Square

jueves, 11 de enero de 2024

Script para godot3d 4.2 cuando presiono tecla "M" se reinicia el juego; esta puesto en un MeshInstance3D; y es bicnieto;

 extends MeshInstance3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass

func _unhandled_input(event):

if event is InputEventKey:

if event.pressed and event.keycode == KEY_M:

get_tree().reload_current_scene()

#rotate_y(90.88)



-------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

Explicacion;

Script para godot3d 4.2 cuando presiono tecla "M"  se reinicia el juego; esta puesto en un MeshInstance3D; y es bicnieto; me vengo a referir , intento aclarar el nodo raiz padre del juego es un

World de el sale un Area3d de esta sale un CollisionShape3D de este asi mismo sale el MeshInstance3D contenedor del script que funciona perfectamente, ejecuto el juego y cuando presiono tecla "m" se empieza el juego de nuevo.




miércoles, 10 de enero de 2024

Script para Godot3d cuando algo entra en el area3d borra nodos hijos y nodos hermanos; mas complejo;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass







func _on_area_entered(area):

var parent = get_parent()

var Turbo = parent.get_node("Turbo")

var Turbo2 = parent.get_node("Turbo2")

var CollisionShape3DCARROCERIA = parent.get_node("CollisionShape3DCARROCERIA")

var ModeloElicopteroobj = parent.get_node("ModeloElicopteroobj")

Turbo.queue_free()

Turbo2.queue_free()

CollisionShape3DCARROCERIA.queue_free()

ModeloElicopteroobj.queue_free()

get_node("CollisionShape3D mas amarillo aun").queue_free()

get_node("MeshInstance3D SUPERAMARILLO").queue_free()

pass # Replace with function body.


Script para Godot3d cuando algo entra en el area3d borra nodos hijos y nodos hermanos;

 extends Area3D


# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass


func _on_area_entered(area):

var parent = get_parent()

var Turbo = parent.get_node("Turbo")

Turbo.queue_free()

get_node("CollisionShape3D mas amarillo aun").queue_free()

get_node("MeshInstance3D SUPERAMARILLO").queue_free()

pass # Replace with function body.




EXPLICACION:

El script se pone en el Area 3d donde estan los elementos que borraremos cuando algo entre en dicha area3d contenedora tambien del script, esta parte son hermanos:

var parent = get_parent()

var Turbo = parent.get_node("Turbo")

Turbo.queue_free()

 

esta otra parte son hijos:

get_node("CollisionShape3D mas amarillo aun").queue_free()

get_node("MeshInstance3D SUPERAMARILLO").queue_free()

pass # Replace with function body.



martes, 9 de enero de 2024

Otro html

TOCA CON EL DEDO Y DISPARAS BOLAS AZULES




<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Animación de círculos</title>
    <style>
      canvas {
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="200" height="200"></canvas>
    <script>
      const canvas = document.getElementById('myCanvas');
      const ctx = canvas.getContext('2d');

      // Dibuja un cuadrado en el canvas
      ctx.fillStyle = 'red';
      ctx.fillRect(50, 50, 100, 100);

      // Agrega un evento touchstart al canvas
      canvas.addEventListener('touchstart', function(event) {
        // Dibuja círculos en el canvas y los mueve hacia el eje -y-
        let y = 50;
        let radius = 10;
        let intervalId = setInterval(function() {
          ctx.clearRect(0, 0, canvas.width, canvas.height);
          ctx.fillStyle = 'red';
          ctx.fillRect(50, 50, 100, 100);
          ctx.fillStyle = 'blue';
          ctx.beginPath();
          ctx.arc(100, y, radius, 0, 2 * Math.PI);
          ctx.fill();
          y += 10;
          if (y > canvas.height + radius) {
            clearInterval(intervalId);
          }
        }, 50);
      });
    </script>
  </body>
</html>

Animación de círculos

lunes, 8 de enero de 2024

Dispara cudrados toca la pantalla

Toca el cuadrado rojo con el dedo, luego el azul .....y asi sucesibamente........

Click on the red square to see the effect


<!DOCTYPE html>
<html>
<head>
<style>
.container {
  width: 200px;
  height: 200px;
  position: relative;
  background-color: #f1f1f1;
}

.square {
  width: 50px;
  height: 50px;
  position: absolute;
  background-color: red;
  cursor: pointer;
}

.square:hover ~ .moving-square {
  animation: move-up 1s ease-in-out forwards;
}

@keyframes move-up {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-100px);
  }
}

.moving-square {
  width: 50px;
  height: 50px;
  position: absolute;
  background-color: blue;
  top: 200px;
}
</style>
</head>
<body>

<h2>Click on the red square to see the effect</h2>

<div class="container">
  <div class="square"></div>
  <div class="moving-square"></div>
</div>

</body>
</html>

Circulos volando

<!DOCTYPE html>
<html>
<head>
  <style>
    #square {
      width: 200px;
      height: 200px;
      background-color: lightblue;
      position: relative;
    }

    .circle {
      width: 20px;
      height: 20px;
      background-color: white;
      border-radius: 50%;
      position: absolute;
      animation: move 2s ease-in-out infinite;
    }

    @keyframes move {
      0% {
        transform: rotate(0deg) translate(0, 0);
      }
      100% {
        transform: rotate(360deg) translate(100px, 0);
      }
    }
  </style>
</head>
<body>
  <div id="square" ontouchstart="createCircle(event)">
  </div>

  <script>
    function createCircle(event) {
      var x = event.touches[0].clientX;
      var y = event.touches[0].clientY;
      var circle = document.createElement("div");
      circle.classList.add("circle");
      circle.style.left = x + "px";
      circle.style.top = y + "px";
      document.getElementById("square").appendChild(circle);
    }
  </script>
</body>
</html>




TOCA CON EL DEDO REP
PETIDAMENTE LA PANTALLA DEL TELEFONO....EN EL CUADRADO AZUL

domingo, 7 de enero de 2024

Sript para Godot3d 4.2 produce una animacion de giro de todo el contenido del Area3d y borra dos hijos de dicho nodo Area3d;

 extends Area3D


# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

get_node("SOLDADOTIESO2VIVO").queue_free()

get_node("CollisionShape3D10 borroestoprueba").queue_free()

$AnimationPlayer.play("PELICULA180")

------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
Explicacion:
 Tenemos un Area3d con una animacion de giro, cuando algo toca ese area3d, produce la animacion y a su vez borra dos nodos hijos de esta area3d el SOLDADOTIESO2VIVO y CollisionShape3D10 borroestoprueba

El func _on_area_entered(area): para que funcione se a de poner desde SEÑAL que esta en Nodos al lado del Inspector parte derecha de Godot..........


(hay que tener cuidado al duplicar archivos , por ejemplo si se pone este script en un Area3d que falta o tiene otro nombre por ejemplo el nodo hijo get_node("CollisionShape3D10 borroestoprueba").........pongamos no esta, o tiene otro nombre el juego funciona, pero al colisionar y estar incorrecto se cuelga el juego..................porque no encuentra esos archivos....



Script para godot3d 4.2, Un Area3d tiene una animacion que se activa, y un nodo hijo de otro tipo que se borra;

 extends Area3D


# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

get_node("SOLDADOTIESO2VIVO").queue_free()

$AnimationPlayer.play("PELICULA180")

----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------


explicacion: cuando algo entra en Area3D el area entera gira porque hice una animacion que grave , y a la vez un nodo hijo llamado get_node("SOLDADOTIESO2VIVO") es borrado por la linea .queue_free()