Hi there!
As we have been learning in this course, whenever you see a bunch of repeated code, you can either make a function or a ‘for’ loop to go through them a bit more efficiently.
I thought to follow up on the previous person asking this, by trying something out (and failing sadly). The thing I would like the function to do is to draw the input plane, just like how this is done in the course. However, I was already stuck thinking on what the type of return should be of the function, as I am already drawing a texture inside the function itself. Furthermore, I think I might be messing up some syntax, since vscode is not highlighting the function nor the new variable made within the function. Therefore, could I perhaps ask for a hint as to how to accomplish a more efficient way to load the different planes?
void updatePlane (plane, float deltaTime, int scrollSpeed)
{
float planePosX{};
planePosX -= scrollSpeed * dT;
if (scrollSpeed <= -plane.width * 2)
{
scrollSpeed = 0.0;
}
Vector2 plane1Pos{planePosX, 0.0};
DrawTextureEx(plane, plane1Pos, 0.0, 2.0, WHITE);
Vector2 plane2Pos{planePosX + background.width * 2, 0.0};
DrawTextureEx(plane, plane2Pos, 0.0, 2.0, WHITE);
}
Sincerely,
Tom