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

Pages: [1]
1
Graphics / Re: Problem with rendering a rectangle
« on: January 26, 2016, 07:14:01 pm »
Thank you, I knew there was something simple I was forgetting...

2
Graphics / Problem with rendering a rectangle
« on: January 26, 2016, 06:54:41 pm »
For some reason this code won't render the rectangleshape correctly. It takes control away from the player correctly and waits the right amount before giving it back, but the rectangle doesn't render on the window. If you need more of my code, please let me know.

int screenHeight = 500;
int screenWidth = 500;

if (Keyboard::isKeyPressed(Keyboard::Escape)){
                  playerControl = false;
                  RectangleShape menuBackground;
                  menuBackground.setFillColor(sf::Color::Red);
                  menuBackground.setSize(Vector2f(0, 0));
                  menuBackground.setPosition(sf::Vector2f(screenWidth / 2, screenHeight / 2));
                  window.draw(menuBackground);
                  for (int c = 1; c < 51; c++){
                     menuBackground.setSize(sf::Vector2f(round(screenWidth / 50) * c, round(screenHeight / 50) * c));
                     menuBackground.move(sf::Vector2f((round(screenWidth / 50) * c / 2) * -1, round((screenHeight / 50) * c / 2) * -1));
                     window.draw(menuBackground);
                     sleep(Time(milliseconds(10)));
                  }
                  menuBackground.setSize(Vector2f(screenWidth, screenHeight));
                  window.draw(menuBackground);

                  sleep(Time(seconds(3)));
                  
                  for (int a = 0; a < 50; a++){
                     menuBackground.setSize(sf::Vector2f(screenWidth - (round(screenWidth / 50) * a), screenHeight - (round(screenHeight / 50) * a)));
                     menuBackground.move(sf::Vector2f(round(screenWidth / 50) * a / 2, round(screenHeight / 50) * a / 2));
                     window.draw(menuBackground);
                     sleep(Time(milliseconds(10)));
                  }
                  menuBackground.setSize(Vector2f(0, 0));
                  window.draw(menuBackground);
                  playerControl = true;
            }

3
Graphics / Re: Problems using textures in classes
« on: November 30, 2015, 05:13:24 pm »
Thanks for your help, because it seems SFML has the same problem you have, it hates being Global. As soon as a moved it into being a non-global texture, it fixed.

4
Graphics / Re: Problems using textures in classes
« on: November 23, 2015, 07:53:51 pm »
As far as I can find, that is where the stacktrace starts. As for whether I should do this, I can't find any other way to check the name of a texture to attach it to a sprite. I don't want to have to create separate classes for each enemy. As you can see from the second part of the code, I am attaching the texture by comparing the file name to the name of the enemy. If there is a way to check the the name of a texture, compare it to the name of an enemy and attach it if it matches, that would be great. But I don't know ow to do that.

5
Graphics / Problems using textures in classes
« on: November 23, 2015, 07:25:17 pm »
I didn't even fully understand what the problem is. It was fixed when I commented out the texture and sprite declaration, but I need those for what I am using it for. The code I used was:

Main:

enemy enemies[4];

int main(){
   for (int a = 0; a < enemyListL; a++){
      enemies[a].name = "dead";
      if (!enemies[a].texture.create(32, 32)){}
   }
   enemies[0].sprite.setPosition(50, 50);

   generateEnemy(enemies, "link", 15);
}

Class:

#include <SFML/Graphics.hpp>

using namespace sf;

const int enemyListL = 5;

string enemiesNames[enemyListL] = { "link", "wyrm", "armored wyrm", "glitching wyrm", "evil guard" };

//health, pAttack, aAttack, pDefense, aDefense, speed, luck
int enemyBaseStat[7][enemyListL] = { 5, 5, 5, 5, 5, 5, 5};

class enemy{
public:
   string name;
   int health;
   int level;
   int pAtk;
   int aAtk;
   int pDef;
   int aDef;
   int speed;
   int luck;
   Texture texture;
   Sprite sprite;
   enemy(){               //This is the line it points to with the error
   }
};

int takeDamageDisk(Disks disk, enemy enemy1){
   srand(time(NULL));
   return ((disk.damage * 2) / (enemy1.aDef)) * ((rand() % 15) + 91) / 100;
}

void generateEnemy(enemy enemiesT[4], string name, int level){
   for (int a = 0; a < 4; a++){
      if (enemiesT[a].name == "dead"){
         for (int b = 0; b < enemyListL; b++){
            if (name == enemiesNames){
               enemiesT[a].level = level;
               srand(time(NULL));
               enemiesT[a].health = enemyBaseStat[0] * level + (enemyBaseStat[0] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() ^ time(NULL));
               enemiesT[a].pAtk = enemyBaseStat[1] * level + (enemyBaseStat[1] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() * time(NULL));
               enemiesT[a].aAtk = enemyBaseStat[2] * level + (enemyBaseStat[2] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() ^ time(NULL));
               enemiesT[a].pDef = enemyBaseStat[3] * level + (enemyBaseStat[3] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() * time(NULL));
               enemiesT[a].aDef = enemyBaseStat[4] * level + (enemyBaseStat[4] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() ^ time(NULL));
               enemiesT[a].speed = enemyBaseStat[5] * level + (enemyBaseStat[5] * level * (((rand() % 30) - 15) + 100) / 100);
               srand(rand() * time(NULL));
               enemiesT[a].luck = enemyBaseStat[6] * level + (enemyBaseStat[6] * level * (((rand() % 10) - 5) + 100) / 100);
               sf::Image image;
               image.loadFromFile("Images\Enemies\\" + name + ".png");
               enemiesT[a].texture.update(image);
               enemiesT[a].sprite.setTexture(enemiesT[a].texture);
            }
         }
      }
   }
}


The window compiles correctly but crashes immediately after launch, before the window can even register.

The error is this:
Unhandled exception at 0x777522D2 (ntdll.dll) in RPGFramework.exe: 0xC0000005: Access violation writing location 0x00000004.

6
Graphics / Re: How do I use a rectangleshape as a class member?
« on: November 12, 2015, 03:27:40 pm »
Thanks, I forgot to migrate my namespace call... That fixed it.

7
Graphics / How do I use a rectangleshape as a class member?
« on: November 12, 2015, 03:00:00 pm »
I am trying to create collision detection for rectangleshapes, and I decided to try and attach it directly to the shape by calling the rectangleshape constructor as a member of the bounding box class, and it is giving me all kinds of errors. I can't figure out how to fix it, or if I am even able to do this.
Here's my code:

#include <SFML/Graphics.hpp>

const int OBoxA = 20;
const int IBoxA = 20;

class box{
public:
   RectangleShape drawBox;
   int xOffset;
   int xLength;
   int xOrigin;
   int yOffset;
   int yLength;
   int yOrigin;

   box(){
      xLength = -1;
   }
        //I set the values through a different method besides calling it
};

My error message is:
Error   18   error C2146: syntax error : missing ';' before identifier 'drawBox'
Error   19   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

If you need more, please let me know. Thanks.

8
Thank you so much, that fixed it!

9
I did that and it worked for all but the last two bugs.

my error console now looks like this:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Projects\CPP\Temporal\Debug\Temporal.exe : fatal error LNK1120: 1 unresolved externals

after I changed the additional dependencies to this:
freetype.lib; jpeg.lib; opengl32.lib; winmm.lib; gdi32.lib; flac.lib; vorbisenc.lib; vorbisfile.lib; vorbis.lib; ogg.lib; openal32.lib; sfml-graphics-s-d.lib; sfml-window-s-d.lib; sfml-system-s-d.lib; sfml-audio-s-d.lib; kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)

10
Hi, I've been trying to add sfml 2.3.2 to the project, and I am getting a large amount of errors. I tried to find out what the problem was by searching around, and it mostly said to put the .dll files with the executable, but being relatively new to the process I didn't know where that would be. I am using the code exactly as put in the SFML and Visual Studio tutorial, and I am statically linking the files.

In C/C++ << general << additional include directories I put C:\Projects\CPP\SFML-2.3.2\bin; C:\Projects\CPP\SFML-2.3.2\include

In C/C++ << preprocessor <<preprocessor definitions I added SFML_STATIC at the beginning

In Linker/general/additional library directory I put C:\Projects\CPP\SFML-2.3.2\bin; C:\Projects\CPP\SFML-2.3.2\lib;

In Linker/input/Additional dependencies I put freetype.lib; jpeg.lib; opengl32.lib; winmm.lib; gdi32.lib; flac.lib; vorbisenc.lib; vorbisfile.lib; vorbis.lib; ogg.lib; openal32.lib; sfml-graphics-s.lib; sfml-window-s.lib; sfml-system-s.lib; sfml-audio-s.lib; in front of what was already there

the full error report I got is as follows:

1>sfml-graphics-s.lib(Color.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Color.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Shape.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Shape.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(CircleShape.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(CircleShape.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(RenderTarget.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(RenderTarget.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(RenderWindow.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(RenderWindow.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(RenderStates.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(RenderStates.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Transform.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Transform.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Transformable.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Transformable.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(VertexArray.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(VertexArray.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Texture.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Texture.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(View.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(View.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Shader.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Shader.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(GLExtensions.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(GLExtensions.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(GLLoader.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(GLLoader.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(Image.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(Image.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-graphics-s.lib(ImageLoader.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-graphics-s.lib(ImageLoader.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(VideoMode.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(VideoMode.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(Window.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(Window.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(VideoModeImpl.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(VideoModeImpl.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(GlContext.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(GlContext.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(WindowImpl.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(WindowImpl.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(WglContext.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(WglContext.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(JoystickManager.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(JoystickManager.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(SensorManager.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(SensorManager.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(WindowImplWin32.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(WindowImplWin32.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(WglExtensions.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(WglExtensions.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(Joystick.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(Joystick.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-system-s.lib(String.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-system-s.lib(String.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-system-s.lib(Err.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-system-s.lib(Err.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>sfml-system-s.lib(ThreadLocal.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>sfml-system-s.lib(ThreadLocal.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in Source.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Projects\CPP\Temporal\Debug\Temporal.exe : fatal error LNK1120: 1 unresolved externals

If I made some easy mistake, I'm sorry for wasting your time, and I hope you have a nice day. If you need anything else, please let me know and I will try to post it. Thank you.

Pages: [1]
anything