Commit d80db96a by Иван Кубота

Merge branch 'master' of gitlab.quokka.pub:Zibx/projectSane

parents 62f3f3ef e90f7b86
node_modules/* node_modules/*
package-lock.json package-lock.json
\ No newline at end of file .idea/*
\ No newline at end of file
This diff is collapsed. Click to expand it.
...@@ -7,7 +7,8 @@ Game({ ...@@ -7,7 +7,8 @@ Game({
Player, Player,
Key, Key,
NPC, NPC,
Tree Tree,
Trash
}, },
loaded: function() { loaded: function() {
......
...@@ -324,7 +324,7 @@ GameObject.prototype = { ...@@ -324,7 +324,7 @@ GameObject.prototype = {
visible: true, visible: true,
opacity: 1, opacity: 1,
say: function( sentence, duration) { say: function( sentence, duration) {
duration = duration || sentence.length/8; duration = duration || sentence.length/16;
var actions = []; var actions = [];
sentence = sentence.split('\n'); sentence = sentence.split('\n');
...@@ -575,6 +575,8 @@ GameObject.prototype = { ...@@ -575,6 +575,8 @@ GameObject.prototype = {
} }
return true; return true;
})[0] })[0]
}else{
return its[0];
} }
}, },
loadAnimation: function(animationName, {manual, duration, path, size, frames, offset, padding}) { loadAnimation: function(animationName, {manual, duration, path, size, frames, offset, padding}) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<script src="object/NPC.js"></script> <script src="object/NPC.js"></script>
<script src="object/Zone.js"></script> <script src="object/Zone.js"></script>
<script src="object/Tree.js"></script> <script src="object/Tree.js"></script>
<script src="object/Trash.js"></script>
<script src="js/main.js"></script> <script src="js/main.js"></script>
</body> </body>
......
class Key extends GameObject { class Key extends GameObject {
step(dt, tfs){ step(dt, tfs){
if(this.collide(Player)){ if(this.collide(Player)){
var hole = this.getItem( Zone, { Name: 'Hole' } ); var hole = this.getItem( Zone, { Name: this.AttachedZone } );
this.startTime = tfs; this.startTime = tfs;
hole.animate( 'hideWall', function( progress ){ hole.animate( 'hideWall', function( progress ){
if(progress === 0){ if(progress === 0){
......
...@@ -9,20 +9,39 @@ class NPC extends GameObject { ...@@ -9,20 +9,39 @@ class NPC extends GameObject {
} }
}else{ }else{
this.wobble = Math.sin( tfs * 4 ) * 1;
this.wobble2 = Math.sin( tfs * 3+5 ) * 3;
this.position[ 1 ] = this.originalY + 1 + this.wobble | 0;
this.position[ 0 ] = this.originalX + ( this.wobble2 | 0 );
}
/*this.wobble = Math.sin( tfs * 4 ) * 1;
this.wobble2 = Math.sin( tfs * 3+5 ) * 3;
this.position[ 1 ] = this.originalY + 1 + this.wobble | 0;
this.position[ 0 ] = this.originalX + ( this.wobble2 | 0 );*/
}
if(this.saying){
this.setAnimation('puzing');
}else{
this.setAnimation('blinking');
}
this.updateAnimation(dt);
} }
init() { init() {
this.loadAnimation('blinking', {
path: 'sprites/Jaba1.png',
size: [64, 64],
frames: 4,
duration: 2
});
this.loadAnimation('puzing', {
path: 'sprites/Jaba2.png',
size: [64, 64],
frames: 4,
duration: 2
});
if(this.Dialog) if(this.Dialog)
this.sentance = 0; this.sentance = 0;
/*
this.wobble = 0; this.wobble = 0;
this.originalX = this.position[0]; this.originalX = this.position[0];
this.originalY = this.position[1]; this.originalY = this.position[1];*/
this.actions = { this.actions = {
openPassage: function() { openPassage: function() {
var passage = this.getItem(Zone, {Name: 'RocksPassage'}); var passage = this.getItem(Zone, {Name: 'RocksPassage'});
......
// Класс игрока // Класс игрока
class Player extends GameObject { class Player extends GameObject {
init(){ init(){
this.tinCans = 0;
this.extendSprite(); this.extendSprite();
this.position[1]++; this.position[1]++;
this.collisionOffset = [5,8,5,9]; this.collisionOffset = [5,8,5,9];
......
// Зона вырезает кусок слоя уровня и даёт возможность показывать и скрывать выбранные участки геометрии уровня
class Trash extends GameObject {
init() {
}
step(dt, tfs){
if(this.collide(Player) && this.visible){
this.getItem( Player ).tinCans += 1;
console.log('Tin cans = ', this.getItem( Player ).tinCans )
this.visible = false;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment