New sql files and improved Logger.js

This commit is contained in:
Thomas FORGIONE 2015-05-19 11:50:12 +02:00
parent ad0b759e5e
commit df04a1bbfb
3 changed files with 65 additions and 2 deletions

View File

@ -1,10 +1,37 @@
DROP TABLE IF EXISTS users CASCADE; DROP TABLE IF EXISTS users CASCADE;
DROP TABLE IF EXISTS arrowclicked CASCADE; DROP TABLE IF EXISTS arrowclicked CASCADE;
DROP TABLE IF EXISTS coinclicked CASCADE; DROP TABLE IF EXISTS coinclicked CASCADE;
DROP TABLE IF EXISTS keyboardevent CASCADE;
CREATE TABLE users ( DROP TYPE IF EXISTS VECTOR3 CASCADE;
DROP TYPE IF EXISTS CAMERA CASCADE;
DROP TYPE IF EXISTS DIRECTION CASCADE;
CREATE TYPE VECTOR3 AS(
x FLOAT,
y FLOAT,
z FLOAT
);
CREATE TYPE CAMERA AS(
position VECTOR3,
target VECTOR3
);
CREATE TYPE DIRECTION AS ENUM(
'n',
'ne',
'e',
'se',
's',
'sw',
'w',
'nw'
);
CREATE TABLE users(
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name char(50) name CHAR(50)
); );
CREATE TABLE arrowclicked( CREATE TABLE arrowclicked(
@ -20,3 +47,11 @@ CREATE TABLE coinclicked(
time TIMESTAMP DEFAULT NOW(), time TIMESTAMP DEFAULT NOW(),
coin_id INTEGER coin_id INTEGER
); );
CREATE TABLE keyboardevent(
id SERIAL PRIMARY KEY,
user_id SERIAL REFERENCES users (id),
time TIMESTAMP DEFAULT NOW(),
direction DIRECTION,
camera CAMERA
);

8
sql/test.pgsql Normal file
View File

@ -0,0 +1,8 @@
INSERT INTO users(name) VALUES('Thomas');
INSERT INTO keyboardevent(user_id, direction, camera) VALUES(
1,
NULL,
ROW(ROW(0,0,0), ROW(0,0,0))
);
SELECT ((camera).position).x FROM keyboardevent;

View File

@ -24,3 +24,23 @@ BD.Event.CoinClicked.prototype.send = function() {
BD.Private.sendData(url, data); BD.Private.sendData(url, data);
} }
BD.Event.KeyboardEvent = function() {};
BD.Event.KeyboardEvent.prototype.send = function() {
var url = "/keyboard-event";
var data = {
camera: {
// Compact camera
position: {
x: this.camera.position.x,
y: this.camera.position.y,
z: this.camera.position.z
},
target: {
x: this.camera.target.x,
y: this.camera.target.y,
z: this.camera.target.z
}
}
};
BD.Private.sendData(url, data);
}