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

Author Topic: Tile Map  (Read 16284 times)

0 Members and 2 Guests are viewing this topic.

GameBear

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • Email
Re: Tile Map
« Reply #15 on: May 30, 2017, 12:52:46 am »
To draw in another place you can either set the view:
https://www.sfml-dev.org/tutorials/2.4/graphics-view.php
sf::View view(sf::FloatRect(0, -530, 600, 600));
window.setView(view);

 

Or draw with an offset:

//Wherever you declare variables//
Int xOffset = 0;
Int yOffset = 530;

//Render part.
 STileGrass.setPosition((i * 70)+xOffset ,( j * 70)+yOffset );
 window.draw(STileGrass);
 
If I understand correctly...

Out of curiosity, what is your native language?
Best regards :)
« Last Edit: May 30, 2017, 12:56:03 am by GameBear »
string message = "some random dude";
cout << "I'm just " << message;

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Tile Map
« Reply #16 on: May 30, 2017, 03:53:00 pm »
I have just one more question...The array is vertically showing, how to put it horizontally ?
I mean to put it like int mapArray[4][5] =
    {
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
    };
to int mapArray[4][5] =
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {1,1,1,1,1},
    };
Guess Who's Back ?

GameBear

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
    • Email
Re: Tile Map
« Reply #17 on: May 30, 2017, 04:35:24 pm »
Change STileGrass.setPosition(i * 70, j * 70);
To STileGrass.setPosition(i * 70, j * 70);

The setPosition() takes two operators,
X position and Y position. Like this:
setPosition(X,Y);
If X is j then j is horizontal
If Y is i then i is vertical.

Still, what is your language, I'd love to point you to some tutorials....
string message = "some random dude";
cout << "I'm just " << message;

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Tile Map
« Reply #18 on: May 30, 2017, 04:51:09 pm »
I meant the array to be horizontally looking(because it's easier to look horizontally than vertically) ,not the setposition.
Something like :  int mapArray[4][5] =
    {
        {0,0,0,0,0},
        {0,0,0,0,0},
        {0,0,0,0,0},
        {1,1,1,1,1},
    };
« Last Edit: June 01, 2017, 07:43:25 am by Boanc »
Guess Who's Back ?

Ionut

  • Jr. Member
  • **
  • Posts: 59
  • Guess Who's Back ?
    • View Profile
    • Email
Re: Tile Map
« Reply #19 on: June 01, 2017, 10:52:50 am »
Ok let the array be like that,but now I have a bigger problem,I tried to make a collision detector and it shows me that only the last piece of "map" collides with the player,how to make the entire "map" collidable ?
Guess Who's Back ?

 

anything