mirror of
https://github.com/pyscript/pyscript.git
synced 2022-05-01 19:47:48 +03:00
move examples from public to their own examples folder
This commit is contained in:
45
pyscriptjs/examples/mario/js/bcoin.js
Normal file
45
pyscriptjs/examples/mario/js/bcoin.js
Normal file
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
if (typeof Mario === 'undefined')
|
||||
window.Mario = {};
|
||||
|
||||
var Bcoin = Mario.Bcoin = function(pos) {
|
||||
Mario.Entity.call(this, {
|
||||
pos: pos,
|
||||
sprite: level.bcoinSprite(),
|
||||
hitbox: [0,0,16,16]
|
||||
});
|
||||
}
|
||||
|
||||
Mario.Util.inherits(Bcoin, Mario.Entity);
|
||||
|
||||
//I'm not sure whether it makes sense to use an array for vel and acc here
|
||||
//in order to keep with convention, or to just use a single value, since
|
||||
//it's literally impossible for these to move left or right.
|
||||
Bcoin.prototype.spawn = function() {
|
||||
sounds.coin.currentTime = 0.05;
|
||||
sounds.coin.play();
|
||||
this.idx = level.items.length;
|
||||
level.items.push(this);
|
||||
this.active = true;
|
||||
this.vel = -12;
|
||||
this.targetpos = this.pos[1] - 32;
|
||||
}
|
||||
|
||||
Bcoin.prototype.update = function(dt) {
|
||||
if (!this.active) return;
|
||||
|
||||
if (this.vel > 0 && this.pos[1] >= this.targetpos) {
|
||||
player.coins += 1;
|
||||
//spawn a score thingy.
|
||||
delete level.items[this.idx];
|
||||
}
|
||||
|
||||
this.acc = 0.75;
|
||||
this.vel += this.acc;
|
||||
this.pos[1] += this.vel;
|
||||
this.sprite.update(dt);
|
||||
}
|
||||
|
||||
Bcoin.prototype.checkCollisions = function() {;}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user