We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00a10d1 commit 95491b3Copy full SHA for 95491b3
BombingAdventure/Classes/Entity.cpp
@@ -30,7 +30,11 @@ void Entity::bind_sprite(Sprite *sprite) {
30
}
31
void Entity::reset_position() {
32
if(get_sprite() != NULL) {
33
- setPosition(Vec2(CCRANDOM_0_1() * 960, CCRANDOM_0_1() * 640));
+ /* Generate a position in unit Tile */
34
+ int target_tile_x = (int) floor(CCRANDOM_0_1() * MAP_SIZE.width);
35
+ int target_tile_y = (int) floor(CCRANDOM_0_1() * MAP_SIZE.height);
36
+ /* Set to the position in unit pixel, did not add robust part */
37
+ setPosition(Vec2(target_tile_x * TILE_SIZE.width + TILE_SIZE.width / 2, target_tile_y * TILE_SIZE.height + TILE_SIZE.height / 2));
38
39
40
Vec2 Entity::tileCoordFromPosition(Vec2 position)
0 commit comments