Use grid cell coords for placing entities.

This commit is contained in:
Steve 2015-11-02 10:49:10 +00:00
parent a7c1906950
commit b748d23267
14 changed files with 91 additions and 110 deletions

View File

@ -25,8 +25,8 @@
"types" : "Firefly;Nymph",
"number" : 3,
"side" : "SIDE_ALLIES",
"x" : 640,
"y" : 1000,
"x" : 25,
"y" : 26,
"scatter" : 64
}
],
@ -34,8 +34,8 @@
{
"type" : "ET_WAYPOINT",
"number" : 5,
"x" : 640,
"y" : 480,
"x" : 25,
"y" : 25,
"scatter" : 7500
}
]

View File

@ -48,8 +48,8 @@
"types" : "Firefly;Nymph",
"number" : 4,
"side" : "SIDE_ALLIES",
"x" : 640,
"y" : 1000,
"x" : 25,
"y" : 26,
"scatter" : 64
},
{
@ -57,8 +57,8 @@
"types" : "Jackal",
"number" : 3,
"side" : "SIDE_PANDORAN",
"x" : 640,
"y" : 1000,
"x" : 25,
"y" : 26,
"scatter" : 64,
"active" : 0
}
@ -67,8 +67,8 @@
{
"type" : "ET_WAYPOINT",
"number" : 5,
"x" : 640,
"y" : 480,
"x" : 25,
"y" : 25,
"scatter" : 7500
}
]

View File

@ -27,8 +27,8 @@
"name" : "ALLIES",
"types" : "Firefly;Nymph;Leopard;Hyena",
"side" : "SIDE_ALLIES",
"x" : 640,
"y" : 0,
"x" : 25,
"y" : 24,
"number" : 100,
"scatter" : 5000
},
@ -36,8 +36,8 @@
"name" : "Pandoran",
"types" : "Jackal;Sphinx",
"side" : "SIDE_PANDORAN",
"x" : 7000,
"y" : 0,
"x" : 35,
"y" : 24,
"number" : 80,
"scatter" : 5000
}

View File

@ -32,16 +32,16 @@
"types" : "ATAF",
"number" : 4,
"side" : "SIDE_ALLIES",
"x" : 0,
"y" : 0
"x" : 26,
"y" : 25
},
{
"name" : "Pandoran",
"types" : "Jackal;Sphinx;Nymph",
"number" : 20,
"side" : "SIDE_PANDORAN",
"x" : -5000,
"y" : 0,
"x" : 20,
"y" : 25,
"scatter" : 2000
},
{
@ -49,8 +49,8 @@
"types" : "Jackal;Sphinx;Nymph",
"number" : 20,
"side" : "SIDE_PANDORAN",
"x" : -5000,
"y" : 5000,
"x" : 20,
"y" : 20,
"scatter" : 2000
},
{
@ -58,8 +58,8 @@
"types" : "Jackal;Sphinx;Nymph",
"number" : 20,
"side" : "SIDE_PANDORAN",
"x" : -5000,
"y" : -5000,
"x" : 20,
"y" : 30,
"scatter" : 2000
},
{
@ -67,8 +67,8 @@
"types" : "Nymph",
"number" : 20,
"side" : "SIDE_PANDORAN",
"x" : 5000,
"y" : 8000,
"x" : 30,
"y" : 40,
"scatter" : 2000
},
{
@ -76,8 +76,8 @@
"types" : "Jackal;Sphinx",
"number" : 20,
"side" : "SIDE_PANDORAN",
"x" : 7000,
"y" : -4000,
"x" : 30,
"y" : 20,
"scatter" : 2000
}
]

View File

@ -27,8 +27,8 @@
"name" : "ALLIES",
"types" : "Firefly;Nymph",
"side" : "SIDE_ALLIES",
"x" : 640,
"y" : 0,
"x" : 25,
"y" : 24,
"number" : 75,
"scatter" : 5000
},
@ -36,8 +36,8 @@
"name" : "Pandoran",
"types" : "Jackal",
"side" : "SIDE_PANDORAN",
"x" : 7000,
"y" : 0,
"x" : 35,
"y" : 30,
"number" : 50,
"scatter" : 5000
}

View File

@ -23,8 +23,8 @@
"name" : "Dart",
"type" : "StaticDart",
"side" : "SIDE_PIRATE",
"x" : 800,
"y" : 200
"x" : 25.5,
"y" : 24.5
}
]
}

View File

@ -23,8 +23,8 @@
"name" : "Dart",
"type" : "UnarmedDart",
"side" : "SIDE_PIRATE",
"x" : 640,
"y" : 0
"x" : 25,
"y" : 24
}
]
}

View File

@ -23,8 +23,8 @@
"name" : "Dart",
"type" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 640,
"y" : -1000
"x" : 25,
"y" : 24
}
]
}

View File

@ -23,36 +23,25 @@
"name" : "TAF",
"type" : "TAF",
"side" : "SIDE_ALLIES",
"x" : 440,
"y" : 480
"x" : 24.9,
"y" : 25.5
},
{
"name" : "TAF",
"type" : "TAF",
"side" : "SIDE_ALLIES",
"x" : 840,
"y" : 480
},
"x" : 25.1,
"y" : 25.5
}
],
"fighterGroups" : [
{
"name" : "Dart",
"type" : "SimpleDart",
"types" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 2640,
"y" : -1500
},
{
"name" : "Dart",
"type" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 2640,
"y" : -1500
},
{
"name" : "Dart",
"type" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 2640,
"y" : -1500
"number" : 3,
"x" : 26,
"y" : 20
}
]
}

View File

@ -32,27 +32,14 @@
"pilot" : "Jim Goddard",
"squadron" : "Midnight Runners"
},
"fighters" : [
"fighterGroups" : [
{
"name" : "Dart",
"type" : "SimpleDart",
"types" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 640,
"y" : -1500
},
{
"name" : "Dart",
"type" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 640,
"y" : -1500
},
{
"name" : "Dart",
"type" : "SimpleDart",
"side" : "SIDE_PIRATE",
"x" : 640,
"y" : -1500
"number" : 3,
"x" : 26,
"y" : 20
}
]
}

View File

@ -38,16 +38,16 @@
"types" : "TAF",
"number" : 4,
"side" : "SIDE_ALLIES",
"x" : 0,
"y" : 0
"x" : 23,
"y" : 25
},
{
"name" : "Dart",
"types" : "SimpleDart",
"number" : 10,
"side" : "SIDE_PIRATE",
"x" : 1000,
"y" : 5000,
"x" : 27,
"y" : 35,
"scatter" : 2000
},
{
@ -55,8 +55,8 @@
"name" : "Dart",
"number" : 10,
"side" : "SIDE_PIRATE",
"x" : -3000,
"y" : -3000,
"x" : 20,
"y" : 15,
"scatter" : 2000
},
{
@ -64,8 +64,8 @@
"types" : "SimpleDart",
"number" : 10,
"side" : "SIDE_PIRATE",
"x" : 0,
"y" : -6000,
"x" : 15,
"y" : 35,
"scatter" : 2000
}
]

View File

@ -39,16 +39,16 @@
"types" : "TAF",
"number" : 4,
"side" : "SIDE_ALLIES",
"x" : 0,
"y" : 0
"x" : 25,
"y" : 23
},
{
"name" : "Dart",
"types" : "Dart",
"number" : 12,
"side" : "SIDE_PIRATE",
"x" : -3000,
"y" : 0,
"x" : 20,
"y" : 25,
"scatter" : 2000
},
{
@ -56,8 +56,8 @@
"types" : "Dart",
"number" : 12,
"side" : "SIDE_PIRATE",
"x" : 4000,
"y" : 0,
"x" : 40,
"y" : 25,
"scatter" : 2000
},
{
@ -65,8 +65,8 @@
"types" : "Dart",
"number" : 12,
"side" : "SIDE_PIRATE",
"x" : 0,
"y" : 6000,
"x" : 25,
"y" : 35,
"scatter" : 2000
}
]

View File

@ -47,8 +47,8 @@
"name" : "Pirate Leader",
"type" : "Dart",
"side" : "SIDE_PIRATE",
"x" : -5000,
"y" : 0,
"x" : 12,
"y" : 25,
"flags" : "FF_NO_KILL+FF_DISABLE+FF_MISSION_TARGET"
}
],
@ -58,16 +58,16 @@
"types" : "TAF",
"number" : 2,
"side" : "SIDE_ALLIES",
"x" : 1600,
"y" : 400
"x" : 27,
"y" : 25
},
{
"name" : "Dart",
"types" : "Dart",
"number" : 12,
"side" : "SIDE_PIRATE",
"x" : -5000,
"y" : 0,
"x" : 15,
"y" : 25,
"scatter" : 2000
}
]

View File

@ -189,14 +189,17 @@ static void loadPlayer(cJSON *node)
type = cJSON_GetObjectItem(node, "type")->valuestring;
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
player = spawnFighter(type, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, side);
player = spawnFighter(type, 0, 0, side);
player->x = (GRID_SIZE * GRID_CELL_WIDTH) / 2;
player->y = (GRID_SIZE * GRID_CELL_HEIGHT) / 2;
}
static void loadFighters(cJSON *node)
{
Entity *f;
char *type;
int side, x, y;
int side;
float x, y;
if (node)
{
@ -206,8 +209,8 @@ static void loadFighters(cJSON *node)
{
type = cJSON_GetObjectItem(node, "type")->valuestring;
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
x = cJSON_GetObjectItem(node, "x")->valueint;
y = cJSON_GetObjectItem(node, "y")->valueint;
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
f = spawnFighter(type, x, y, side);
@ -232,8 +235,9 @@ static void loadFighterGroups(cJSON *node)
{
Entity *f;
char **types, *name, *type;
int side, x, y, scatter, number, active;
int side, scatter, number, active;
int i, numTypes;
float x, y;
scatter = 1;
active = 1;
@ -247,9 +251,9 @@ static void loadFighterGroups(cJSON *node)
types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
number = cJSON_GetObjectItem(node, "number")->valueint;
x = cJSON_GetObjectItem(node, "x")->valueint;
y = cJSON_GetObjectItem(node, "y")->valueint;
name = cJSON_GetObjectItem(node, "name")->valuestring;
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
if (cJSON_GetObjectItem(node, "scatter"))
{
@ -307,8 +311,8 @@ static void loadEntities(cJSON *node)
STRNCPY(e->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH);
}
e->x = cJSON_GetObjectItem(node, "x")->valueint;
e->y = cJSON_GetObjectItem(node, "y")->valueint;
e->x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
e->y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
if (cJSON_GetObjectItem(node, "flags"))
{
@ -324,7 +328,8 @@ static void loadEntityGroups(cJSON *node)
{
Entity *e;
char *name;
int i, type, x, y, scatter, number;
int i, type, scatter, number;
float x, y;
scatter = 1;
@ -336,8 +341,8 @@ static void loadEntityGroups(cJSON *node)
{
type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
number = cJSON_GetObjectItem(node, "number")->valueint;
x = cJSON_GetObjectItem(node, "x")->valueint;
y = cJSON_GetObjectItem(node, "y")->valueint;
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
name = NULL;
if (cJSON_GetObjectItem(node, "name"))