|
C++ question [SOLVED!!!] June 25, 2009 08:30PM | Admin Registered: 17 years ago Posts: 5,132 |
int MaxNumber = 1;
int NumberArray[MaxNumber];
...
int main(){
...
std::cin >> MaxNumber;
...
NumberArray[4] = 16;
}|
Re: C++ question June 25, 2009 09:29PM | Registered: 17 years ago Posts: 384 |
|
Re: C++ question June 25, 2009 09:30PM | Registered: 17 years ago Posts: 91 |
|
Re: C++ question June 25, 2009 09:59PM | Admin Registered: 17 years ago Posts: 5,132 |
|
Re: C++ question June 25, 2009 10:08PM | Registered: 17 years ago Posts: 91 |
|
Re: C++ question June 25, 2009 10:29PM | Registered: 17 years ago Posts: 1,012 |
|
Re: C++ question June 26, 2009 02:20PM | Admin Registered: 17 years ago Posts: 5,132 |
//This file prototypes a simple Sprite class for ALLEGRO
class Sprite{
public:
//Constructor
Sprite();
//Destructor
~Sprite();
//Class Functions
void SetBITMAP(BITMAP *bitmaptoset, int width, int height);//Sets a single-framed BITMAP to represent a Sprite
void SetBITMAP(BITMAP *bitmaptoset, int width, int height, int columns, int framenumber);//Sets a multi-framed BITMAP to represent a Sprite
void Draw(BITMAP *backbuffer);//Draws the BITMAP set to the Sprite
void Draw(BITMAP *backbuffer, int transform);//Same as the first Draw, except the integer param specifies a transformation(1-Horiz, 2-Vert)
void JumpFrame(int frame);//Change to a different frame
void NextFrame();//Sets to the next frame of the assigned BITMAP
void PrevFrame();//Sets to the previous fram of the assigned BITMAP
bool CollidesWith(Sprite *spritetocollidewith);//Checks to see if one sprite collides with another
bool CollidesWith(int Mouse_X, int Mouse_Y, int Mouse_Width, int Mouse_Height);//Checks to see if a Sprite collides with the mouse
//Callbacks
int GetWidth();
int GetHeight();
//Variables
int X;//X value on a 2D plane
int Y;//Y value on a 2D plane
protected:
int SpriteMaxFrame;
BITMAP *SpriteBITMAP[SpriteMaxFrame];//BITMAP assigned to Sprite <--Works perfectly when I have a number replace "SpriteMaxFrame"
int SpriteWidth;//Width value of each frame in a BITMAP
int SpriteHeight;//Height value of each frame in a BITMAP
int SpriteFrame;//What frame the Sprite is on
};|
Re: C++ question June 26, 2009 09:31PM | Admin Registered: 17 years ago Posts: 5,132 |
|
Re: C++ question [SOLVED!!!] June 27, 2009 07:01PM | Registered: 17 years ago Posts: 384 |
|
Re: C++ question [SOLVED!!!] June 27, 2009 07:08PM | Admin Registered: 17 years ago Posts: 5,132 |
|
Re: C++ question [SOLVED!!!] June 27, 2009 07:14PM | Registered: 17 years ago Posts: 384 |
|
Re: C++ question [SOLVED!!!] July 07, 2009 06:56PM | Registered: 17 years ago Posts: 2 |
|
Re: C++ question [SOLVED!!!] July 12, 2009 07:03PM | Registered: 17 years ago Posts: 15 |
std::vector< int > resizableArray; // array of ints but who knows how many ints resizeableArray.push_back( 5 ); // increase size of the array by one, by adding the element 5 doSomethingWith( resizeableArray[ 0 ] ); // do something with 5
|
Re: C++ question [SOLVED!!!] July 13, 2009 08:02PM | Admin Registered: 17 years ago Posts: 5,132 |
|
Re: C++ question [SOLVED!!!] July 13, 2009 08:10PM | Registered: 17 years ago Posts: 1,012 |
|
Re: C++ question [SOLVED!!!] July 13, 2009 10:06PM | Admin Registered: 17 years ago Posts: 5,132 |
|
Re: C++ question [SOLVED!!!] July 13, 2009 10:24PM | Registered: 17 years ago Posts: 1,012 |
Quote
Arikado
I certainly don't want people who use my sprite class to have to hunt down a proper C++ Standard Library to be able to compile and run my platform independent programs on their OS. I think I'll keep my linked list.
|
Re: C++ question [SOLVED!!!] July 13, 2009 10:31PM | Admin Registered: 17 years ago Posts: 5,132 |
Well, since my code is dependent on a platform independent library not (yet?) designed to work on some of those platforms, it's probably best to stay with my platform independencies.Quote
daniel_c_wQuote
Arikado
I certainly don't want people who use my sprite class to have to hunt down a proper C++ Standard Library to be able to compile and run my platform independent programs on their OS. I think I'll keep my linked list.
Well, vector should be avaiable on the Wii (devkitPro / PPC), and is definitly part of all big linux and windows compiler suites.
And I bet, you would even have it on the iPhone.
Since the code is also not messy, I completely agree.Quote
daniel_c_w
But if your code works, there is no need to change it.
|
Re: C++ question [SOLVED!!!] July 15, 2009 06:28PM | Registered: 17 years ago Posts: 1,012 |