mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Move tests, create makefile action to run tests on examples (#433)
* Move tests, create makefile action to run tests on examples * Correct import file for html files * Build environment for tests * Fix the CI * rearrange CI * fix find cmd and make sure we don't delete the folder implicitly * more rearranging * fix folder permissions and custom sed for subfolders * add toga wheels files * re-add missing file * mirror latest changes in alpha ci * fix find cmd * try different fix for find * remove redundant build Co-authored-by: mariana <marianameireles@protonmail.com> Co-authored-by: pww217 <pwilson@anaconda.com> Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
This commit is contained in:
81
examples/mario/js/block.js
Normal file
81
examples/mario/js/block.js
Normal file
@@ -0,0 +1,81 @@
|
||||
(function() {
|
||||
if (typeof Mario === 'undefined')
|
||||
window.Mario = {};
|
||||
|
||||
//TODO: clean up the logic for sprite switching.
|
||||
//TODO: There's a weird bug with the collision logic. Look into it.
|
||||
|
||||
var Block = Mario.Block = function(options) {
|
||||
this.item = options.item;
|
||||
this.usedSprite = options.usedSprite;
|
||||
this.bounceSprite = options.bounceSprite;
|
||||
this.breakable = options.breakable;
|
||||
|
||||
Mario.Entity.call(this, {
|
||||
pos: options.pos,
|
||||
sprite: options.sprite,
|
||||
hitbox: [0,0,16,16]
|
||||
});
|
||||
|
||||
this.standing = true;
|
||||
}
|
||||
|
||||
Mario.Util.inherits(Block, Mario.Floor);
|
||||
|
||||
Block.prototype.break = function() {
|
||||
sounds.breakBlock.play();
|
||||
(new Mario.Rubble()).spawn(this.pos);
|
||||
var x = this.pos[0] / 16, y = this.pos[1] / 16;
|
||||
delete level.blocks[y][x];
|
||||
}
|
||||
|
||||
Block.prototype.bonk = function(power) {
|
||||
sounds.bump.play();
|
||||
if (power > 0 && this.breakable) {
|
||||
this.break();
|
||||
} else if (this.standing){
|
||||
this.standing = false;
|
||||
if (this.item) {
|
||||
this.item.spawn();
|
||||
this.item = null;
|
||||
}
|
||||
this.opos = [];
|
||||
this.opos[0] = this.pos[0];
|
||||
this.opos[1] = this.pos[1];
|
||||
if (this.bounceSprite) {
|
||||
this.osprite = this.sprite;
|
||||
this.sprite = this.bounceSprite;
|
||||
} else {
|
||||
this.sprite = this.usedSprite;
|
||||
}
|
||||
|
||||
this.vel[1] = -2;
|
||||
}
|
||||
}
|
||||
|
||||
Block.prototype.update = function(dt, gameTime) {
|
||||
if (!this.standing) {
|
||||
if (this.pos[1] < this.opos[1] - 8) {
|
||||
this.vel[1] = 2;
|
||||
}
|
||||
if (this.pos[1] > this.opos[1]) {
|
||||
this.vel[1] = 0;
|
||||
this.pos = this.opos;
|
||||
if (this.osprite) {
|
||||
this.sprite = this.osprite;
|
||||
}
|
||||
this.standing = true;
|
||||
}
|
||||
} else {
|
||||
if (this.sprite === this.usedSprite) {
|
||||
var x = this.pos[0] / 16, y = this.pos[1] / 16;
|
||||
level.statics[y][x] = new Mario.Floor(this.pos, this.usedSprite);
|
||||
delete level.blocks[y][x];
|
||||
}
|
||||
}
|
||||
|
||||
this.pos[1] += this.vel[1];
|
||||
this.sprite.update(dt, gameTime);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user