Jump to content

  • Log In with Google      Sign In   
  • Create Account


shawk08033

Member Since 16 Jul 2012
Offline Last Active Jan 21 2014 06:35 PM
-----

Topics I've Started

Read text as a map in c++

20 January 2014 - 04:06 PM

Hi I have a class call map. 

#include "Map.h"
#include <fstream>
#include <ostream>
#include <istream>

Log spritelog("spritedebug.txt", false);
Map::Map()
{
Load();
spritelog << "Sprites are loaded" << std::endl;
}
void Map::Load()
{
    ifstream resources("resources.txt");
    std::string str;
    int i = 0;
    while (std::getline(resources, str))
    {
      UsedSprites[i] = new Sprite(0, 0, str);
      i++;
    }
    resources.close();
    delete resources;
    str = "";
    ifstream maptext("map.txt");
    i = 0;
    int y = 0;
    int x = 0;
    while(std::getline(maptext, str))
    {
        stringstream stream(str);
        string c = "";
        while(std::getline(stream,c, ','))
        {
          int n = atoi(c.c_str());
          MapSprite[x] = UsedSprites[n];
          MapSprite[x]->X = i*64;
          MapSprite[x]->Y = y*64;
          spritelog << n << "Loading into " << x << " at " << i*64 << "," << y*64 << std::endl;
          i++;
          x++;
        }
        y++;
        i = 0;
    }
    maptext.close();
    spritelog << "Loading " << x << " Sprites Into Map at " << y << " lines" << std::endl;
    delete UsedSprites;
    delete maptext;
}
void Map::Render()
{
    for(int i = 0; i < 34; i++)
    {
        MapSprite[i]->Render();
        spritelog << "Rended: " << i << "X: " << MapSprite[i]->X << " Y: " << MapSprite[i]->Y << std::endl;
    }
}


When I load this text file:

0,1,0,0,1
1,0,0,0,1
1,1,1,1,1
0,0,0,0,0
1,1,1,1,1
1,0,0,0,1
1,1,1,1,1
 
0 = green 1= grey
 
See attachments for debug info and screen shot.Attached File  helpc++.PNG   231.75KB   0 downloadsAttached File  spritedebug.txt   1.82KB   23 downloads
 
When is the x and y not the same as what I set it in Load() to what it renders at.

Making an optimized 3d mmo in open gl c++

04 April 2013 - 05:05 PM

I currently starting to make a mmorpg in c++ using opengl. How could I optimized it to run the best it can on integrated graphics but also take full advantage of top of line graphics card like a GTX 660 or higher.Would it been done directly in the way I code opengl or would it been done by changing the quality of the texture images?? 


Representing player classes in c++

21 September 2012 - 01:57 PM

What is the best way to represent player classes for an rpg game in c++

Rendering Engine For QT

22 July 2012 - 10:48 AM

Is there any open source cross platform rendering/graphics engine for qt

Rendering Engine For QT

21 July 2012 - 07:20 PM

Is there any open source cross platform 3d rendering/graphics for qt.

PARTNERS