Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

I want +=, -=, *=, /= and div

6 replies · 3,124 views · Started 17 September 2006

See topic title. The first four would be helpful keystroke-savers, and the latter is useful when trying to work out how many 16s are in a sprite's y value.

Div is integer division. Think of it as the counterpart to mod.

Alternatively, you could add floor() (and ceiling()).

I don't think adding those to the language itself is necessary, but I will add the following functions to std.zh, the ZScript standard header that will be included in b14:


//some utility routines
int Floor(int x) {
if(x < 0)
return (x-.9999)<<0;
return x<<0;
}

int Ceiling(int x) {
if(x < 0)
return x<<0;
return (x+.9999)<<0;
}

std.zh will also include constants like SFX_STAIRS for sound effects and item classes.

Actually div() would be a really useful function. Div would essentially be the equivalent of:


result = x / y;
if(result > 0)
{
result = Floor(result);
}
else
{
result = Ceiling(result);
}