Skip to content

Instantly share code, notes, and snippets.

View pr00thmatic's full-sized avatar

Ruth García pr00thmatic

View GitHub Profile
uno.animations.add('stand_front', [15], fps, true);
uno.animations.add('stand_right', [5], fps, true);
uno.animations.add('stand_back', [10], fps, true);
uno.animations.add('front', [1,2,3,4], fps, true);
uno.animations.add('right', [6,7,8,9], fps, true);
uno.animations.add('back', [11,12,13,14], fps, true);
uno.animations.play('stand_front'); //empezará viendo hacia el frente
//creando al personaje
uno = game.add.sprite(game.world.width/2-16,
game.world.height/2-16,
'uno');
// Física
game.physics.arcade.enable(uno);
uno.collideWorldBounds = true;
cursores = game.input.keyboard.createCursorKeys();
if(cursores.left.isDown) {
lastDirection = 'left';
uno.scale.x = -1;
uno.body.velocity.x = -1*velocity;
uno.animations.play('right'); //uno.scale.x=-1 hace que right se voltee a left
} else if (cursores.right.isDown) {
lastDirection = 'right';
uno.scale.x = 1;
cursores = game.input.keyboard.createCursorKeys();
if(cursores.left.isDown) {
...
} else if (cursores.right.isDown) {
...
} else if (cursores.up.isDown) {
uno.body.velocity.y = -1;
uno.animations.play('front')
lastDirection = 'front';
function move_x(alguien, dir) {
alguien.scale.x = dir;
alguien.body.velocity.x = dir*velocity;
lastDirection = 'right'; //right will be flipped if left
}
function move_y(alguien, dir) {
uno.body.velocity.y = dir*velocity;
if (dir > 0)
function update() {
game.physics.arcade.collide(uno, walls);
cursores = game.input.keyboard.createCursorKeys();
uno.animations.play('stand_' + lastDirection); // importante!! "uno" se queda quieto.
if(cursores.left.isDown) {
lastDirection = 'left';
uno.scale.x = -1;
uno.body.velocity.x = -1*velocity;
var Cat = { // this is actually an object: a "prototype" object
color: 'none',
size: 'none',
meow: function() {
console.log("meow");
}
};
var Garfield = Object.create(Cat); // this is a prototype object too
@pr00thmatic
pr00thmatic / .emacs part
Created January 27, 2015 22:10
.emacs for global keystrokes C-c C-c comment-region and C-c C-u uncomment-region
(defun comment-marked-region ()
"comments the marked region, just like M-x comment-region"
(interactive)
(comment-region (mark) (point)))
(defun uncomment-marked-region ()
"uncoments the marked region, just like M-x uncomment-region"
(interactive)
(uncomment-region-default (mark) (point)))
@pr00thmatic
pr00thmatic / js-test.js
Last active August 29, 2015 14:15
js test
var a = (function () {
this.x = 100;
var a = 1;
var showX = function () {
console.log(this.x);
};
var setX = function () {
this.x = -100;