Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Remi749

Pages: [1]
1
General / Parsing "Collection of Images" with json doesn't work
« on: November 26, 2017, 04:53:54 pm »
Hi, so I have a Tiled map, I have a "based on a tileset image" tileset, and a "Collection of Images" tileset with a few images of different sizes inside.

Everything works fine, but not for the "Collection of Images" tileset and parsing this with json to our game.

Here is the layer loader from json to cpp. It loads the layer and it works fine, if I add something to the map from "Collection of Images" tileset, it is ignored. I can still collide with it, but it isn't shown.

void MapMaker::loadLayer(Json::Value &layer, std::list<Object *> &objects, TileSize tileSize) {

    MapLayer *tmp = new MapLayer(tileSize);

    tmp->width = layer["width"].asInt();
    tmp->height = layer["height"].asInt();

    memset(tmp->tileMap, 0, sizeof(tmp->tileMap));

    for(size_t i = 0; i < layer["data"].size(); ++i)
        tmp->tileMap[i] = layer["data"][(int)i].asInt();

    tmp->isCollisionLayer = layer["properties"]["Collision"].asBool();

    objects.push_back(tmp);

}

The crates in the images are from the "Collection of Images" tileset


but in-game these are gone, but the player can still collide with them...


I bet there is some code missing. if anyone can help that would be greatly appreciated.

I have attached the json map file if needed.

2
Thanks for the reply, I figured it out in a different way. If anyone is interested to know how, let me know :)

3
Graphics / Getting position of the circle that is rotated around a point
« on: November 19, 2017, 04:29:53 pm »
Hi, in the code below I have a circle shape, which rotates around the player in my game. If I try to do a getPosition for the circle, it gives the point at which it rotates around. this is not what I'm looking for.

I want to be able to get the exact position where the circle is during its circular movement around the point. So I can use that position and shoot bullets towards the circle.


//header file:

sf::CircleShape c;

//cppfile:

c.setFillColor(sf::Color::Red);
c.setPosition(this->sprite->getPosition().x + width / 2, this->sprite->getPosition().y + height / 2);
c.setRadius(25);
c.setOrigin({1, -100});

c.rotate(1.f);

c.setPosition(this->sprite->getPosition().x + width / 2, this->sprite->getPosition().y + height / 2);

std::cout << "Circle.x: " << c.getEXACTPOS.y << " | Circle.y: " << c.getEXACTPOS.y << std::endl;

window.draw(c);
 

If there is a better solution to rotate a circle around a point, don't hesitate to tell me :)

If this is not possible, I am looking for a way to use the rightstick on a joystick to shoot in the direction it's pointing to.

Pages: [1]