Cant figure out collision error

View previous topic View next topic Go down

Cant figure out collision error

Post by tribalzero on Thu Jun 16, 2016 10:59 am

Hey, I just finished episode 11 and before I get any further I'm trying to figure out why my collision is acting weird.

The bullets are getting stuck on the player and not disappearing.

Here's my code

http://pastebin.com/xQhHJRA5

And what the error looks like

http://i35.servimg.com/u/f35/19/49/58/20/collis10.png


I tried comparing with the final solution, but I didn't see what the issue was Question confused

tribalzero

Posts : 3
Reputation : 0
Join date : 2016-06-13

View user profile

Back to top Go down

Re: Cant figure out collision error

Post by rc on Thu Jun 16, 2016 3:47 pm

Two problems:

The major one is:

Code:

socket.on('remove',function(data){
 
    for(var i = 0 ; i < data.player.length; i++){
      delete Player.list[data.player[i]];
    }
    for(var i = 0 ; i < data.bullet.length; i++){
      delete Player.list[data.bullet[i]]; // <===== this should be Bullet.list
    }
  });

There is also

Code:

socket.on('update',function(data){
 
    for(var i = 0; i < data.player.length; i++){
      var pack = data.player[i];
      var p = Player.list[pack.id];
      if(p){
        if(pack.x !== undefined)
          p.x = pack.x;
        if(pack.y !== undefined)
          p.y = pack.y;
        if(pack.hp !== undefined)
          p.hp = pack.hp;
        if(pack.y !== undefined) //<==== should be pack.score
          p.score = pack.score;
      }
    }

I used https://diffnow.com/ to compare code.
avatar
rc
Admin

Posts : 164
Reputation : 9
Join date : 2016-04-04
Age : 23
Location : Montreal

View user profile http://rainingchain.com

Back to top Go down

Re: Cant figure out collision error

Post by tribalzero on Thu Jun 16, 2016 8:07 pm

awesome! good to know about that website, thanks

tribalzero

Posts : 3
Reputation : 0
Join date : 2016-06-13

View user profile

Back to top Go down

Re: Cant figure out collision error

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum