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

Pages: [1]
1
General / Unresolved External Symbol error
« on: July 26, 2010, 01:25:41 pm »
Quote from: "Laurent"
You forgot the type (bool, int) and you must put these lines in the global scope, outside a function.

Man... Google has 604000 pages that talk about "static members initialization in C++", they explain it very clearly, so you should read more of them to understand what you must do, rather than guessing what code to write.

I don't mean to be rude, just trying to help. Because if you write code that you don't understand, you'll be back next week with the same kind of problem.


I feel like an idiot now. Never hit me to make them global... Thank you. And I will retry reading up on it. Also, I wouldnt consider that to be rude, I consider it effective guidance.

2
General / Unresolved External Symbol error
« on: July 26, 2010, 12:19:29 am »
Quote from: "Laurent"
In this code, the static members are not defined. Where did you put the piece of code that I showed you first?
In the problem area. Whithin the //// lines. I tried to replace it and just add it. Both times I got a redefinition error.

3
General / Unresolved External Symbol error
« on: July 25, 2010, 07:30:43 pm »
The header where I defined the class and its variables.

Code: [Select]
#ifndef PLAYER_H
#define PLAYER_H

#include "Window.h"
#include "Enemy.h"




class Player
{
public:
Player();
sf::Image Image;
sf::Sprite Sprite;
int XCord();
int YCord();
static bool up;
static bool down;
static bool left;
static bool right;
static bool shoot;
static int SpeedMultiplier;


private:
int PosX;
int PosY;


};

int PlayerMovement();

#endif



The cpp file with only the code part causing trouble:

Code: [Select]
#include "Player.h"
#include "Window.h"


Player::Player()
{
Image.LoadFromFile("Animal.tga");
Image.CreateMaskFromColor(sf::Color(255,0,255),0);
Sprite.SetImage(Image);
Sprite.SetCenter(10.f, 10.f);
}

int PlayerMovement()
{

///////////////////////////////////////////////////////
sf::Event KeyPress;
Player::up = false;
Player::down = false;
Player::left = false;
Player::right = false;
Player::shoot = false;
Player::SpeedMultiplier = 1;
////////////////////////////////////////////////////////




if (KeyPress.Type == sf::Event::KeyPressed)
{


switch (KeyPress.Key.Code)
{
case sf::Key::Up:
Player::up = true;
break;
case sf::Key::Down:
Player::down = true;
break;
case sf::Key::Left:
Player::left = true;
break;
case sf::Key::Right:
Player::right = true;
break;
case sf::Key::LShift:
Player::SpeedMultiplier = 3;
case sf::Key::Space:
Player::shoot = true;
default:
break;
}
}

if (KeyPress.Type == sf::Event::KeyReleased)
{

switch (KeyPress.Key.Code)
{
case sf::Key::Up:
Player::up = false;
break;
case sf::Key::Down:
Player::down = false;
break;
case sf::Key::Left:
Player::left = false;
break;
case sf::Key::Right:
Player::right = false;
break;
case sf::Key::LShift:
Player::SpeedMultiplier = 1;
default:
break;
}
}
     }


The problem lies within the code between the //// lines. The linker is what is having trouble.

Can it be because of using the Player::(something) outside the constructor??

NOTES:
Think();
Draw();
SetPos();

Not made those yet, because I want the class to compile and exist before I make it think and do stuff.

4
General / Unresolved External Symbol error
« on: July 25, 2010, 04:16:07 pm »
That is what I thought might have caused it, but then I get a redeclaration error.

Code: [Select]
\Player.cpp(16) : error C2655: 'Player::up' : definition or redeclaration illegal in current scope
1>        c:\users\nds\documents\visual studio 2008\projects\firelizards\firelizards\Player.h(18) : see declaration of 'Player::up'
1>.\Player.cpp(16) : error C2086: 'bool Player::up' : redefinition


Then I thought, maybe it is because I wrote bool again, so I removed bool and only used Player::(whatever). That caused the compiler to complain and give the same error as originally, unresolved external symbol.

I know I can fix it by rewriting it as non.static, but I would rather fix this and learn from it.

5
General / Unresolved External Symbol error
« on: July 25, 2010, 01:53:04 pm »
Quote from: "Laurent"
Well, just read a tutorial about how to properly initialize static member variables... Google knows lots of them ;)

Well, done that again, and as I understood it, the error is about me not adding a library or header file that is requested in my code. But I have gone through that and I know I have all of them added.

6
General / Unresolved External Symbol error
« on: July 24, 2010, 01:07:41 pm »
Risking being laughed at for bad coding, I still have a question that has been bugging me lately. "Unresolved external symbol". I have gotten this error a few times now, and I really want to know exactly what it means and why it is showing up. The code parts that are causing this are:


Player.cpp
Code: [Select]
#include "Player.h"
#include "Window.h"


Player::Player()
{
Image.LoadFromFile("Animal.tga");
Image.CreateMaskFromColor(sf::Color(255,0,255),0);
Sprite.SetImage(Image);
Sprite.SetCenter(10.f, 10.f);
}

int PlayerMovement()
{
sf::Event KeyPress;

bool up = Player::up;
bool down = Player::down;
bool left = Player::left;
bool right = Player::right;
bool shoot = Player::shoot;
int SpeedMultiplier = Player::SpeedMultiplier;


if (KeyPress.Type == sf::Event::KeyPressed)
{


switch (KeyPress.Key.Code)
{
case sf::Key::Up:
Player::up = true;
break;
case sf::Key::Down:
Player::down = true;
break;
case sf::Key::Left:
Player::left = true;
break;
case sf::Key::Right:
Player::right = true;
break;
case sf::Key::LShift:
Player::SpeedMultiplier = 3;
case sf::Key::Space:
Player::shoot = true;
default:
break;
}
}

if (KeyPress.Type == sf::Event::KeyReleased)
{

switch (KeyPress.Key.Code)
{
case sf::Key::Up:
up = false;
break;
case sf::Key::Down:
down = false;
break;
case sf::Key::Left:
left = false;
break;
case sf::Key::Right:
right = false;
break;
case sf::Key::LShift:
SpeedMultiplier = 1;
default:
break;
}
}

/* //MOVING THE PLAYER SPRITE.
if(up)
{
Player::Sprite.Move((cos(Player::Sprite.GetRotation()*3.14159265/180)*3)*Player::SpeedMultiplier, (sin(Player::Sprite.GetRotation()*3.14159265/180)*-3)*Player::SpeedMultiplier);
}
if(down)
{
Player::Sprite.Move((cos(Player::Sprite.GetRotation()*3.14159265/180)*-3)*Player::SpeedMultiplier, (sin(Player::Sprite.GetRotation()*3.14159265/180)*3)*Player::SpeedMultiplier);
}
if(left)
{
Player::Sprite.Rotate(6);
}
if(right)
{
PLayer::Sprite.Rotate(-6);
}
while (shoot)
{
//App.Draw(FireSprite);
//FireSprite.SetDirection(AnimalSprite);
//FireSprite.Move(cos(BulletAngle*3.14159265/180)*3, sin(BulletAngle*3.14159265/180)*-3);
//RenderTarget(FireSprite);

}*/
}



Player.h
Code: [Select]
#ifndef PLAYER_H
#define PLAYER_H

#include "Window.h"
#include "Enemy.h"




class Player
{
public:
Player();
sf::Image Image;
sf::Sprite Sprite;
int XCord();
int YCord();
static bool up;
static bool down;
static bool left;
static bool right;
static bool shoot;
static int SpeedMultiplier;


private:
int PosX;
int PosY;


};

int PlayerMovement();

#endif


Can you point out what is causing it and why it is a negative thing? I want to understand the errors so I can work with them even better in the future.



Notes:

The sfml packets are all under the Window.h header.

Full error list:
Code: [Select]
1>Player.obj : error LNK2001: unresolved external symbol "public: static bool Player::right" (?right@Player@@2_NA)
1>Player.obj : error LNK2001: unresolved external symbol "public: static bool Player::left" (?left@Player@@2_NA)
1>Player.obj : error LNK2001: unresolved external symbol "public: static bool Player::up" (?up@Player@@2_NA)
1>Player.obj : error LNK2001: unresolved external symbol "public: static int Player::SpeedMultiplier" (?SpeedMultiplier@Player@@2HA)
1>Player.obj : error LNK2001: unresolved external symbol "public: static bool Player::down" (?down@Player@@2_NA)
1>Player.obj : error LNK2001: unresolved external symbol "public: static bool Player::shoot" (?shoot@Player@@2_NA)


Thank you so much in advance.

7
Graphics / I can't create another sprite
« on: June 20, 2010, 10:09:18 pm »
Thank you, I can see it now. Thank you so much. I have been sitting for 3 days now.

8
Graphics / I can't create another sprite
« on: June 20, 2010, 08:07:38 am »
I am just learning SFML at the moment, but so far it has been logical. This problem does not brake any logical reasoning and thus I can't seem to find the cause for it all.

I created the first sprite, made it move and stuff. Then I wanted to create a bullet or ranged attack for it, so I made the image and created the sprite JUST like the tutorial said. Still I get the unidentified identifier error.

Here is the code:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

using namespace std;
using namespace sf;

int main()
{
   RenderWindow App(VideoMode(800, 600, 32), "DICKFACED");
   App.SetFramerateLimit(60);
   
   Image Image;
   Image.LoadFromFile("Animal.tga");
   Image.CreateMaskFromColor(Color(255,0,255),0);

   Image Image2;
   Image.LoadFromFile("FIRE.tga");
   Image.CreateMaskFromColor(Color(255,0,255),0);

   Sprite Sprite(Image);
   Sprite.SetX(154.f);
   Sprite.SetY(114.f);
   Sprite.SetCenter(10.f, 10.f);

   Sprite Fire(Image2);
   

   bool up = false;
   bool down = false;
   bool left = false;
   bool right = false;
   bool shoot = false;

   while (App.IsOpened())
   {
      Event Event;
      while (App.GetEvent(Event))
      {
         
         if (Event.Type == Event::Closed)
            App.Close();
         Sprite.GetPosition();
         
         if ((Event.Type == Event::KeyReleased) && (Event.Key.Code == Key::Escape))
         {
            App.Close();
         }

         if (Event.Type == Event::KeyPressed)
         {
            

            switch (Event.Key.Code)
            {
               case Key::Up:
                  up = true;
                  break;
               case Key::Down:
                  down = true;
                  break;
               case Key::Left:
                  left = true;
                  break;
               case Key::Right:
                  right = true;
                  break;
               case Key::Space:
                  shoot = true;
               default:
                  break;
            }               
         }
         if (Event.Type == Event::KeyReleased)
         {

            switch (Event.Key.Code)
            {
               case Key::Up:
                  up = false;
                  break;
               case Key::Down:
                  down = false;
                  break;
               case Key::Left:
                  left = false;
                  break;
               case Key::Right:
                  right = false;
                  break;
               default:
                  break;
            }               
         }
      }

      if(up)
      {
         Sprite.Move(cos(Sprite.GetRotation()*3.14159265/180), sin(Sprite.GetRotation()*3.14159265/180)*-1);
      }
      if(down)
      {
         Sprite.Move(cos(Sprite.GetRotation()*3.14159265/180)*-1, sin(Sprite.GetRotation()*3.14159265/180));
      }
      if(left)
      {
         Sprite.Rotate(3);
      }
      if(right)
      {
         Sprite.Rotate(-3);
      }
      if(shoot)
      {
         Fire.SetPosition(Sprite.GetPosition);
         Fire.Move(cos(Fire.GetRotation()*3.14159265/180), sin(Fire.GetRotation()*3.14159265/180)*-1);


      }
   
      App.Clear(Color(255,255,255));
      //Draw stuff
      App.Draw(Sprite);
      App.Display();

   }

return 0;
}

Pages: [1]