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

Pages: [1]
1
General / Re: Problem with simple code.
« on: February 04, 2013, 12:36:20 am »
Thanks Everyone for your help, FRex's first answer helped me with the problem, i can now see the orange tiles perfectly :D. Also i do realize the YouTube tutorials contain some bad practice, but at first i was looking for a book but i could not find a book on sfml, If one exists could you please give me the name of it. Lastly the main reason why i have not decided to go with sfml 2.0 yet is that im not sure if the above code would be compatible with it and i have not seen any tutorials on it, I have yet to take a look at the wiki though.

2
General / Problem with simple code.
« on: February 03, 2013, 10:32:21 pm »
Hello i am new to SFML and i am using codingmadeeasy's tutorials on YouTube as well as the written tutorials for SFML to help me get started. Everything was going good till i got to one of his tutorials that deal with loading maps from a file where you can decide what tiles are using 1's and 0's. Well before i even try implementing code into my own games i copy and paste them and make sure the work at first. So when i tried to compile the code he had put on his site, the code compiled fine but the 1's on the map file wont appear which are orange color but the blue tiles which are 0's do appear, Can you figure out what is wrong with the code?

// C++ Sfml Made Easy Tutorial 29 - Loading Tile Maps [Easy]
// CodingMadeEasy

#include<SFML/Graphics.hpp>
#include<iostream>
#include<fstream>

#define ScreenWidth 800
#define ScreenHeight 600

#define BLOCKSIZE 40

int loadCounterX = 0, loadCounterY = 0;
int mapSizeX, mapSizeY;
int MapFile[100][100];

void LoadMap(const char *filename)
{
    std::ifstream openfile(filename);
    if(openfile.is_open())
    {
        openfile >> mapSizeX >> mapSizeY;
        while(!openfile.eof())
        {
            openfile >> MapFile[loadCounterX][loadCounterY];
            loadCounterX++;
            if(loadCounterX >= mapSizeX)
            {
                loadCounterX = 0;
                loadCounterY++;
            }
        }
    }
}

void DrawMap(sf::RenderWindow &Window)
{
    sf::Shape rect = sf::Shape::Rectangle(0, 0, BLOCKSIZE, BLOCKSIZE, sf::Color(255, 255, 255, 255));
    sf::Color rectCol;
    for(int i = 0; i < mapSizeX; i++)
    {
        for(int j = 0; j < mapSizeY; j++)
        {
            if(MapFile[i][j] == 0)
                rectCol = sf::Color(44, 117, 255);
            if (MapFile[i][j] == 1)
                rectCol = sf::Color(255, 100, 17);

            rect.SetPosition(i * BLOCKSIZE, j * BLOCKSIZE);
            rect.SetColor(rectCol);
            Window.Draw(rect);
        }
    }
}

int main()
{
    sf::RenderWindow Window(sf::VideoMode(ScreenWidth, ScreenHeight, 32), "SFML Made Easy");

    LoadMap("Map.txt");
    while(Window.IsOpened())
    {
        sf::Event Event;
        while(Window.GetEvent(Event))
        {
            if(Event.Type == sf::Event::Closed || Event.Key.Code == sf::Key::Escape)
                Window.Close();
        }

        Window.Clear();
        DrawMap(Window);
        Window.Display();
    }
    return 0;
}

 



By the way my Map.txt file looks like this
10 10
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
1111111111

3
General discussions / SFML and the Windows Phone 8 SDK
« on: January 28, 2013, 05:58:18 am »
So as some of us know Microsoft's new mobile platform windows phone 8 has native code support so i was wondering if in some way we could get SFML to work on the OS would it be Plausible?

Pages: [1]