ChainedHollow

Members
  • Content count

    24
  • Joined

  • Last visited

Community Reputation

158 Neutral

About ChainedHollow

  • Rank
    Member
  1. Pass entire vector of objects to constructor by reference?

    Thank you so much! It hit me after you asked what the type was. Pointers and references do still confuse me a bit but I am trying! Thanks for the help!
  2. Pass entire vector of objects to constructor by reference?

    Oh yeah, the declaration of the heroes vector is std::vector<Hero*> heroes;
  3. Pass entire vector of objects to constructor by reference?

    That isnt working either : ( Thank you though. Im so confused!
  4. I am needing to pass an entire vector of objects to a constructor of another class.  I have succeeded in doing this with a single vector object, but with the entire vector, it's giving me trouble.   Here is the code.   classes.h:   class Star: public Spell {      public:           Star(std::vector<Hero>& hero_list): h_list(hero_list) {}      protected:           std::vector<Hero>& h_list; }   spells.cpp:   Star::Star(std::vector<Hero>& hero_list): h_list(hero_list) {   }   and then the call from main.cpp:   std::vector<Spell*> spells; spells.push_back(new Star(*heroes));   Right now, it's not liking the call. I get: "Error: no operator "*" matches these operands" I have similar code that is working just fine with passing a single object from the vector, but not this.    I need to pass the entire vector for this particular spell sub-class so it can check values of multiple hero objects and make changes to them. 
  5. Passing an object to constructor of another object? C++

    error C2664: 'Heal::Heal(Hero &)' : cannot convert parameter 1 from 'Hero **' to 'Hero &'   I've tried adding & and * but that doesn't work either.
  6. Passing an object to constructor of another object? C++

    I see, thank you. It seems I have fixed the errors with the classes, but I don't if it's working yet because calling it is giving me an error now. I removed const, as was mentioned, and I moved Hero& hero to the protected section of Heal. Then I have:     spells.push_back(new Heal(heroes.at(0)) );   spells is a vector made above. std::vector<Spell*> spells; and heroes is the hero vector. std::vector<Hero*> heroes;   This just isn't working now. Am I calling it wrong?
  7. Hi everyone! I am hoping someone can help me out with this. I've been looking around online all night and I am so confused.   I have 2 classes, and 1 sub-class. Spell, Heal::Spell, and Hero;   Spell is a friend class of Hero and Heal is a subclass of Spell. I need Heal to be able to make changes to a Hero object, so I am wanting to pass a pointer to the Hero object to the Heal constructor.    If someone can help me with this I would be so grateful! I will include my code, so far.   classes.h Spell { public:      // code private:      Hero &hero; }   Heal(const Hero& h) { public:      // code protected:      // code }   classes.cpp Heal::Heal(const Hero& h): hero(h) {      //code } Thats basically what I have for the classes. Any clarification on how to fix this???  
  8. Nvm I fixed my issue with finding the angle between 2 objects and using it with SDL_RenderCopyEx();   Here is my function:   double find_angle(float x1, float x2, float y1, float y2) { double degrees;   // Get the angle between point (x1,y1) and (x2,y2) degrees = atan2(y2 - y1, x2 - x1) * 180/PI;   return degrees; }   and the call:   angle = find_angle(target.y, y, x, target. x);   Im not sure why its working since the variables are mixed up where they are supposed to be, but I kept trying them in different positions and its working,
  9. SDL2_ttf issues: Entry Point not found. Visual Studio

    Well the issue is fixed! I just came back to tell you thank you so much for all the help. I did have trouble compiling the .dll myself, so that is not what fixed it for me. I think what finally fixed it was just verifying that both libfreetype-6.dll and zlib.dll in my project folder. They both were, but I copied over them anyway and it works now.
  10. SDL2_ttf issues: Entry Point not found. Visual Studio

    C/C++: /ZI /nologo /W3 /WX- /Od /Oy- /D "_MBCS" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug\SDL2Tutorials.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue    Linker: /OUT:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.exe" /NOLOGO "SDL2.lib" "SDL2_image.lib" "SDL2_ttf.lib" "SDL2main.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" /MANIFEST /ManifestFile:"Debug\SDL2Tutorials.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.pdb" /SUBSYSTEM:CONSOLE /PGD:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 
  11. SDL2_ttf issues: Entry Point not found. Visual Studio

    I saw what you were saying about MinGW on google, but Im not using it. Im using Visual Studio 2010. I do have the libfreetype.dll file in the project folder. Its the one that came with SDL2. I made a new project so that I could go through linking everything again, and its doing the same thing. I need to use text in my game, so I'm going to have to fix this eventually.
  12. I have been working on a game using SDL but recently decided to switch to SDL2. I've been going over the examples for SDL2 on LazyFoo but there isn't really any documentation, just code. I got to the ttf examples yesterday. The first basic one worked yesterday. Today, I got to another example that uses ttf and it's giving me an error. I tried the first one again and I'm getting the same error. I have no idea what is going on. I have searched on google to try to fix it but I havn't found anything helpful. The error is:   Entry Point not found The procedure entry point InterLockedCompareExchange@12 could not be located in the dynamic link library libfreetype-6.dll    
  13. OpenGL and Spritesheets (2D game)

    I have been working on a 2D game using SDL for a while now and got to a point where I felt OpenGL would be needed for rotating sprites. I have been trying to learn it to get it implemented into the game, and I am having some trouble. What I am mainly wondering right now, is the best method of using sprites. Is it still best practice to have all my sprites on one sheet for multiple objects? Or have a separate sheet for each object.    Thank you!
  14. I'm working on a game in SDL and C++ with RPG aspects, such as stats, and gear. What I am confused about is how to implement so many different types of gear with different stats. Such as , should each different type of item be a new object in the programming, or should is it somehow possible to create a database I can use and update at later times when I want to add new items to the game. I've also heard about scripting and XML but I am just not sure where to go with this. (I'm still pretty new to all this, all I've done so far is Blackjack, tetris, and pong.)   Basically I just need a way to describe an item. Give it a name, what type of clothing it is(head piece, gloves, etc.), and what stat changes it provides. Then in the game be able to grab the information and use it to alter the player's stats.    If someone can point me in the right direction I'm sure I can figure out some way to implement this properly.  This is my first original game idea and I'm still in the planning stages really. Thank you for any advice and help!
  15. multiply defined symbols found

    I'm doing my first project with multiple files and I'm having trouble for some reason. I used the example for multiple source files lazyfoo.net has and while it did help ease my confusion somewhat, I am still getting errors: 1>Pong.obj : error LNK2005: "struct SDL_Surface * sScreen" (?sScreen@@3PAUSDL_Surface@@A) already defined in Functions.obj 1>Pong.obj : error LNK2005: "int const SCREEN_WIDTH" (?SCREEN_WIDTH@@3HB) already defined in Functions.obj 1>Pong.obj : error LNK2005: "int const SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3HB) already defined in Functions.obj 1>Pong.obj : error LNK2005: "int const SCREEN_BPP" (?SCREEN_BPP@@3HB) already defined in Functions.obj 1>Pong.obj : error LNK2005: "struct SDL_Surface * pongSprites" (?pongSprites@@3PAUSDL_Surface@@A) already defined in Functions.obj 1>C:\Users\Brandon\Documents\Visual Studio 2010\Projects\Pong\Release\Pong.exe : fatal error LNK1169: one or more multiply defined symbols found Pong.cpp [CODE] #include "Functions.h" #include "Globals.h" #pragma region Main int main(int argc, char* argv[]) { #pragma region Setup //Quit flag bool quit = false; #pragma endregion Setup #pragma region Game Logic //While the user hasn't quit while( quit == false ) { //While there's events to handle while( SDL_PollEvent( &event )) { //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } #pragma endregion Game Logic #pragma region Rendering SDL_FillRect(sScreen,NULL, 0x000000); //Update Screen SDL_Flip( sScreen ); #pragma endregion Rendering } return 0; } #pragma endregion Main [/CODE] Globals.h [CODE] #ifndef GLOBALS_H #define GLOBALS_H #include "SDL.h" #include "SDL_image.h" extern SDL_Surface* sScreen = NULL; extern const int SCREEN_HEIGHT = 700; extern const int SCREEN_WIDTH = 600; extern const int SCREEN_BPP = 32; extern SDL_Event event; extern SDL_Surface* pongSprites = NULL; #endif [/CODE] Functions.h [CODE] #ifndef FUNCTIONS_H #define FUNCTIONS_H #include "SDL.h" #include "SDL_image.h" #include <string> bool init(); SDL_Surface *load_image( std::string filename ); void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* block ); bool load_files(); #endif [/CODE] Functions.cpp [CODE] #include "Functions.h" #include "SDL.h" #include "SDL_image.h" #include "Globals.h" #include <string> #pragma region Init bool init() { //Initialize all SDL subsystems if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return false; } //Set up the screen sScreen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE ); //If there was an error in setting up the screen if( sScreen == NULL ) { return false; } //Set the window caption SDL_WM_SetCaption( "Pong", NULL ); //If everything initialized fine return true; } #pragma endregion Init #pragma region Load_image //------------------------------------------------- SDL_Surface *load_image( std::string filename ) { //The image that's loaded SDL_Surface* loadedImage = NULL; //The optimized surface that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = IMG_Load( filename.c_str() ); //If the image loaded if( loadedImage != NULL ) { //Create an optimized surface optimizedImage = SDL_DisplayFormat( loadedImage ); //Free the old surface SDL_FreeSurface( loadedImage ); //If the surface was optimized if( optimizedImage != NULL ) { //Color key surface SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) ); } } //Return the optimized surface return optimizedImage; } //------------------------------------------------- #pragma endregion Load_image #pragma region Load_Files bool load_files() { pongSprites = load_image("pong.png"); if(pongSprites != NULL) return true; else return false; } #pragma endregion Load_Files #pragma region Apply_Surface void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* block ) { //Holds offsets SDL_Rect offset; //Get offsets offset.x = x; offset.y = y; //Blit SDL_BlitSurface( source, block, destination, &offset ); } #pragma endregion Apply_Surface [/CODE] Thank you for any help in getting over this next obstacle, I do appreciate it.