O'Reilly Forums: Html5 & Javascript Collisions In The Game Platform (Y-Axis) - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Html5 & Javascript Collisions In The Game Platform (Y-Axis)

#1 User is offline   redok 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 16-January 13

Posted 17 January 2013 - 07:42 AM

Hi
The problem affects only the X axis. I have not created a conflict for the X axis
I can not deal with the collision when the next platform is higher than the previous one.
My all code: http://wklej.org/id/928010/
That's how it works: http://galeriagiza.p...anPytanie1.html

The most important part of the code:

    // JUMP FIGURE 
    if(jump>0)
    {
      y_figure-=4;
      jump-=4;
    }
    else 
    {  
      for(p=0;p<numberBlocksLand;p++)
      {          
        if(x_figure>=(oX[p]+speed) && x_figure<=(oX[p]+widthBlock+speed))
        {
          if(y_figure<(oY[p]-heightFigure))
          {
            y_figure+=2;
            if(y_figure==(oY[p]-heightFigure)) stopJump=0;
          }
        }
      }
    }


I tried to create an auxiliary variable widthFigureHelp:

var widthFigureHelp=0;
(...)
    if(jump>0)
    {
      y_figure-=4;
      jump-=4;
    }
    else 
    {  
      for(p=0;p<numberBlocksLand;p++)
      {   
        if(oY[p]>oY[p+1]) widthFigureHelp=widthFigure; // width=50;
        else widthFigureHelp=0;
       
        if(x_figure>=(oX[p]+speed) && x_figure<=(oX[p]+widthBlock+speed-widthFigureHelp))
        {
          if(y_figure<(oY[p]-heightFigure))
          {
            y_figure+=2;
            if(y_figure==(oY[p]-heightFigure)) stopJump=0;
          }
        }
      }
    }


That's how it works: http://galeriagiza.p...anPytanie2.html
Then almost works - but at the time of the jump figure stops until the statue will move to its width...
I very ask for help.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users