Hi, im working on a 2D shoot'em up map editor and the ground is made up of tiles moving downwards.
When the bottom row tiles go past the screen their position is set to top of screen (2.0f) + size of a tile.
The tilemap has to be atleast one row (here it is two rows) bigger than the screen (upwards) else there would be a gap when the top row moves down and the bottom row hasn't yet passed the screen.
However there's a small gap only when the first row is relocated above the screen between the "first" row and the "last" row (in the array so to speak).
All consecutive rows seems to lap over eachother fine, unless (and here's problem 2) the scroll speed is to fast, then the gaps erupts between more rows.
Objective: I want the tilemap to scroll smoothley and not have small gap's between rows independent of the scroll speed.
GameInit()
V2f tp = v2f((32.0f / 512.0f), (32.0f / 512.0f)); V2i tm_dim = v2i(32, 34); game->tilemap = Push(game, SPRITE, tm_dim.x * tm_dim.y); game->tilemap_dim = tm_dim; for(int y = 0; y < tm_dim.y; y++) { for(int x = 0; x < tm_dim.x; x++) { game->tilemap[x + (tm_dim.x * y)].pos = v2f(0.0f + (tp.x * x), 0.0f + (tp.y * y)); game->tilemap[x + (tm_dim.x * y)].size = v2f(tp.x, tp.y + 0.001f); game->tilemap[x + (tm_dim.x * y)].col = v4f(1.0f, 1.0f, 1.0f, 1.0f); game->tilemap[x + (tm_dim.x * y)].tcoord_p = v2f(5.0f * tp.x, 1.0f - (1.0f * tp.y)); game->tilemap[x + (tm_dim.x * y)].tcoord_sz = v2f(1.0f * tp.x, 1.0f * tp.y); } }
GameUpdate()
V2i tm_dim = game->tilemap_dim; for(int y = 0; y < tm_dim.y; y++) { for(int x = 0; x < tm_dim.x; x++) { float scroll_speed = 0.003f; int i = x + (tm_dim.x * y); float py = game->tilemap[i].pos.y; float szy = game->tilemap[i].size.y; game->tilemap[i].pos.y -= scroll_speed; if(py + szy <= 0.0f) { game->tilemap[i].pos.y = 2.0f + szy; } if(MousePressed(platform, GLFW_MOUSE_BUTTON_LEFT)) { if(CursorInside_SPRITE(platform, game->tilemap[i])) game->tilemap[i].tcoord_p = game->currently_chosen_sprite->tcoord_p; } } }