Aw, crap. I thought that just reserved 30 spaces.
Hmm. You're right, I was eventually intending on making them local. What should I do when they're local?
Type: Posts; User: Dondrei
Aw, crap. I thought that just reserved 30 spaces.
Hmm. You're right, I was eventually intending on making them local. What should I do when they're local?
Hmm, I have a new problem now, I was trying to switch from using a vector of Monsters to using a vector of pointers to the Monsters like matsp suggested, but it doesn't like it. What I had originally...
Oh, that makes sense.
Why would you want to de-const a const? Doesn't that defeat the purpose?
Cool, thanks.
What are the other kinds of casts used for? Pointers or something?
There are some pretty big gaps in my programming knowledge, one of them being casts. I was writing code like this:
int a, c;
float b;
a = 100;
b = 0.8;
c = a*b;
My compiler threw a...
Huh, so all those variables I've made ints and all the ones I've made signed ints are actually all the same? Now I feel like a dork. :P
I see... so why does vector.size() need a specialised...
Okay, I think I see the problem, I was thinking int was unsigned but apparently it defaults to signed. That threw me. If I put:
for (unsigned int i=0; i<MonsterList.size(); i++) {}
It doesn't...
Even if I change "int i" to "signed int i" I still get comparison of signed and unsigned integer expressions. All the example code I've seen just uses something like:
for(int i=0;i <...
Hmm, now I have an elementary question... I made a loop for the two drawimage calls:
for (int i=0; i<=1; i++) {
drawimage(block, 0, 0, MonsterList.at(i).spritew,...
Oh, looks like you all figured it out right after I posted :P
I'm planning to have different kinds of monsters, but Monster will be the base class, I think all the basic features of the monster...
Sorry... I'm a dork, I wasn't thinking clearly. The problem is that in my movement code I was still referring to Monster1 and Monster2, I should've changed that to MonsterList.at(0) and...
Gah... I think I figured it out. I went to copy more code across but then looking at it it occurred to me the monsters were assigned to the vector before I specified their positions. I pasted it just...
I have a class Monster for NPCs and so on in the game, and I want to create a vector containing all the currently active monsters. As they die or get spawned I figure I'll pushback or popback them in...
Oh right, that makes sense. I was assuming that because the logic was being used in the definition of a float, it would assume all the numbers in it were floats too.
So if I put (9.0/5) for...
I'm still very much a programming newbie, so maybe this all makes perfect sense but it wasn't the behaviour I was expecting. I wrote a Celsius to Fahrenheit converter to show someone the basics of...
I think I'll just separate with &&s, probably the simplest way.
Ah, that makes sense.
Oh, okay. So what does the <= operator do in that context?
Okay, this is a bit basic but I'm having a hard time Googling it so what the hey...
Does C++ accept logic tests like:
if (a <= x <= y) {}
Or do I have to keep writing it out as:
Yeah, my convention is basically just personal aesthetics at the moment, I should probably make it more consistent.
Heh, thanks for the link, I know exactly the sort of people it was talking...
Oh, I already had ==, I just got sloppy copying the code :P
Hmm, maybe I should pass Goblin to the function instead, that would make the most sense I think.
So if I make goblin and hero derived...
I'm trying to access a variable in a class from another class:
class hero (
public:
int xpos;
void Move();
);
class monster (
Oh, of course, the scope thingy.
That's great, thanks for your help.
Ah, thanks.
Hmm, I'm getting some kind of error if I use this.xpos, but if I put this->xpos it seems to work, is "this" actually a pointer?
Is there a way to change the global variable xpos...
If I have a class defined like this:
class Sprite {
public:
int xpos;
int ypos;
void move();
};
I don't think so, I'm just hitting Dev-C++'s normal compile & run button. The thing is I'm putting in "include SDL.h" and apparently it references inttypes.h, so that's why I'm getting the error.