DeScruff
Member
Hey,
So after years of using Game Maker, I only recently found out that GM does have binary functions!
This could significantly clean up and shorten my code. Specially my "Can you walk on this tile" code.
As a quick example instead of:
I can have:
Much shorter, and cleaner!
But Im wondering, is it possible use Bitwise operations for things like ds_grid_value_exists?
It be much cleaner then running a small loop to check each individual grid square in an area.
If not you guys have any ideas?
So after years of using Game Maker, I only recently found out that GM does have binary functions!
This could significantly clean up and shorten my code. Specially my "Can you walk on this tile" code.
As a quick example instead of:
Code:
var tmpTile
tmpTile = ds_grid_get(grid_Tile, x/16+1, y/16)
if tmpTile == 1 || tmpTile == 3 || tmpTile == 5 || tmpTile == 7 || tmpTile == 9 || tmpTile == 11 || tmpTile == 13 || tmpTile == 15 { // All the tiles the player cant walk on
CanWalk = false;
} else { CanWalk = true; }
Code:
var tmpTile
tmpTile = ds_grid_get(grid_Tile, x/16+1, y/16)
if tmpTile & 1{ // The binary numbers for 1,3,5,7,9,11,13,15 all contain xxx1
CanWalk = false;
} else { CanWalk = true; }
But Im wondering, is it possible use Bitwise operations for things like ds_grid_value_exists?
It be much cleaner then running a small loop to check each individual grid square in an area.
If not you guys have any ideas?