Skip to content

Instantly share code, notes, and snippets.

View FEDE0D's full-sized avatar

Federico FEDE0D

View GitHub Profile
8469223 01
@FEDE0D
FEDE0D / Godot IAP.gd
Created February 1, 2016 16:00
In app purchases in Godot Engine: Examples
# Intent: interface to the GodotPayments module (remember to add the java path in the project settings android>modules )
"Intent.gd"
extends Node
# Interface for the GodotPayments module
# To use extend this script and save the result on the Global singleton 'Data'
const STATIC_RESPONSE_NONE = 0
const STATIC_RESPONSE_ALL = 1
@FEDE0D
FEDE0D / timer.gd
Created January 17, 2016 19:25
Timer in Godot
const TIMER = 2.0 # 2 seconds
var timer = 0.0
# use _process or _fixed_process for physics stuff
func _process(delta):
timer += delta
if timer > TIMER:
do_something()
timer = 0.0
12-28 21:33:42.419: D/GODOT(27641): ** GODOT ACTIVITY CREATED HERE ***
12-28 21:33:43.319: D/GODOT(27641): command_line is null? no
12-28 21:33:43.359: I/godot(27641): **INIT EVENT! - 0xe45880
12-28 21:33:43.359: I/godot(27641): ***************** HELLO FROM JNI!!!!!!!!
12-28 21:33:43.359: I/godot(27641): *******CLASS FOUND!!!
12-28 21:33:43.359: I/godot(27641): STEP2, 0x1d200202
12-28 21:33:43.359: I/godot(27641): STEP3 1092602616
12-28 21:33:43.359: I/godot(27641): STEP4, 0x87a0002d
12-28 21:33:43.359: I/godot(27641): STEP4.5, 0x1d200206
12-28 21:33:43.359: I/godot(27641): STEP7
# You can do this
func _fixed_process(delta):
var pos_a = get_node("body_a").get_global_pos()
var pos_b = get_node("body_b").get_global_pos()
# lets say you want to move the body_a to body_b
var new_pos = pos_a.linear_interpolate(pos_b, delta)
get_node("body_a").set_global_pos(new_pos)
@FEDE0D
FEDE0D / vector_example.gd
Created December 17, 2015 05:34
Vector normalized in Godot
1º Add the direction vectors. Ie: you want to add the right key + up key velocity.
var vel = vel_left + vel_right
2º Normalize the velocity, this will make the length of the vector exactly 1 unit.
vel = vel.normalized()
3º Now the movement would be only 1 unit per frame, so multiply for the real speed
vel = vel * speed
translate(vel * delta)
@FEDE0D
FEDE0D / ej4.sql
Last active December 4, 2015 21:11
BBDD1 2015 - Parcial - Ejercicio SQL
1.
# creamos el usuario
CREATE USER 'u_registrado'@'localhost' IDENTIFIED BY '1234';
# le damos permiso para que lea la tabla noticia
GRANT SELECT ON `bd`.`NOTICIA` TO 'u_registrado'@'localhost';
# le damos permiso al usuario para agregar comentarios (no modificar)
GRANT INSERT ON `bd`.`COMENTARIO` TO 'u_registrado'@'localhost';
# le damos permiso para modificar los datos de su cuenta
GRANT UPDATE ON `bd`.`USUARIO_REGISTRADO` TO 'u_registrado'@'localhost';
@FEDE0D
FEDE0D / ej1
Last active November 26, 2015 15:33
Concurrente Parcial: Ejercicio 1 del parcial 2da Fecha 2013
Parcial concurrente 2da fecha 2013
1) Resolver con MONITORES el siguiente problema.
En un Crucero por el Mediterráneo hay 200 personas que deben subir al barco por medio de 10 lanchas con 20 lugares
cada una. Cada persona sube a la lancha que le corresponde. Cuando en una lancha han subido sus 20 personas durante 5 minutos navega hasta el barco. Recién cuando han llegado las 10 lanchas al barco se les permite a las 200 personas subir al barco.
NOTA: suponga que cada persona llama a la función int NúmeroDeLancha() que le devuelve un valor entre 0 y 9 indicando la lancha a la que debe subir. Maximizar la
concurrencia.
process Persona[p: 1..200] {
int nroLancha = NumeroLancha();
#inside the singleton
func _ready():
Globals.set("singleton", self)
#in any other node
func example_func():
Globals.get("singleton") # get the singleton node
#===========Escena1.scn================
func _ready():
Globals.set("idioma", -1) # no es necesario hacer esto
func btn_1_click():
Globals.set("idioma", 1)
func btn_2_click():
Globals.set("idioma", 2)