碰撞
yunzl 发表于 2019-02-04 11:18:42 291

if wsp!=0{
    var _list = ds_list_create();
    var _num = instance_place_list(x+wsp,y,obj_block,_list, false);
    if _num > 0
    {   
        var _mask=-1
        if sprite_index _mask=sprite_index
        if mask_index _mask=mask_index
        if wsp<0{
            var _left=x+sprite_get_bbox_left(_mask)-sprite_get_xoffset(_mask)
            var _lock=false
            var _tmp=0
            for (var i = 0; i < _num; ++i;)
            {
                if _left>_list[|i].bbox_right{
                    if !_lock{
                        _tmp=_list[|i].bbox_right
                        _lock=true
                    }else{
                        if _tmp<_list[|i].bbox_right
                        _tmp=_list[|i].bbox_right
                    }
                }
            }
            if _lock wsp=-(_left-_tmp)+1
        }else{
            var _right=x+sprite_get_bbox_right(_mask)-sprite_get_xoffset(_mask)
            var _lock=false
            var _tmp=0
            for (var i = 0; i < _num; ++i;)
            {
                if _right<_list[|i].bbox_left
                if !_lock{
                    _tmp=_list[|i].bbox_left
                    _lock=true
                }else
                if _tmp>_list[|i].bbox_left
                _tmp=_list[|i].bbox_left
            }
            if _lock wsp=_tmp-_right-1
        }
    }
    ds_list_destroy(_list);
}
x+=wsp
if hsp!=0{
    var _list = ds_list_create();
    var _num = instance_place_list(x,y+hsp,obj_block,_list, false);
    if _num > 0
    {
        var _mask=-1
        if sprite_index _mask=sprite_index
        if mask_index _mask=mask_index
        if hsp<0{
            var _top=y+sprite_get_bbox_top(_mask)-sprite_get_yoffset(_mask)
            var _lock=false
            var _tmp=0
            for (var i = 0; i < _num; ++i;)
            {
                if _top>_list[|i].bbox_bottom
                if !_lock{
                    _tmp=_list[|i].bbox_bottom
                    _lock=true
                }else
                if _tmp<_list[|i].bbox_bottom
                _tmp=_list[|i].bbox_bottom

            }
            if _lock hsp=-(_top-_tmp)+1
        }else{
            var _bottom=y+sprite_get_bbox_bottom(_mask)-sprite_get_yoffset(_mask)
            var _lock=false
            var _tmp=0
            for (var i = 0; i < _num; ++i;)
            {
                if _bottom<_list[|i].bbox_top
                if !_lock{
                    _tmp=_list[|i].bbox_top
                    _lock=true
                }else
                if _tmp>_list[|i].bbox_top
                _tmp=_list[|i].bbox_top
            }
            if _lock hsp=_tmp-_bottom-1
        }
    }
    ds_list_destroy(_list);
}
y+=hsp
最后于 2月前 被yunzl编辑 ,原因:
最新回复 (2)
  • 电波 发表于 2019-02-05 11:22:51
    0 2
    贴一段代码走人,好水哇
  • 电波 发表于 2019-02-05 11:23:15
    0 3
    不对,这里正是水库...