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
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