Hex to GM
I doubt anyone has a use for this but, have this. I used it for my SMB engine and DKC thing for the physics.
/// hex_real(hex string, divide by)
// Converts hexidecimal values to real values Game Maker can read. (If unsure, set divide by to 256)
var hex_c;
hex_c = 0;
var hex_result;
hex_result = 0;
for(i=1; i<=string_length(argument0); i+=1)
{
// Get/Copy hex index:
hex_c = ord(string_char_at(string_upper(argument0), i));
// Byte shift:
hex_result = hex_result << 4;
// Add to result:
if(hex_c >= ord("0") && hex_c <= ord("9"))
{
hex_result = hex_result + (hex_c-ord("0"));
}
else if(hex_c >= ord("A") && hex_c <= ord("F"))
{
hex_result = hex_result + (hex_c - ord("A") + 10);
}
}
// Return.
if(!argument1)
{
argument1 = 1;
}
return hex_result/argument1;
Turns hex stuff ("000E4") to something game maker can read. I used it in the SMB engine. Things were even easier because someone made a guide for SMB. https://i276.photobucket.com/albums/kk21/jdaster64/smb_playerphysics.png