Not the best approach

I enjoyed this course for the most part, but this approach of constantly fumbling around with the code for the Scarfy game is a bit annoying. When teaching someone new, a more complex subject, you need to give small incremental challenges with a well define and concrete goal so there is a sense of achievement and closure. Some of the concepts like structs, functions should have been taught in a new game, instead of crammed in the Scarfy lessons and ending up changing the same code several times.

3 Likes

i agree, it feels like at some points that I’m in the completely wrong section.

well i like this way because this way we make a good programmed game he is also explain better how to program better and why is it better

I see where you’re coming from, but in a professional sense this can actually simulate what it’s like to work on a project.

You will be shifting around code regularly as issues come up or the overall design gets changed. Game Development is always in flux until it’s not.

1 Like

i think the problem with rewriting code by creating abstraction is that it doesnt feel right because it ends up creating more work than saving in the context of some of the examples (e.g. going from unformalized object to struct to array of our structs). but the general principle is fine. for me personally i wish every lesson would have significantly more work tied to it, its very small scale already. making it even more piecemeal would significantly reduce the value of the class (imho).

Are there necroposting rules here?

I’d like to remind you my fellow colleagues that the “best approach” to coding is something subjective. IMO the lessons feel quite realistic because in real GameDev scenarios, refactoring code is very common, you’ll almost never code “the best approach” out of the blue and never touch the code again.

It’s said that code is as alive as languages, always evolving and with many forms of conveying the same meaning.

Also this format of teaching tackles two birds or more with one stone:
1 - Teaches students multiple approaches to coding, from simple code to more robust code.
2 - Gets students used to code refactoring and code reviewing, a must have skill for programmers.

EDIT: Forgot to include some variable declarations in the example, despite using them later

I honestly appreciated the way that it kept condensing down to more and more flexible code, eliminating hardcoding in a constantly-progressing manner.

Though I do feel like that sorta fell by the wayside when it came to the last steps of the Scarfy tutorial, drawing each background layer discretely when we’d just been taught how to iterate through arrays.

Decided to go above and beyond, personally, and challenge myself. Google’d how to load up a math library (#include <cmath>, in case you were curious) and then invoke exponentiation. As a result, what took a bunch of separate lines and variables in the tutorial only required this for me:

    Texture2D bgDepthFromBack[3];
        bgDepthFromBack[0] = LoadTexture("textures/far-buildings.png");
        bgDepthFromBack[1] = LoadTexture("textures/back-buildings.png");
        bgDepthFromBack[2] = LoadTexture("textures/foreground.png");

    const int bgLayers{3};
    float bgLayersX[bgLayers]{};

[ other code ]

        // Background/midground/foreground scroll and reset check logic
        for (int i = 0; i < bgLayers; i++)
        {
            bgLayersX[i] -= (20*(pow(3,i)))*dT; // move through loop according to (3^i)*20*dT in pixels per second
            if (bgLayersX[i] <= 0-(bgDepthFromBack[i].width*2)) // check for end-of-loop position
            {
                bgLayersX[i] = 0.0; // reset bg/mg/fg to beginning of loop 
            }
        }

        for (int i = 0; i < bgLayers; i++)
        {
            Vector2 bg1Pos{bgLayersX[i],0.0}; // Left-hand image pos
            Vector2 bg2Pos{bgLayersX[i]+(bgDepthFromBack[i].width*2),0.0}; // Right-hand image pos
            DrawTextureEx(bgDepthFromBack[i],bg1Pos,0.0,2.0,WHITE); // Left-hand image draw
            DrawTextureEx(bgDepthFromBack[i],bg2Pos,0.0,2.0,WHITE); // Right-hand image draw
        }

[ more other code ]

    for (int i = 0; i < 3; i++)
    {
        UnloadTexture(bgDepthFromBack[i]);
    }

Just seemed silly not to use the tools we’d been given, even if it took a little extra hunting to find that last detail I needed to make the parallax work.

I could’ve probably done them in one for loop, but it kept misbehaving when I tried so I just split it out into two.

Excellent work and well done giving yourself a challenge like that.

Privacy & Terms