1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

tilemap_set_mask not working?

Discussion in 'Programming' started by KMVegas, Jun 27, 2019.

  1. KMVegas

    KMVegas Member

    Joined:
    Aug 11, 2017
    Posts:
    6
    Hey, all. I'm trying to learn bitmasking with tile layers. It's taken me awhile to grasp it, but at this point, it seems pretty straightforward. I followed an old post from 2016 to start setting things up, but I'm having an issue. When I go back and check the tile index after setting a bit, the index comes back NOT ignoring the bit I set. Let's say index is 1, then I set a bit, and suddenly the index is 33. The post from 2016 mentioned a bug but Mike Daily said it was fixed internally and that was over 3 years ago. Is it still broken?

    Single object in a room with tiles, from a 4x4 tile set, so possibility of indices 0 - 15.

    Thanks for any help!

    Create Event
    Code:
    // get the tilemap
    tmap=layer_tilemap_get_id("TL_Test");
    
    // set the mask
    var _mask = tile_rotate | tile_mirror | tile_flip | 15;
    
    //tilemap_set_mask(tmap, _mask);
    tilemap_set_global_mask(_mask);

    Step Event
    Code:
    /// @desc Set bit / get index
    
    var _tdata,_tdatanew,_tindex;
    
    #region left click to see tile index
    
    if(mouse_check_button_pressed(mb_left)){
    
        // get data from clicked tile
        _tdata=tilemap_get_at_pixel(tmap,mouse_x,mouse_y);
       
        // exit on void tile
        if(_tdata==0){
            show_message("Empty space!");
            exit;
        }
       
        // get index in case a property has been changed
        _tindex=tile_get_index(_tdata);
       
        // Show the index
        show_message("Tile index: "+string(_tindex));
       
    }#endregion
    
    #region right click to set bit 6
    
    if(mouse_check_button_pressed(mb_right)){
    
        // get data from clicked tile
        _tdata=tilemap_get_at_pixel(tmap,mouse_x,mouse_y);
       
        // exit on void tile
        if(_tdata==0){
            show_message("Empty space!");
            exit;
        }
       
        // set the sixth bit
        _tdatanew = _tdata | 32;
       
        // show tile data
        show_message("Tile data blob was: "+string(_tdata)
            +", and is now: "+string(_tdatanew));
       
        // place the modified tile
        tilemap_set_at_pixel(tmap,_tdatanew,mouse_x,mouse_y);
       
    }#endregion
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,046
    Your code seems okay, so I'd suggest filing a bug report with YYG and please supply a link to download an example that shows the issue.
     

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