But if i dont make it 320x320 is a problem to choose different textures because im making a script to do the calculations to set the texture coords. without setting evry texture start pos and end pos in an array (doing it manually if there's 100 textures will take a lot of time) if for example i make it 256x256 evry single texture cant be 25.6x25.6 pixels, can be 25 or 26 and that will be so hard to make automated :S
- A subtexture doesn't have to be 0.1 of the texture width.
- You don't have to fill the entire space.
- The texture doesn't have to be square. If it'll be more space-efficient, use rectangular textures, as long as both sides are powers of 2.
With that in mind, let's create a system to AUTOMATICALLY generate coordinates:
var tex_w, tex_h, off_u, off_v;
tex_w = texture_get_width(in_tex) / subtexture_count_horizontal;
tex_h = texture_get_height(in_tex) / subtexture_count_vertical;
off_u = 0.5 * tex_w / (subtexture_width + 1);
off_v = 0.5 * tex_h / (subtexture_height + 1);
out_u = off_u * (1 - 2 * in_u) + (subtex_x + in_u) * tex_w;
out_v = off_v * (1 - 2 * in_v) + (subtex_y + in_v) * tex_h;
subtexture_count_horizontal is the number of subtextures along the width of the main texture. subtexture_count_vertical is the number of subtextures along the height of the main texture.
subtexture_width and subtexture_height are the width and height (in pixels) of every subtexture, not including the repeated "buffer" pixels.
subtex_x and subtex_y are integers indicating which subtexture to choose.
in_u and in_v permit you to choose any u,v pair on the subtexture. In your case, 0,0 1,0 1,1 and 0,1 will be used.
Note: The script I gave above (untested) should work even for non-power-of-2 textures (because of texture_get_width/texture_get_height). Despite this, GET OUT OF THE HABIT; at some point, it'll ruin the game on some card.
As for the repeating, you could potentially write a program to automate it for you (using surface_getpixel), but it may be faster and easier to do it manually.
Edited by Gamer3D, 17 May 2012 - 08:32 PM.