Legacy GM draw_background_part_wrapped?

S

Shadowblitz16

Guest
does anybody know how to make a function that draw a part of a background but draws wrapped around tiles if the width or size surpasses the actual image bounds?

for example say I had a full background image that I was representing as tiles
lets say its a 4x4 background and each tile is 2x2

background_image
A 0, 1, 2, 3 < X Axis
0 [0, 1, 2, 3],
1 [4, 5, 6, 7],
2 [8, 9, A, B],
3 [C,D, E, F]
^
Y Axis

background_draw_part(background_image, 2, 0, 2, 2, x, y)
A 0, 1, 2, 3 < X Axis
0 [2, 3],
1 [6, 7]
2
3
^
Y Axis

but if I do something like this
I want to be able to return the image like its a 1d array or list of tiles
like so..
background_draw_part(background_image, 3, 0, 2, 2, x, y)
A 0, 1, 2, 3 < X Axis
0 [3, 4],
1 [7, 8],
2
3
^
Y Axis

it would be nice to have this for the y axis too so something like
background_draw_part(background_image, 3, 3, 2, 2, x, y)
A 0, 1, 2, 3 < X Axis
0 [F, 4],
1 [1, 0],
2
3
^
Y Axis
 

TheouAegis

Member
Take the X & Y of the tile. Add the width of the tile to the X and the height of the tile to the Y. Compare those two values to the width of the room and the height of the room. For each of those values that is greater than 0, repeat the Draka man with that positive difference as the x or y coordinate.
 
S

Shadowblitz16

Guest
@TheouAegis
Draka man?

I'm trying to get it to wrap around the tilesheet

here is some example code but it doesn't work
Code:
///draw_background_part_wrapped(back, left, top, width, height, x, y)

var _back   = argument[0]
var _left   = argument[1]
var _top    = argument[2]
var _width  = argument[3]
var _height = argument[4]
var _x      = argument[5]
var _y      = argument[6]
var _hwrap = background_get_width( _back);
var _vwrap = background_get_height(_back);
var _wid = _width div (_hwrap div _width)
var _hei = _height div (_vwrap div _height)

for (var _h=0; _h<_hei; _h++) {
for (var _w=0; _w<_wid ; _w++) {
  //var _tilex = ((_width  mod _hlimit) * _width)  + _left
  //var _tiley = ((_height div _vlimit) * _height) + _top
 
  var _drawx = ((_h mod (_hwrap div _width )) * _width ) + _x
  var _drawy = ((_w div (_vwrap div _height)) * _height) + _y

  draw_background_part_ext(_back, _left, _top, _width, _height, _drawx, _drawy, 1, 1, $FFFFFF, 1)
}}
 
Last edited by a moderator:
Top