Multiple declarations
Nov 4, 2010 at 9:05pm UTC
So, I'm learning SFML and was trying tto make a Tic-tac-Toe game, but it keeps telling me that the functions of the class that manages the grid is being declared multiple times. Can someone point where's the error??
SFML_Backbone.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include "AIFlManager.hpp"
using namespace std;
int main()
{
sf::Image F;
sf::Sprite sF;
sf::Image O;
sf::Sprite sO;
sf::Image X;
sf::Sprite sX;
F.LoadFromFile("F.png" );
O.LoadFromFile("O.png" );
X.LoadFromFile("X.png" );
sF.SetImage(F);
sO.SetImage(O);
sX.SetImage(X);
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(325, 325, 32), "SFML Graphics" );
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
// Move the sprite
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Q)) return 1;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::W)) return 2;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::E)) return 3;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A)) return 4;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::S)) return 5;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::D)) return 6;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Z)) return 7;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::X)) return 8;
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::C)) return 9;
}
// Clear the screen (fill it with black color)
FManager pr;
if (1 == 1) pr.move(1);
App.Clear();
App.Draw(sF);
App.Draw(sO);
App.Draw(sX);
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
FManager.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <iostream>
using namespace std;
class FManager
{
int field[9];
void usedField(int );
public :
bool move(int );
};
void FManager::usedField(int s)
{
if (field[0] != 1 || field[0] != 0)
{
for (int i = 0; i < 10; i++)
{
field[i] = 0;
}
};
int ch = s;
field[s] = 1;
cout << field[s];
}
bool FManager::move(int m)
{
usedField(m);
return true ;
}
AIFlManager.hpp
1 2 3 4 5 6 7 8
#ifndef AIFlManager
#define AIFlManager
#include "FManager.cpp"
void FManager::usedField(int );
bool FManager::move(int );
#endif
Thanks for the help!
Nov 4, 2010 at 9:31pm UTC
Last edited on Nov 4, 2010 at 9:32pm UTC
Nov 4, 2010 at 11:57pm UTC
Thank you very much!
Topic archived. No new replies allowed.