Just to point it out, since I didn’t make much of a thing of it yesterday, this is the thing I was hoping you would work out, and if it hadn’t been for the fact you didn’t have the masks working properly first, that would have been the point at which your grid rendered more or less properly.
To me, the fact you managed to work it out on your own justifies me witholding that information, because it got you to think about how sprites are rendered from the top left and that’s an important thing to remember.
In what way?
Are you sure it doesn’t just look squashed together because you only have buildings and no roads making a path through them/separating them?
They should be the size of a blank tile without any building on it, which is what that image from the SO answer (and my modified version) demonstrate(s).
It will be at some point.
C++ has classes too, and its classes are far more powerful and far cheaper than Java’s and Python’s classes.
Classes also make code a lot easier to group and organise, and allow you to rely less on global variables.
Java likes ‘fields’ and ‘methods’.
C++ refers to them as ‘member variables’ and ‘member functions’.
I’m not sure about Python.
Apparently some places refer to ‘fields’/‘member variables’ as ‘attributes’, but that’s likely to cause confusion because a lot of languages use the term ‘attribute’ to refer to what Java calls ‘annoations’ - a kind of metadata that can be applied to an entity to provide information either to the compiler or for use with reflection.
That’s only the beginning. Next comes inheritance and overriding.
Hopefully they’ll stretch to generics, because that’s where things really get interesting.
(Although Java’s generics are a weak, bolted-on mess compared to those of languages like C# and C++.)
You’ve got a lot of interesting and mind-blowing stuff ahead of you, though I doubt your course will cover it all.
No, that’ll probably happen when you learn about inheritance and class design patterns instead.
:P (I’m only half joking.)
Using classes more or less everywhere is fine as long as you don’t completely banish free (i.e. non-member) functions from your repetoire. (I’m looking at you, Java.)
All I’ve done is get some of the commented-out code out of the way and adjust the spacing slightly. That’s barely touching the surface as far as organisation goes.
By the way, as long as you’ve commited to GitHub you don’t have to worry about deleting rather than commenting out old code because the whole point of Git is that it keeps the entire history of your code and you can retrieve any old code that has since been deleted just by going back through the commit history.
For example here is your code as it was on the 11th of February.