i'm making a video game, and i'm having, i think, a concept problem. The game will be a platformer which will use tile maps, so to start i will create a mask matrix indicating the tiles to be loaded, and etc..., so my problem is, how to handle the scrolling? should i create a giant mask matrix indicating in each position of the whole level what is supposed to be loaded, and according to the position of the player, change the section to be drawed?? Is this a correct approach to this situation??
Using tiles is a great idea first off (for a 2d game), as it allows you to effectively manage memory, loading, etc. and an effective part of using tiles for this reason IS to use a matrix, or map. In combination with a tileset for a given level or area, and with your base reflections (x and y plane) the matrix/map and tileset combo works a treat.
Three things need to be taken into account for this mechanism to be used effectively in a game however:
If allowing 4/8 way scrolling, be careful that any actors/enemies/etc in the game are unloaded or carefully frozen/unfrozen in some way at the same time as mapped tiles when they are no longer in your viewport, particularly if you have AI/Pathfinding utilities. (The failure to compensate for this is visible in most, if not all 8 bit platform games where 8 way scrolling was allowed as enemies off screen fell through floors, etc.)
Separate the concern's of scrolling/viewing from your concept of tiling. Tiling is a mechanism to deal with art assets prior to and after use by the game engine. I.e. This is a storage and load/unload pattern, rather than a rendering mechanism. Load the tiles you need to display and +100% in the x/y planes (for example) into memory, and create a texture centered around your character. Then scroll around the texture rather than by tile. Reload tiles after x/y has moved by more than (x) from start point. This has some extra benefits at the cost of the extra rendering to texture. I.e. you can apply transformations, blends, etc. to the texture off screen, and it prevents artefact-ing between tiles, which can occur at times.
Depending on your target platform and coding abilities you may not wish to use actual tilesets and load individually from a larger palette. I would recommend against this as good practice, but that's me personally. I have seen 2d engines which did lazy loading of tiles as required, but I think loading a tileset with an area or level is a better way to use this pattern.
(Scrolling is handled elsewhere on this site amongst other places.)