1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Asset - Extension iMprOVE_WRAP

Discussion in 'Marketplace' started by csanyk, Jul 1, 2016.

  1. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    iMprOVE_WRAP is a paid extension that improves on the built-in GML function move_wrap.

    The GML function move_wrap() is a useful GML function, but it has a few limitations:
    • It’s limited to working with the border of the room.
    • Being a move_ function, it is based on GML’s built-in movement variables, so if you don’t use speed (or hspeed and vspeed) to move your object, it doesn’t work at all.
    • Objects that are going off the edge of the room do not have their sprite start to draw at the other edge until the instance moves past border by the margin, at which point it disappears immediately from the edge of the room it’s leaving, making its appearance at the other end of the room very sudden.
    iMprOVE_WRAP provides a collection of new functions that can be used in lieu of move_wrap(). These new functions improve on the original move_wrap in a number of ways:
    • You have complete control to define a rectangular region within the room that the instance should wrap around. This allows you to define an arbitrary range for the object to wrap around that is not limited to the borders of the room. You can use the boundaries of the room just like move_wrap(), but you can also use the borders of a view, instead, or of an arbitrary region within your room (or even outside of your room, although you wouldn’t be able to see it.)
    • Wrapping is based on position, not motion. If the instance’s x and y variables are outside of the defined range that you set up, the function will “wrap” the position around the defined range, using mod math to reposition it. This allows it to work with whatever variables you want to use for movement, whether they be the built-in GML speed variables, or variables that you define.
    • Independent horizontal and vertical margins. Move_wrap() only has one parameter for margin; iMprOVE_WRAP has separate parameters for horizontal and vertical margin, to allow greater flexibility. Very helpful if your object’s sprite isn’t square in proportions.
    • Drawing on both sides of the wrap boundary. With move_wrap(), the instance does not appear at the opposite side of the room until its position changes. This can lead to a jarring effect if a large or slow-moving sprite slowly reaches the wrap boundary, and then suddenly appears on the opposite side, rather than gradually emerging. iMprOVE_WRAP enhances the effect by allowing you to optionally drawing four “phantom” selves, at the points +/- range_height and range_width away from the true location of the instance, you can create the illusion of the instance’s sprite wrapping around, appearing on both edges of the defined range.
    • Collisions can (optionally) be checked at the positions of the “phantom” sprites. In case it is necessary in your game; recommended if you’re using the phantom sprites, since otherwise they will not collide with things.
    Includes a well-documented demo project to help you understand how to use the functions.

    Full documentation at: https://goo.gl/7DQaUZ

    https://marketplace.yoyogames.com/assets/2216/improve_wrap

    Please review it if you give it a try!
     
    Last edited: Jan 25, 2017
    Lycanphoenix likes this.
  2. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    Version 2.0.0 released 10/15/2016 adds two new functions:

    • draw_sprite_wrap()
    • draw_sprite_ext_wrap()
    And makes improvements to the existing functions as follows:

    • boundary wrap drawing occurs at the corners of the wrap range (8 phantom drawings rather than 4) when do_wrap_h and do_wrap_v are both true.
    • the collision functions iw_collision_wrap() and iw_collision_wrap_map() incorporate do_wrap_h and do_wrap_v parameters, and only perform collision checks where they are needed. The functions still return all potential collision variables so that there is never an undefined value, even where collisions are not checked. (Unchecked collision locations return noone.)
     
  3. m_brudi

    m_brudi Guest

    Hi there i bought this project and its looking really good, but i need a help
    can you tell me if its possible to get rid of the border so it will be like a normal map and when you use view its just like a infinite map?
    you know what i mean?
    thanks
     
  4. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    Hey, thanks for purchasing, and thanks for the question!

    To answer, yes of course you can turn off the border drawing. If you're referring to the demo object, look in the Draw event, and comment out or delete the appropriate line of code (Draw line 12). It should be clearly labeled with a comment. And be sure to read the support doc that I wrote for it.

    Let me know if you have any feedback on how it might be improved once you've had some time to use it.
     
  5. Hey, I just picked up iMprOVE_WRAP. Seems pretty critical for my project (and I'm frankly surprised this functionality isn't part of stock Game Maker Studio). If I encounter anything odd, or have any suggestions, I'll be sure to get in touch!
     
  6. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    Thanks for buying! Please do let me know what you think about it.
     
  7. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    v2.1.0 is released!

    Improvements:
    • iMprOVE_WRAP demo resources have been placed in folders to keep them tidy when importing the asset into a project.

    • oIMprOVE_WRAP_demo sprite has been updated to allow for more precise positioning. Sprite is semi-transparent, with a yellow pixel at the origin
      [​IMG]

    • oIMprOVE_WRAP_demo object now draws guide lines indicating the height and width of the wrap range. This is useful in confirming that clone drawings and wrapping is occuring where it should.

    • iMprOVE_WRAP demo dashboard text has been updated to be a bit more clear.

    New functions:
    • iw_distance_to_object(): returns the shortest distance to the target object from the wrapping object, taking into account all directions available.

    • iw_distance_to_point(): returns the shortest distance to the target point from the wrapping object, taking into account all directions available.

    New demo room for the iw_distance_to_object() and iw_distance_to_point() functions.
     
  8. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    v2.2.0 is released!

    New functions:
    • iw_point_direction(): returns the direction of the shortest distance from point A to point B, taking into account the wrap zone.
    • iw_point_distance(): returns the shortest distance from point A to point B, taking into account the wrap zone.
     
  9. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    v2.3.0 is released!

    New function:

    • iw_collision_clear(): clears the value of the 9 collision “other_” variables set by the iw_collision_wrap() function, resetting them to noone, or initializing them if unset:
      • other_center
      • other_left
      • other_right
      • other_up
      • other_down
      • other_up_left
      • other_up_right
      • other_down_left
      • other_down_right
    Note there is no equivalent function needed by iw_collision_wrap_map because it always returns a new ds_map.​
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice