# Frogger Offset Help!

**URL:** <https://discourse.processing.org/t/frogger-offset-help/18842>\
**Category:** Coding Questions\
**Created:** [March 20, 2020, 3:23pm UTC](https://discourse.processing.org/t/frogger-offset-help/18842 "2020-03-20T15:23:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Burgs](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Burgs](https://discourse.processing.org/u/Burgs)\
**Post date:** [March 20, 2020, 3:23pm UTC](https://discourse.processing.org/t/frogger-offset-help/18842/1 "2020-03-20T15:23:19Z")

</div>

hello, I’m doing an exercise to practice offset. I’m currently working on a game of frogger to apply this but dont know where to start. how should i apply apply the offset to make the object move in a direction and then the other objects move relative to it.

this is what i have to draw the objects

```auto
void drawHazard(int type, float x, float y, float size)
{
  if (type == 0)
  {
    fill(255,0,0);
    ellipse(x,y,size,size);
    
  }
  if (type == 1)
  {
    fill(0);
    rect(x,y,size,size);
  }
  if (type == 2)
  {
    fill(255);
    ellipse(x,y,size,size);
  }
}

void drawHazards()
{
  
  for (int j=0;j<width;j++)
  {
    for (float i=0;i<level+2;i++)
    {
      float y0 = (height-bandHeight*1.5)-i*(bandHeight*3);
      if (y0 < bandHeight)
        {
          y0 = height-bandHeight*1.5;
        }
      float y1 = (height-bandHeight*2.8)-i*(bandHeight*3);
      if (y1 < bandHeight)
        {
          y1 = height-bandHeight*2.8;
        }
      float y2 = (height-bandHeight*3.5)-i*(bandHeight*3);
      if (y2 < bandHeight)
        {
          y2 = height-bandHeight*3.5;
        }
         x0 = j*(bandHeight*3);
         x1 = j*(bandHeight*4)-((bandHeight-50)/2);
         x2 = j*(bandHeight*5);
      drawHazard(0,x0,y0,bandHeight/1.5);
      drawHazard(1,x1,y1,bandHeight/1.5);
      drawHazard(2,x2,y2,bandHeight/1.5);
   
    }
   
  }  
  
}

```

Thanks in advance for the help

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 20, 2020, 4:13pm UTC](https://discourse.processing.org/t/frogger-offset-help/18842/2 "2020-03-20T16:13:56Z")

</div>

please post a runable code and not only a small bit.  
Please explain what you want to achieve.
