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

Pages: [1] 2
1
General / I'm becoming insane
« on: November 20, 2011, 10:17:07 pm »
Fixed it :D the "use inherited defaults " in the Linker settings of VS2010 was unticked :D

2
General / I'm becoming insane
« on: November 19, 2011, 11:45:17 pm »
I recompiled SFML 1.6 because of a random problem with sprites... and everything went peachy, with no errors or warnings. When I tried to run my program(which loads a sprite, displays it etc etc) I get this
Code: [Select]

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)


I searched the forum, the answers were to include sfml-window debug library, searched the internet, checked the path... I'm stumped.

3
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 09, 2011, 10:50:40 pm »
Quote from: "Laurent"
Quote
sorry, 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


I am sorry again for wasting your time. On the other hand, I think the problem is with Visual Studio 2010 project configurations... I'll just reset them and/or rebuild SFML

4
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 06, 2011, 10:53:05 pm »
Quote from: "sbroadfoot90"
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.


My bad, didn't read thoroughly :(

Regarding the code, it works in my second "non-obfuscated" post, but it fails to do so in the first one, even though the code is 99% the same... sorry, this is the most minimal I can to reproduce the bug :(

5
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 06, 2011, 08:31:58 pm »
And it works perfectly with this code:

main.cpp:
Code: [Select]

/*
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;

}


masterSprite.h:
Code: [Select]

/*
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


utilities.h:
Code: [Select]

/*
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

6
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 06, 2011, 08:25:27 pm »
Quote from: "Laurent"
Can you provide a complete and minimal example that reproduces the problem?


I'll post the whole code, without obfuscation:

main.cpp:
Code: [Select]

/*
 * 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
Code: [Select]

/*
 * 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:
Code: [Select]

/*
 * 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:
Code: [Select]

/*
 * 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


I am running this with SFML 1.6

7
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 06, 2011, 08:01:43 pm »
Quote from: "Laurent"
The error message suggests that somehow your image filename is empty.


The only difference between this program and the program that worked, is that this program uses images created by myself, and the other one used images from the internet.

8
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 05, 2011, 11:06:55 pm »
Bumping...

9
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 05, 2011, 01:26:40 am »
... is the error message I get after I run my program. I've checked the paths, they are ok, copied the images from their folder into the root of the program, even changed them from JPG to PNG and nothing... same error message for each image that is being loaded. It worked before in an other program, which was not much different from this one in terms of classes and such.
Here is the code:

main.cpp:

Code: [Select]

#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;
}



mappings.h:

Code: [Select]

#ifndef MAPPINGS_H_
#define MAPPINGS_H_

#define PLACEHOLDER "placeholder.png"
#define PLAYABLE_CHARACTER "pc.png"

#endif


Also, the Blocks and kareninaCharacter class are pretty much the same, except the latter one has a few more methods, but the process of loading images and sprites is the same and as in the tutorial:

Code: [Select]

Blocks(string imglocation)
{

this->imgLocation = imgLocation;
Image.LoadFromFile(imgLocation);

Sprite.SetImage(Image);

}


I am using Visual Studio 2010 on Win7 x64

10
Graphics / Simple, yet difficult(at least for me)
« on: October 07, 2011, 01:30:59 pm »
Quote from: "ChronicRat"
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;


Ah, ye olde ternary operator :D powerful, yet used by few :P

11
Graphics / Simple, yet difficult(at least for me)
« on: October 07, 2011, 01:22:32 pm »
Quote from: "praetoriaen"
Quote from: "sbroadfoot90"
OK I found your bug, the fact you're using VS2010 doesn't have anything to do with it :)

you just put
Code: [Select]
     bool indicator = true; inside your main loop meaning that it was resetting to true each frame. You needed to put it before
Code: [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.


EDIT: I feel like an idiot... i didn't put the key detection routine... it works now flawlessly :) thank you all

12
Graphics / Simple, yet difficult(at least for me)
« on: October 07, 2011, 01:15:19 pm »
Quote from: "sbroadfoot90"
OK I found your bug, the fact you're using VS2010 doesn't have anything to do with it :)

you just put
Code: [Select]
     bool indicator = true; inside your main loop meaning that it was resetting to true each frame. You needed to put it before
Code: [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.

13
Graphics / Simple, yet difficult(at least for me)
« on: October 07, 2011, 12:15:36 am »
Quote from: "sbroadfoot90"
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 problem

Code: [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 this

Code: [Select]

            if(indicator)
            {
               Sprite.SetImage(pMegusta->Image);
               indicator = false;
            }
            else
            {
               Sprite.SetImage(pMudkip->Image);
               indicator = true;
            }


Tried with both =='s and with your example, nothing. It just changes the sprite to the Me Gusta face on the first key press, and on the second it does nothing.

Sorry for the utilities part, as I said, my aim is to make this program bloated :D

I'm using VS2010, if it matters...

14
Graphics / Simple, yet difficult(at least for me)
« on: October 07, 2011, 12:07:16 am »
No problem :)

This is my event loop. Currently, it is supposed to change a sprite first from a Slowpoke to a Me Gusta face, and then change it to a Mudkip. And it fails to work:
Code: [Select]


#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;

}



masterSprite.h:
Code: [Select]

#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_


utilities.h:
Code: [Select]

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

}


Sorry if it's a little bit bloated, I'm making it like that on purpose :D

15
Graphics / Simple, yet difficult(at least for me)
« on: October 06, 2011, 10:05:38 pm »
I am trying to change sprites when the user presses a key. For instance, there is a sprite of a chicken, if the user presses M, the chicken changes into a plane, and if he/she presses it again, it changes into a snake. I tried putting if's in the event chain after the if that is supposed to pick up the key.. but no luck. Any help? I am sure the answer is simple, but I'm probably too stressed out to see it :P

Pages: [1] 2
anything