1. Drew Strickland
  2. websocket-game

Commits

dr...@drew-laptop  committed a89cba6

multiplayer firing added, gun position / firing art is wrong still

  • Participants
  • Parent commits 31106e9
  • Branches default

Comments (0)

Files changed (8)

File public/css/game.css

View file
     font-weight: 700;
     cursor: pointer;
 }
+.ui-nametag{
+    color: #fff;
+    text-align: center;
+    font-size: 10px;
+    line-height: 14px;
+    border: solid 1px #ccc;
+}
 .playerCharacter{
     top: -1px;
     border-bottom: dashed 5px #f90;

File public/gamepkg/scripts/hp.js

View file
         var me = this;
         this.hpd = Crafty.e('2D, DOM, Color')
         .attr({
-            x: me.x,
-            y: me.h + me.y + 10,
-            w: me.w,
+            x: me.x - 33,
+            y: me.h + me.y + 16,
+            w: 66,
             h: 2
         })
         .color('#0f0');
         this.attach(hpd);
         this.bind('EnterFrame', function(){
             hpd.h = 2;
-            hpd.y = me.h + me.y + 5;
+            hpd.y = me.h + me.y + 10;
             var pct = this.hp/this.baseHP;
-            hpd.w = this.w*(pct);
+            hpd.w = 66*(pct);
             if(pct == 1){
                 hpd.css({'display': 'none'});
             }

File public/gamepkg/scripts/playerCharacter.js

View file
         }).color('blue');
         this.origin('center');        
         this.nametag = Crafty.e('ui-nametag').attr({
-            x: this.x - 34,
-            y: this.y + 50
+            x: this.x - 33,
+            y: this.y + 32
         }).text(this.name);
         this.attach(this.nametag);
         this.nametag.attr({h:-18, w:68});

File public/gamepkg/scripts/sceneHowToPlay.js

View file
     maintitle.y = 10;
     var inst = 'Move your ship with the <b>W, A, S, and D</b> keys.  Your ship will automatically look at the mouse.';
     inst += '<br/><br/>';
-    inst += 'You can press <b>TAB</b> at any time to see the current scoreboard';
-    inst += '<br/><br/>';
     inst += 'You are the <b style="color: ' + uData.color + ';">' + uData.color + '</b> player.';
     Crafty.e('ui-text-block').text(inst).attr({x: 15, y: 40});
     Crafty.e('ui-button').text('Change Ship Name').attr({x: 15, y: 210, w: 200, h: 40}).handler(function(){

File public/gamepkg/scripts/sceneMain.js

View file
 Crafty.scene('main', function(){
     var player = Crafty.e('playerCharacter, Player').color( uData.color );
     cCenter(player);
-    player.addWeapon(Crafty.e('LaserCannonMKI'));
+    player.addWeapon(Crafty.e('LaserCannonMKIV'));
     comm.send( JSON.stringify({act: 'getPlayers'}) );
 });

File public/gamepkg/scripts/ui.js

View file
 Crafty.c('ui-nametag',{
     init: function(){
         this.addComponent('2D, DOM, Text');
-        this.attr({h: 0, w: 0, x: 0, y: 0})
+        this.attr({h: 0, w: 64, x: 0, y: 0})
         .text('NameTag')
-        .css({
-            'color' : '#fff',
-            'text-align' : 'center',
-            'font-size' : '10px',
-            'line-height' : '14px'
-        })
     }
 });

File public/gamepkg/scripts/weapons.js

View file
             fires: 'Bullet',
             loaded: true,
             x:0, y:0, rotation: 0,
-            w: 1, h: 1,
+            w: 16, h: 16,
             parent: false,
             offset:{x:7, y:3},
             damageModifier: 1,
         this.addComponent('LaserCannonMKI');
         this.attr({reloadRate: 60, damageModifier: 9, speedModifier: 1.75});
     }
-});
-Crafty.c('PulseLaserMKI', {
-    init: function(){
-        this.addComponent('Gun');
-        this.attr({offset:{x:10,y:15}});
-        this.attr({fires: 'PulseLaser', reloadRate: 1500, duration: 3000, w: 12});
-        this.fire = function(){
-            if(this.loaded){
-                var me = this;
-                this.loaded = false;
-                for(var i=0; i<me.barrels; i++){
-                    var p = Crafty.e(me.fires).attr({
-                        x: me._x,
-                        y: me._y,
-                        rotation: me.parent.rotation,
-                        pOrigin: me.parent
-                    });
-                    p.origin('bottom center');
-                    p.y -= p.h
-                    p.damage *= me.damageModifier;
-                    p.speed *= me.speedModifier;
-                    me.attach(p)
-                    p.fire();
-                    p.bind('destroy', function(){
-                        setTimeout(function(){me.reload()},me.reloadRate);
-                    })
-                    me.bind('EnterFrame', function(){
-                        p.x = me.x;
-                        p.y = me.y-p.h;
-                        p.rotation = me.rotation;
-                    });
-                }
-                setTimeout(function(){ p.trigger('destroy'); p.destroy(); }, this.duration )
-            }
-        }
-    }
-});
-Crafty.c('PulseLaserMKII',{
-    init: function(){
-        this.addComponent('PulseLaserMKI');
-        this.attr({reloadRate: 1000, duration: 5000});
-    }
-});
-Crafty.c('PulseLaserMKIII',{
-    init: function(){
-        this.addComponent('PulseLaserMKI');
-        this.attr({reloadRate: 1000, duration: 5000, damageModifier: 2});
-    }
 });

File public/js/commObj.js

View file
                 case 'addUser':
                     var newb = Crafty.e('playerCharacter').color(json.color);
                     cCenter(newb);
-                    newb.addWeapon(Crafty.e('LaserCannonMKI'))
+                    newb.addWeapon(Crafty.e('LaserCannonMKIV'))
                     newb.playerID = json.playerID;
                     break;
                 case 'destroyPlayer':