Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Aug 2012
Offline Last Active Jan 29 2014 12:44 PM

Topics I've Started

Pass entire vector of objects to constructor by reference?

20 January 2014 - 09:53 PM

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.



class Star: public Spell
          Star(std::vector<Hero>& hero_list): h_list(hero_list) {}
          std::vector<Hero>& h_list;


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. 

Passing an object to constructor of another object? C++

10 January 2014 - 12:10 AM

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.
     // code
     Hero &hero;
Heal(const Hero& h)
     // code
     // code
Heal::Heal(const Hero& h): hero(h)
Thats basically what I have for the classes. Any clarification on how to fix this???

Finding angle between 2 objects * SDL_RenderCopyEx

05 December 2013 - 05:12 AM

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,

SDL2_ttf issues: Entry Point not found. Visual Studio

12 November 2013 - 02:07 AM

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

OpenGL and Spritesheets (2D game)

27 September 2013 - 11:49 AM

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!