05.10.2017, 19:19
So basically, I'm trying to create a random generation of "tiles", but I can't calculate out the X and Y position from 0.0, 0.0 by using negative numbers but I can succeed with doing it with positive numbers.
As seen here; tile 4 is supposed to be on the corner of tile 1, west-south, not north-east.
Here's how their deployment is;
And the function is as following;
Any ideas of what I'm doing wrong?
https://*********/j-81qEOxk6E
As seen here; tile 4 is supposed to be on the corner of tile 1, west-south, not north-east.
Here's how their deployment is;
PHP код:
public OnGameModeInit() {
CreateTile(TILE_TYPE_GRASS, 0, 0);
CreateTile(TILE_TYPE_GRASS, 1, 0);
CreateTile(TILE_TYPE_GRASS, 0, 1);
CreateTile(TILE_TYPE_GRASS, -1, -1);
return 1;
}
PHP код:
stock CreateTile(type, x, y) {
new id = CreateObject(TILE_MODEL_ID, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)), 30.0, 0, 0, 0);
new string[144];
format(string, sizeof string, "Tile: %i\nPosition: %i - %i", id, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)));
Create3DTextLabel(string, 0x1CC4FCFF, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)), 30.0, 1000.0, 0, 0);
switch(type) {
case TILE_TYPE_GRASS: {
SetObjectMaterial(id, 0, 9495, "vict_sfw", "Grass", 0);
for(new Float:gYY = -62.5; gYY < 62.5; gYY += (float(random(50)+1)*0.1)+1)
for(new Float:gX = -62.5, Float:gY = float(random(50)+1)*0.1; gX < 62.5; gX += (float(random(50)+1)*0.1)+1, gY = float(random(50)+1)*0.1)
CreateDynamicObject(TILE_OBJECT_GRASS, ((x >= 0)?(x*125):(x*(-125)))+gX, (((y >= 0)?(y*125):(y*(-125)))+gY)-gYY, 30, 0, 0, 0);
}
}
staticTiles[id][staticTile_ID] = id;
staticTiles[id][staticTile_Type] = type;
}
https://*********/j-81qEOxk6E