Hi, my game have a array of 512 by 512 which makes a surface that's 512*32 px in both dimensions. (max possible size for a surface) When my view is on the edge of the surface, I want to have it loop around, as if you where on a sphere.
So, to iterate. I have a 16.384 x 16.384 surface made from 32 x 32 sprites and a 512 x 512 value array. I draw a part of this surface that equals the size of the window. When I get to the edge of the surface, I would like the surface to wrap around itself, as if it were a sphere.
The only solution I can think of is instead of drawing a part of the surface that equals the size of the window, I could draw it in chunks of 32s, and determine individually which chunk to draw where and when.
That would mean I'd have to do something like this each draw event:
Is this the best approach?
So, to iterate. I have a 16.384 x 16.384 surface made from 32 x 32 sprites and a 512 x 512 value array. I draw a part of this surface that equals the size of the window. When I get to the edge of the surface, I would like the surface to wrap around itself, as if it were a sphere.
The only solution I can think of is instead of drawing a part of the surface that equals the size of the window, I could draw it in chunks of 32s, and determine individually which chunk to draw where and when.
That would mean I'd have to do something like this each draw event:
Code:
for(var i=0; i<room_width/32; i++){
for(var p=0; p<room_height/32; p++){
draw_surface_part(surface,left,top,32,32,i*32,p*32)
}}
Last edited: