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 - Code_Black2she

Pages: [1]
1
General / C++/sfml
« on: April 15, 2017, 09:02:33 pm »
Yes hi ok I have some c++/sfml code that I've wrote, and I have been running into problems. The one I'm stuck on now is mapping the map corrdinates to the objects in the map. I want to be able to use 2d int arrays for difderent objects. One for the player, one for the map ect for collsion. Thanks for the help.   https://pastebin.com/mihFbL9X

2
General / Re: Tile map help
« on: September 04, 2016, 07:42:38 am »
Yes I am but I need help on understanding how to display tiles on screen

3
General / Tile map help
« on: September 04, 2016, 04:12:03 am »
Yes I'm having trouble with my code. I don't understand why it is not displayed right. I've tryed sfml tutorials on youtube, but no help to me.
Beginner self thaugh programmer.





Code: [Select]

class Tile{
    sf::Sprite spr;
public:
    void LoadTile(sf::Texture& tex){

spr.setTexture(tex);

}

void draw(sf::RenderWindow* rw){

//spr.SetPosition(x,y);
(*rw).draw(spr);


}

sf::Vector2f getsize(){}

};


class Level{
    std::vector<std::vector<Tile*> > map1;
    int h,w;
public:
Level(int x,int y){

map1.resize(x);
for(int i=0;i<x;i++)
    map1.at(i).resize(y,0);
this->h=x;
this->w=y;


}
void AddTile(int x,int y,Tile* tile){

map1[x][y]=tile;


}
Tile* GetTile(int x,int y){return map1[x][y];}


};


















void LoadLevel(int*level){
    Level*p=new Level(2,2);
    Tile*tile;
    int currentTile=0;
    sf::Texture grass,brick;
    grass.loadFromFile("321.jpg");
brick.loadFromFile("123.jpg");

for(int i=0;i<2;i++)
    for(int j=0;j<2;j++){

    currentTile= level[i+j];

    std::cout<<currentTile;
    if(currentTile==1){
        tile=new Tile;
        (*tile).LoadTile(brick);
    }
    else if(currentTile==0){
        tile=new Tile;
        (*tile).LoadTile(grass);}



        (*p).AddTile(i,j,tile);
        }

for(int i=0;i<2;i++)
    for(int j=0;j<2;j++){

      Tile* tile1 =(*p).GetTile(i,j);

      tile1->draw(&window);




    }


}




int main(){

int level[4]={0,1,0,1};
sf::RenderWindow window(sf::ViderMode(800,600)"game");
while(window.isOpen()){
   sf::Event eve;
   while(window.pollEvent(eve)){
      if(eve.type==sf::Event::Closed)
        window.close();
       
     
LoadLevel(level);
     
    window.display();

   }




}

std::cout<<"Hello World!  "<<count;

return 0;

Pages: [1]
anything