text: Content count231
  Joined
  Last visited
  Community Reputation594 Good
  About Crusable77
  - RankMember
  typedef, structs, and arrays
  Crusable77 replied to Crusable77's topic in For BeginnersThanks, I didn't even think of that.
  typedef, structs, and arrays
  Crusable77 posted a topic in For BeginnersHello, I have a struct that defines an RGBA colour: struct Colour{ float r; float g; float b; float a; }; Then I have an array of some predefined colours so instead of having to write out something link display.clear(Colour(1.f, 0.f, 0.f, 1.f) I would instead write display.clear(clr::red); So I have an array of colours: //pre defined colours Colour colours[6] = {{1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 1.f}}; Now here is my problem. I want to typedef all the elements in the array so instated of writing clr::colours[0] I write clr::red. SO I tried writing them like this and it did not work: namespace clr{ typedef colours[0] red; typedef colours[1] green; typedef colours[2] blue; typedef colours[3] magenta; typedef colours[4] white; typedef colours[5] black; }//namespace clr Is this possible or did I just do it wrong? Thanks for any help.
  SFML Texture errors
  Crusable77 replied to Crusable77's topic in For BeginnersYes it was the graphics card. My graphics card is very old. Thanks for the help.
  SFML Texture errors
  Crusable77 posted a topic in For BeginnersHello, I recently got a new pc with windows 8. I tried to compile a project on this new computer with the same IDE and the same version on SFML as on my old windows 7 laptop, and I get this error repeated in my console window. An internal OpenGL call failed in Texture.cpp (146) : GL_INVALID_ENUM, an unacce ptable value has been specified for an enumerated argument An internal OpenGL call failed in Texture.cpp (147) : GL_INVALID_ENUM, an unacce ptable value has been specified for an enumerated argument The only thing I can think of is the graphics card. All the projects compile fine on my old laptop, which has a better graphics card but worse cpu and less ram. Thanks for any help.
  - I fixed the issue two days ago, sorry for not commenting. I added a tilepos int and then wrote a predicate to pass into the std;:sort and that fixed it. Thanks for the responses.
  - When I have the image the same as the one on the right, it should say I win, but it doesn't. I believe it is because of the order of the vector. I want the top corner of the map to be 0 and then all the way down to the bottom right to be n in a sequential order, despite how I move the tiles. At the beginning of the game i shuffle the tiles using std::random_shuffle and reset the positions so it is jumbled and call std::sort: std::random_shuffle(m_blocks.begin(), m_blocks.end()); //reset the positions for(int y = 0; y != 10; ++y){ for(int x = 0; x != 10; ++x){ m_blocks[(y * 10) + x]->setPos(sf::Vector2f(offsetX + (x * 32), offsetY + (y * 32))); } } std::sort(m_blocks.begin(), m_blocks.end()); m_blocks is the tiles and 32 is the size of the block. I also call std:;sort after I move the tiles: std::sort(m_blocks.begin(), m_blocks.end()); Also I am overloading the < operator: bool Block::operator<(Block& rhs){ return (m_tile_pos < rhs.m_tile_pos); } and the m_tile_pos is set everytime the block is updated
  Sorting std::vectors
  Crusable77 posted a topic in For BeginnersHello, I am making a picture matching game(you have a picture and a jumbled picture and you need to make them match), and so I have a vector of tiles(2d squares with colour). When I move the selected tile it changes the position of the tile it moved onto to its old position. However, this does not change its position in the vector so when trying to see if the picture matches the one I just made, it doesn't work. I need a way to, after I move the tile, update the vector so the order of the tiles in the map is 0 - n and it isn't all jumbled up. I tried std::sort but that doesn't seem to work. Thanks for any help.I included a pic to help demonstrate the movement.[attachment=19165:Problem.png]
  Compiling SDL2 with MinGW through Command line
  Crusable77 posted a topic in For BeginnersHello, I am tyring to comile a project with SDL2 through command line with MinGw. I have a run.bat file that looks like so: g++ -o Game.exe Main/Main.cpp -lmingw32 -lSDL2main -mwindows -lSDL2 pause start /d "C:\Users\Mathew Bergen\Documents\Programming\C++\LD Practice" Game.exe I get these errors: c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main. o): In function `main': e:\p\giaw\src\pkg\mingwrt-4.0.3-1-mingw32-src\bld/../mingwrt-4.0.3-1-mingw32-src /src/libcrt/crt/main.c:91: undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status I googled the WInMain@16 error and I found that I needed to add -mwindows to the linking command, but it still does not work. I am on windows 7, Thanks for any help.
  - Thank you everyone. I figured out the error was with my singleton, it wasn't deleting properly. Thanks for the help.
  - I did read the article and I did everything it told me to and I still don't get the full debug log.
  - Hello, I did #define _CRTDBG_MAP_ALLOC and my destructors are virtual: /*Component is the parent to all other components so the entity class can have a std::vector<Componet*>*/ #ifndef COMPONENT_HPP #define COMPONENT_HPP class Component{ public: Component(); virtual ~Component() = 0; virtual void update(float deltaT); }; #endif //COMPONENT_HPP
  std::vector memory leak issues
  Crusable77 posted a topic in For BeginnersHello, I have an entity with a std::vector<Component*> m_components (Component is an abstract base class all other Components inherit from so I can polymorph them) and when I destroy the entity I clear the vector like so: Entity::~Entity(){ for(std::vector<Component*>::iterator iter = m_components.begin(); iter != m_components.end(); ++iter){ delete *iter; *iter = NULL; } m_components.clear(); m_components.shrink_to_fit(); } and I get memory leaks. I looked online and everywhere I look it looks like I am doing it right. The memory leaks are a jumble of numbers: Detected memory leaks! Dumping objects -> {377} normal block at 0x05804D28, 8 bytes long. Data: < N > 90 4E 80 05 00 00 00 00 {376} normal block at 0x05804E80, 80 bytes long. Data: < c w c > 90 B1 63 05 D8 81 77 05 90 B1 63 05 00 00 CD CD {374} normal block at 0x05884028, 98304 bytes long. Data: < > 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF {373} normal block at 0x05804E38, 8 bytes long. Data: < M > A4 4D 80 05 00 00 00 00 {372} normal block at 0x05804DF0, 8 bytes long. Data: < M > 80 4D 80 05 00 00 00 00 {371} normal block at 0x05804D70, 68 bytes long. Data: < c w c > C8 B0 63 05 C8 80 77 05 C8 B0 63 05 00 00 CD CD {353} normal block at 0x05778268, 8 bytes long. Data: < w > E8 81 77 05 00 00 00 00 {352} normal block at 0x057781D8, 80 bytes long. Data: < c *x N > 90 B1 63 05 10 2A 78 05 80 4E 80 05 01 00 CD CD {350} normal block at 0x057839A0, 262144 bytes long. Data: < $ $ $ $ > 83 24 0C FF 83 24 0C FF 83 24 0C FF 83 24 0C FF {349} normal block at 0x05778190, 8 bytes long. Data: < w > FC 80 77 05 00 00 00 00 {348} normal block at 0x05778148, 8 bytes long. Data: < w > D8 80 77 05 00 00 00 00 {347} normal block at 0x057780C8, 68 bytes long. Data: < c x pM > C8 B0 63 05 08 19 78 05 70 4D 80 05 01 00 CD CD {326} normal block at 0x05772908, 8 bytes long. Data: < *x > 20 2A 78 05 00 00 00 00 {325} normal block at 0x05782A10, 80 bytes long. Data: < &w c w > 18 26 77 05 90 B1 63 05 D8 81 77 05 01 00 CD CD {323} normal block at 0x057819D0, 4096 bytes long. Data: < > FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF {322} normal block at 0x05781988, 8 bytes long. Data: << x > 3C 19 78 05 00 00 00 00 {321} normal block at 0x05772950, 8 bytes long. Data: < x > 18 19 78 05 00 00 00 00 {320} normal block at 0x05781908, 68 bytes long. Data: <@"w c w > 40 22 77 05 C8 B0 63 05 C8 80 77 05 01 00 CD CD {303} normal block at 0x0577A100, 8 bytes long. Data: <(&w > 28 26 77 05 00 00 00 00 {302} normal block at 0x05772618, 80 bytes long. Data: < c *x c > 90 B1 63 05 10 2A 78 05 90 B1 63 05 01 00 CD CD {299} normal block at 0x05779030, 4096 bytes long. Data: < > FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF {298} normal block at 0x05772308, 8 bytes long. Data: <t"w > 74 22 77 05 00 00 00 00 {297} normal block at 0x057722C0, 8 bytes long. Data: <P"w > 50 22 77 05 00 00 00 00 {296} normal block at 0x05772240, 68 bytes long. Data: < c x c > C8 B0 63 05 08 19 78 05 C8 B0 63 05 01 00 CD CD {275} normal block at 0x0563B220, 8 bytes long. Data: <| c > 7C B0 63 05 00 00 00 00 {274} normal block at 0x0563B190, 80 bytes long. Data: < &w *x N > 18 26 77 05 10 2A 78 05 80 4E 80 05 01 01 CD CD {273} normal block at 0x0563B148, 8 bytes long. Data: <p c > 70 B0 63 05 00 00 00 00 {272} normal block at 0x0563B0C8, 68 bytes long. Data: <@"w x pM > 40 22 77 05 08 19 78 05 70 4D 80 05 01 01 CD CD {271} normal block at 0x0563B070, 24 bytes long. Data: <H c c c > 48 B1 63 05 C8 B0 63 05 04 00 00 00 20 B2 63 05 {171} normal block at 0x0357F378, 40 bytes long. Data: < 5_ > D4 C5 35 5F 18 00 00 00 08 00 00 00 00 00 00 00 {170} normal block at 0x003FBFE8, 40 bytes long. Data: < 5_ > D4 C5 35 5F 18 00 00 00 08 00 00 00 00 00 00 00 Object dump complete. I am using VS2012's built in system for detecting memory leaks. This is the only place I am dynamically allocating anything in my program and when I comment out everything that has to do with the vector I get no errors. Thanks for any help.
  Weird memory leak reports
  Crusable77 posted a topic in For BeginnersHello, I read this (tells you how to detect memory leaks in VS) and I applied it to my project but I got some unexpected results. I am not even dynamically allocating anything and it tells me I have a bunch of memory leaks. Detected memory leaks! Dumping objects -> {173} normal block at 0x038F9D90, 20 bytes long. Data: <8.s 8.s 8.s > 38 2E 73 00 38 2E 73 00 38 2E 73 00 01 00 CD CD {172} normal block at 0x038F3408, 24 bytes long. Data: <@4 > 40 34 8F 03 FF FF FF FF 00 00 00 00 00 00 00 00 {171} normal block at 0x0360EEA0, 40 bytes long. Data: < _ > D4 C5 C3 5F 18 00 00 00 08 00 00 00 00 00 00 00 {170} normal block at 0x0072BCF0, 40 bytes long. Data: < _ > D4 C5 C3 5F 18 00 00 00 08 00 00 00 00 00 00 00 {151} normal block at 0x007335B0, 32 bytes long. Data: <Platformer Studi> 50 6C 61 74 66 6F 72 6D 65 72 20 53 74 75 64 69 {150} normal block at 0x00727620, 8 bytes long. Data: < % > 9C 25 08 01 00 00 00 00 {147} normal block at 0x00732F60, 24 bytes long. Data: < /s > 98 2F 73 00 FF FF FF FF 00 00 00 00 00 00 00 00 {146} normal block at 0x00732ED0, 24 bytes long. Data: < /s > 08 2F 73 00 FF FF FF FF 00 00 00 00 00 00 00 00 {145} normal block at 0x00732E88, 8 bytes long. Data: <8# _ > 38 23 C4 5F 00 00 00 00 {144} normal block at 0x00732E38, 20 bytes long. Data: < > 90 9D 8F 03 90 9D 8F 03 90 9D 8F 03 01 01 CD CD {143} normal block at 0x00732DF8, 4 bytes long. Data: < > 0C 00 00 00 {142} normal block at 0x00732DB8, 4 bytes long. Data: < > 0B 00 00 00 Object dump complete. My Code: #define CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <SFML/Graphics.hpp> #include <string> #include <sstream> #include <iostream> //window attributes const unsigned int WINDOW_WIDTH = 800; const unsigned int WINDOW_HEIGHT = 600; const unsigned int MAX_FPS = 60; const std::string WINDOW_NAME = "Platformer Studio v 1.0 inDev"; int main(){ sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), WINDOW_NAME, sf::Style::Close); sf::Event event; sf::Clock fpsTimer, updTimer; int frames = 0; window.setFramerateLimit(MAX_FPS); while(window.isOpen()){ //events while(window.pollEvent(event)){ switch(event.type){ case sf::Event::Closed: window.close(); break; } } //keyboard input if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) window.close(); ++frames; //set to a dark purple colour window.clear(sf::Color(80, 0, 80, 255)); window.display(); //get frame rate and display it in the title bar if(fpsTimer.getElapsedTime() >= sf::seconds(1)){ std::stringstream sstr; sstr << WINDOW_NAME << " " << frames << " fps"; window.setTitle(sstr.str()); frames = 0; fpsTimer.restart(); } } _CrtDumpMemoryLeaks(); return 0; } What does this mean? I am using VS2012 and SFML 2.0. thanks for any help
  Crusable77 posted a topic in Games Business and LawHello, I have never copyrighted any of my code and I am unsure of how to do it. Do I need a registered company? Can I just use my name? Is there a standard message you need to put in with your code? Thanks for any help. Also, I am not sure if this belongs in this forum or not.
  changed a std::list to std::vector breaks the program
  Crusable77 replied to Crusable77's topic in For BeginnersNo, the problem only occurs when I changed to std::vector from std::list. Edit: It worked thanks