1
General / I'm becoming insane
« on: November 20, 2011, 10:17:07 pm »
Fixed it the "use inherited defaults " in the Linker settings of VS2010 was unticked
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.
sfml-window-s-d.lib(VideoModeSupport.obj) : error LNK2019: unresolved external symbol __imp__EnumDisplaySettingsA@12 referenced in function "public: static void __cdecl sf::priv::VideoModeSupport::GetSupportedVideoModes(class std::vector<class sf::VideoMode,class std::allocator<class sf::VideoMode> > &)" (?GetSupportedVideoModes@VideoModeSupport@priv@sf@@SAXAAV?$vector@VVideoMode@sf@@V?$allocator@VVideoMode@sf@@@std@@@std@@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(void)" (??0WindowImplWin32@priv@sf@@QAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(void)" (??0WindowImplWin32@priv@sf@@QAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExW@48 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(void)" (??0WindowImplWin32@priv@sf@@QAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SetWindowLongA@12 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(void *,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@PAXAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__GetClientRect@8 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(void *,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@PAXAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__AdjustWindowRect@12 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__ReleaseDC@8 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__GetDeviceCaps@8 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__GetDC@4 referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings &)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KAAUWindowSettings@2@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function "public: virtual __thiscall sf::priv::WindowImplWin32::~WindowImplWin32(void)" (??1WindowImplWin32@priv@sf@@UAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__UnregisterClassW@8 referenced in function "public: virtual __thiscall sf::priv::WindowImplWin32::~WindowImplWin32(void)" (??1WindowImplWin32@priv@sf@@UAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function "public: virtual __thiscall sf::priv::WindowImplWin32::~WindowImplWin32(void)" (??1WindowImplWin32@priv@sf@@UAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DestroyIcon@4 referenced in function "public: virtual __thiscall sf::priv::WindowImplWin32::~WindowImplWin32(void)" (??1WindowImplWin32@priv@sf@@UAE@XZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::ProcessEvents(void)" (?ProcessEvents@WindowImplWin32@priv@sf@@EAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::ProcessEvents(void)" (?ProcessEvents@WindowImplWin32@priv@sf@@EAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::ProcessEvents(void)" (?ProcessEvents@WindowImplWin32@priv@sf@@EAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SwapBuffers@4 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::Display(void)" (?Display@WindowImplWin32@priv@sf@@EAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SetCursor@4 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::ShowMouseCursor(bool)" (?ShowMouseCursor@WindowImplWin32@priv@sf@@EAEX_N@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__LoadCursorA@8 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::ShowMouseCursor(bool)" (?ShowMouseCursor@WindowImplWin32@priv@sf@@EAEX_N@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SetCursorPos@8 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetCursorPosition(unsigned int,unsigned int)" (?SetCursorPosition@WindowImplWin32@priv@sf@@EAEXII@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__ClientToScreen@8 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetCursorPosition(unsigned int,unsigned int)" (?SetCursorPosition@WindowImplWin32@priv@sf@@EAEXII@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SetWindowPos@28 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetPosition(int,int)" (?SetPosition@WindowImplWin32@priv@sf@@EAEXHH@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__GetWindowLongA@8 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetSize(unsigned int,unsigned int)" (?SetSize@WindowImplWin32@priv@sf@@EAEXII@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SendMessageA@16 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetIcon(unsigned int,unsigned int,unsigned char const *)" (?SetIcon@WindowImplWin32@priv@sf@@EAEXIIPBE@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__CreateIcon@28 referenced in function "private: virtual void __thiscall sf::priv::WindowImplWin32::SetIcon(unsigned int,unsigned int,unsigned char const *)" (?SetIcon@WindowImplWin32@priv@sf@@EAEXIIPBE@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::RegisterWindowClass(void)" (?RegisterWindowClass@WindowImplWin32@priv@sf@@AAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__RegisterClassW@4 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::RegisterWindowClass(void)" (?RegisterWindowClass@WindowImplWin32@priv@sf@@AAEXXZ)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__ChangeDisplaySettingsA@8 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::SwitchToFullscreen(class sf::VideoMode const &)" (?SwitchToFullscreen@WindowImplWin32@priv@sf@@AAEXABVVideoMode@3@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__SetPixelFormat@12 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::CreateContext(class sf::VideoMode const &,struct sf::WindowSettings &)" (?CreateContext@WindowImplWin32@priv@sf@@AAEXABVVideoMode@3@AAUWindowSettings@3@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__ChoosePixelFormat@8 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::CreateContext(class sf::VideoMode const &,struct sf::WindowSettings &)" (?CreateContext@WindowImplWin32@priv@sf@@AAEXABVVideoMode@3@AAUWindowSettings@3@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DescribePixelFormat@16 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::CreateContext(class sf::VideoMode const &,struct sf::WindowSettings &)" (?CreateContext@WindowImplWin32@priv@sf@@AAEXABVVideoMode@3@AAUWindowSettings@3@@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__TrackMouseEvent@4 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::ProcessEvent(unsigned int,unsigned int,long)" (?ProcessEvent@WindowImplWin32@priv@sf@@AAEXIIJ@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__GetAsyncKeyState@4 referenced in function "private: void __thiscall sf::priv::WindowImplWin32::ProcessEvent(unsigned int,unsigned int,long)" (?ProcessEvent@WindowImplWin32@priv@sf@@AAEXIIJ@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__MapVirtualKeyA@8 referenced in function "private: static enum sf::Key::Code __cdecl sf::priv::WindowImplWin32::VirtualKeyCodeToSF(unsigned int,long)" (?VirtualKeyCodeToSF@WindowImplWin32@priv@sf@@CA?AW4Code@Key@3@IJ@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "private: static long __stdcall sf::priv::WindowImplWin32::GlobalOnEvent(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobalOnEvent@WindowImplWin32@priv@sf@@CGJPAUHWND__@@IIJ@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__DefWindowProcW@16 referenced in function "private: static long __stdcall sf::priv::WindowImplWin32::GlobalOnEvent(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobalOnEvent@WindowImplWin32@priv@sf@@CGJPAUHWND__@@IIJ@Z)
sfml-window-s-d.lib(WindowImplWin32.obj) : error LNK2019: unresolved external symbol __imp__CallWindowProcA@20 referenced in function "private: static long __stdcall sf::priv::WindowImplWin32::GlobalOnEvent(struct HWND__ *,unsigned int,unsigned int,long)" (?GlobalOnEvent@WindowImplWin32@priv@sf@@CGJPAUHWND__@@IIJ@Z)
Quotesorry, this is the most minimal I can to reproduce the bug
I don't think so
The most minimal that you can do is a main that loads and play the sound. Then if it works (which is what I expect), focus on the 1% of your code that is different between both versions. That should produce another minimal code, that you can debug much more easily than your whole project. Etc, etc....
People just give up when they face a bug that they can't explain immediately, like if there was nothing to do. But it's your code, you wrote it, and you wrote the bug too, so there's always something you can do to find it and fix it -- with some extra work. Don't be afraid to write or remove code just for debugging.
And if you happen to find a really minimal code that still has the problem, then I'll be able to tell you whether it's a bug in SFML or not.
http://www.sfml-dev.org/forum/viewtopic.php?p=36368#36368
Quote from: "praetoriaen"Quote from: "Laurent"Can you provide a complete and minimal example that reproduces the problem?
I'll post the whole code, without obfuscation:
He wanted less code, not more, keyword "minimal". Most of the time people don't have time to read through other people's code in details so you need to keep it brief if you have a chance of getting help.
/*
SFMLTestum Testi: Exercise in SFML and HARDCORE OOP
Author: Milos Zivadinovic
Licence: if you are reading this expect Slenderman in your bathroom */
#include <SFML/Graphics.hpp>
#include <iostream>
#include "utilities.h"
#include "masterSprite.h"
int main()
{
sf::RenderWindow App(sf::VideoMode::GetMode(0), "I AM SLOWPOKE KING OF SLOW", sf::Style::Fullscreen);
App.UseVerticalSync(true);
bool running = App.IsOpened();
int width = App.GetWidth();
int height = App.GetHeight();
masterSprite *pSprite = new masterSprite("slowpoke.png");
/* masterSprite *pMegusta = new masterSprite("megusta.png");
masterSprite *pMudkip = new masterSprite("mudkip.png");
masterSprite *pWobbufet = new masterSprite("wobbufet.png"); */
const sf::Input &Input = App.GetInput();
std::cout << width << std::endl;
std::cout << height << std::endl;
bool indicator = true;
while (running)
{
sf::Event Event;
while(App.GetEvent(Event))
{
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::M))
{
if(indicator)
{
pSprite->setSprite("megusta.png");
indicator = false;
}
else
{
pSprite->setSprite("slowpoke.png");
indicator = true;
}
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::R))
{
utilities::r++;
(pSprite->Sprite).Rotate(utilities::r);
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::T))
{
utilities::t++;
(pSprite->Sprite).SetRotation(utilities::t);
}
if(Event.Type == sf::Event::Closed)
{
running = false;
App.Close();
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
running = false;
App.Close();
}
if(Input.IsKeyDown(sf::Key::Right))
{
utilities::x += utilities::speed;
if(utilities::x > width)
{
utilities::x = 0;
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
else
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Left))
{
utilities::x -= utilities::speed;
if(utilities::x < 0)
{
utilities::x = (float)width;
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
else
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Up))
{
utilities::y -= utilities::speed;
if(utilities::y < 0)
{
utilities::y = (float)height;
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
else
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Down))
{
utilities::y += utilities::speed;
if(utilities::y > height)
{
utilities::y = 0;
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
(pSprite->Sprite).SetPosition(utilities::x,utilities::y);
}
}
App.Clear();
App.Draw(pSprite->Sprite);
App.Display();
}
return 0;
}
/*
SFMLTestum Testi: Exercise in SFML and HARDCORE OOP
Author: Milos Zivadinovic
Licence: if you are reading this expect Slenderman in your bathroom */
#ifndef MASTERSPRITE_H_
#define MASTERSPRITE_H_
#include <iostream>
#include <SFML\Graphics.hpp>
class masterSprite
{
public:
masterSprite(std::string imgLocation);
~masterSprite() {};
sf::Sprite getSprite() const;
void setSprite(std::string imgLocation);
//variables
sf::Image Image;
std::string imgLocation;
sf::Sprite Sprite;
};
masterSprite::masterSprite(std::string imgLocation)
{
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
}
sf::Sprite masterSprite::getSprite() const
{
return Sprite;
}
void masterSprite::setSprite(std::string imgLocation)
{
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
}
#endif
/*
SFMLTestum Testi: Exercise in SFML and HARDCORE OOP
Author: Milos Zivadinovic
Licence: if you are reading this expect Slenderman in your bathroom */
#ifndef UTILITIES_H_
#define UTILITIES_H_
namespace utilities
{
int speed = 10; //movement speed
float r = 0; //angle for incremental rotation
float t = 0; //angle for regular rotation
float x = 0; //x axis for movement
float y = 0; //y axis for movement
}
#endif
Can you provide a complete and minimal example that reproduces the problem?
/*
* main.cpp
*
* Created on: Oct 21, 2011
* Author: scarborough
*
*
* --------------------STATUS--------------------
*
* 444 - release
* 333 - final testing
* 222 - beta
* 111 - alpha
* 000 - pre-alpha
*
* ----------------------------------------------
*/
#include <iostream>
#include "kareninacharacter.h"
#include "blocks.h"
#include "mappings.h"
#define NAME "To heaven with you"
#define REVISION 0002
#define DATE_REVISION 05112011 //date of last increment to the REVISION macro
#define STATUS 000
#define DATE_STATUS 21102011 //date of last increment to the STATUS macro
using namespace std;
int main() {
sf::RenderWindow *pApplication = new sf::RenderWindow(sf::VideoMode::GetMode(0), NAME, sf::Style::Fullscreen);
Blocks *pBackground = new Blocks(PLACEHOLDER);
Blocks *pLevelBlock = new Blocks(BLOCK_LEVEL_X);
kareninaCharacter *pPlayableCharacter = new kareninaCharacter(PLAYABLE_CHARACTER);
sf::Shape Floor = sf::Shape::Rectangle(0, 4800, 5000, 5000, sf::Color(50, 50, 50, 0)); //replace with Blocks
bool running = pApplication->IsOpened();
while(running)
{
sf::Event Event;
while(pApplication->GetEvent(Event))
{
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
pApplication->Close();
}
}
pApplication->Clear();
pApplication->Draw(pBackground->getSprite());
pApplication->Draw(Floor);
pApplication->Draw(pPlayableCharacter->getSprite());
pApplication->Draw(pLevelBlock->getSprite());
pApplication->Display();
}
return 0;
}
/*
* mappings.h
*
* Created on: Aug 11, 2011
* Author: scarborough
*
*/
#ifndef MAPPINGS_H_
#define MAPPINGS_H_
#define PLACEHOLDER "placeholder.png"
#define PLAYABLE_CHARACTER "pc.png"
/*
#define BLOCK_LEVEL_X ""
#define BLOCK_LEVEL_1 ""
#define BLOCK_LEVEL_2 ""
#define BLOCK_LEVEL_3 ""
#define BLOCK_LEVEL_4 ""
#define BLOCK_LEVEL_5 ""
#define BLOCK_LEVEL_6 ""
#define BLOCK_LEVEL_7 ""
#define BLOCK_LEVEL_8 ""
#define BLOCK_LEVEL_9 ""
*/
#endif
/*
* blocks.h
*
* Created on: Aug 11, 2011
* Author: scarborough
*
*/
#ifndef BLOCKS_H_
#define BLOCKS_H_
#include <iostream>
#include <SFML\Graphics.hpp>
using namespace std;
class Blocks{
public:
Blocks(string imglocation)
{
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
}
virtual ~Blocks() {};
sf::Sprite getSprite();
private:
string imgLocation;
sf::Image Image;
sf::Sprite Sprite;
};
sf::Sprite Blocks::getSprite()
{
return Sprite;
}
#endif
/*
* kareninacharacter.h
*
* Created on: Aug 11, 2011
* Author: scarborough
*
*/
#ifndef KARENINACHARACTER_H_
#define KARENINACHARACTER_H_
#include <iostream>
#include <SFML\Graphics.hpp>
using namespace std;
class kareninaCharacter {
public:
kareninaCharacter(string imglocation)
{
dead = false;
hostile = false;
health_bar = 100;
mana_bar = 100;
name = "Apoptygma";
attack_melee = false;
attack_ranged = false;
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
};
virtual ~kareninaCharacter() {};
/* getters */
string getName() const;
bool getAttack_melee() const;
bool getAttack_ranged() const;
bool getDead() const;
bool getHostile() const;
short signed int getHealth_bar() const;
short signed int getMana_bar() const;
sf::Sprite getSprite() const;
/* setters */
void setName(string &name);
void setAttack_melee(bool &attack_melee);
void setAttack_ranged(bool &attack_ranged);
void setDead(bool &dead);
void setHostile(bool &hostile);
void setHealth_bar(short signed int &health_bar);
void setMana_bar(short signed int &mana_bar);
void setSprite(string imgLocation);
private:
/* identifiers */
string name;
bool attack_melee;
bool attack_ranged;
/* states */
bool dead;
bool hostile;
/* stats */
short signed int health_bar;
short signed int mana_bar;
/* technicalities */
sf::Sprite Sprite;
sf::Image Image;
string imgLocation;
};
/* getters */
string kareninaCharacter::getName() const
{
return name;
}
bool kareninaCharacter::getAttack_melee() const
{
return attack_melee;
}
bool kareninaCharacter::getAttack_ranged() const
{
return attack_ranged;
}
bool kareninaCharacter::getDead() const
{
return dead;
}
short signed int kareninaCharacter::getHealth_bar() const
{
return health_bar;
}
short signed int kareninaCharacter::getMana_bar() const
{
return mana_bar;
}
sf::Sprite kareninaCharacter::getSprite() const
{
return Sprite;
}
/* setters */
void kareninaCharacter::setName(string &name)
{
this->name = name;
}
void kareninaCharacter::setAttack_melee(bool &attack_melee)
{
this->attack_melee = attack_melee;
}
void kareninaCharacter::setAttack_ranged(bool &attack_ranged)
{
this->attack_ranged = attack_ranged;
}
void kareninaCharacter::setDead(bool &dead)
{
this->dead = dead;
}
void kareninaCharacter::setHostile(bool &hostile)
{
this->hostile = hostile;
}
void kareninaCharacter::setHealth_bar(short signed int &health_bar)
{
this->health_bar = health_bar;
}
void kareninaCharacter::setMana_bar(short signed int &mana_bar)
{
this->mana_bar = mana_bar;
}
void kareninaCharacter::setSprite(string imgLocation)
{
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
}
#endif
The error message suggests that somehow your image filename is empty.
#include <iostream>
#include "kareninacharacter.h"
#include "blocks.h"
#include "mappings.h"
#define NAME "To heaven with you"
using namespace std;
int main() {
sf::RenderWindow *pApplication = new sf::RenderWindow(sf::VideoMode::GetMode(0), NAME, sf::Style::Fullscreen);
Blocks *pBackground = new Blocks(PLACEHOLDER);
kareninaCharacter *pPlayableCharacter = new kareninaCharacter(PLAYABLE_CHARACTER);
sf::Shape Floor = sf::Shape::Rectangle(0, 4800, 5000, 5000, sf::Color(50, 50, 50, 0)); //replace with Blocks
bool running = pApplication->IsOpened();
while(running)
{
sf::Event Event;
while(pApplication->GetEvent(Event))
{
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
pApplication->Close();
}
}
pApplication->Clear();
pApplication->Draw(pBackground->getSprite());
pApplication->Draw(Floor);
pApplication->Draw(pPlayableCharacter->getSprite());
pApplication->Display();
}
return 0;
}
#ifndef MAPPINGS_H_
#define MAPPINGS_H_
#define PLACEHOLDER "placeholder.png"
#define PLAYABLE_CHARACTER "pc.png"
#endif
Blocks(string imglocation)
{
this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);
Sprite.SetImage(Image);
}
Quote from: "praetoriaen"Code: [Select]
if(indicator)
{
Sprite.SetImage(pMegusta->Image);
indicator = false;
}
else
{
Sprite.SetImage(pMudkip->Image);
indicator = true;
}
Sorry, but... =)Code: [Select]
Sprite.SetImage(indicator ? pMegusta->Image : pMudkip->Image);
indicator = !indicator;
Quote from: "sbroadfoot90"OK I found your bug, the fact you're using VS2010 doesn't have anything to do with it
you just putCode: [Select]bool indicator = true;
inside your main loop meaning that it was resetting to true each frame. You needed to put it beforeCode: [Select]while(running)
Tried it just now, it seems that whenever I press any key that is in the event loop it starts switching sprites like crazy without displaying the first sprite... I tried adding it to the end of the event loop, but no avail, it is the same except it displays the first sprite.
OK I found your bug, the fact you're using VS2010 doesn't have anything to do with it
you just putCode: [Select]bool indicator = true;
inside your main loop meaning that it was resetting to true each frame. You needed to put it beforeCode: [Select]while(running)
I haven't read through all of it because there is a lot of utilities:: that was making me dizzy, but I think this is your problemCode: [Select]
if(indicator = true)
{
Sprite.SetImage(pMegusta->Image);
indicator = false;
}
else if(indicator = false)
{
Sprite.SetImage(pMudkip->Image);
indicator = true;
}
1. You need == not =
2. You need not compare to true or false at all!, and the second if condition is unnecessary. Change it to thisCode: [Select]
if(indicator)
{
Sprite.SetImage(pMegusta->Image);
indicator = false;
}
else
{
Sprite.SetImage(pMudkip->Image);
indicator = true;
}
#include <SFML/Graphics.hpp>
#include <iostream>
#include "utilities.h"
#include "masterSprite.h"
int main()
{
sf::RenderWindow App(sf::VideoMode::GetMode(0), "I AM SLOWPOKE KING OF SLOW", sf::Style::Fullscreen);
App.UseVerticalSync(true);
bool running = App.IsOpened();
int width = App.GetWidth();
int height = App.GetHeight();
int indicator = 0;
masterSprite *pSlowpoke = new masterSprite("slowpoke.png");
masterSprite *pMegusta = new masterSprite("megusta.png");
masterSprite *pMudkip = new masterSprite("mudkip.png");
masterSprite *pWobbufet = new masterSprite("wobbufet.png");
sf::Sprite Sprite;
Sprite.SetImage(pSlowpoke->Image);
const sf::Input &Input = App.GetInput();
std::cout << width << std::endl;
std::cout << height << std::endl;
while (running)
{
bool indicator = true;
sf::Event Event;
while(App.GetEvent(Event))
{
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::M))
{
if(indicator = true)
{
Sprite.SetImage(pMegusta->Image);
indicator = false;
}
else if(indicator = false)
{
Sprite.SetImage(pMudkip->Image);
indicator = true;
}
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::R))
{
utilities::r++;
Sprite.Rotate(utilities::r);
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::T))
{
utilities::t++;
Sprite.SetRotation(utilities::t);
}
if(Event.Type == sf::Event::Closed)
{
running = false;
App.Close();
}
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
running = false;
App.Close();
}
if(Input.IsKeyDown(sf::Key::Right))
{
utilities::x += utilities::speed;
if(utilities::x > width)
{
utilities::x = 0;
Sprite.SetPosition(utilities::x,utilities::y);
}
else
Sprite.SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Left))
{
utilities::x -= utilities::speed;
if(utilities::x < 0)
{
utilities::x = (float)width;
Sprite.SetPosition(utilities::x,utilities::y);
}
else
Sprite.SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Up))
{
utilities::y -= utilities::speed;
if(utilities::y < 0)
{
utilities::y = (float)height;
Sprite.SetPosition(utilities::x,utilities::y);
}
else
Sprite.SetPosition(utilities::x,utilities::y);
}
if(Input.IsKeyDown(sf::Key::Down))
{
utilities::y += utilities::speed;
if(utilities::y > height)
{
utilities::y = 0;
Sprite.SetPosition(utilities::x,utilities::y);
}
Sprite.SetPosition(utilities::x,utilities::y);
}
}
App.Clear();
App.Draw(Sprite);
App.Display();
}
return 0;
}
#ifndef MASTERSPRITE_H_
#include <iostream>
#include <SFML\Graphics.hpp>
class masterSprite
{
public:
masterSprite(std::string imgLocation);
~masterSprite() {};
//variables
sf::Image Image;
std::string imgLocation;
};
masterSprite::masterSprite(std::string imgLocation)
{
this->imgLocation;
Image.LoadFromFile(imgLocation);
}
#endif MASTERSPRITE_H_
namespace utilities
{
int speed = 10; //movement speed
float r = 0; //angle for incremental rotation
float t = 0; //angle for regular rotation
float x = 0; //x axis for movement
float y = 0; //y axis for movement
}