Cant figure out collision error

2 posters

Go down

Cant figure out collision error Empty Cant figure out collision error

Post by tribalzero 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

https://i.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

Back to top Go down

Cant figure out collision error Empty Re: Cant figure out collision error

Post by rc 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.
rc
rc
Admin

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

http://rainingchain.com

Back to top Go down

Cant figure out collision error Empty Re: Cant figure out collision error

Post by tribalzero 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

Back to top Go down

Cant figure out collision error Empty Re: Cant figure out collision error

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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