Мое приложение продолжает падать на меня по любой причине. Я новичок в векторах, так что, скорее всего, что-то глупое с моей стороны.
#include <iostream>
#include <vector>
using namespace std;
class Projectile
{
private:
SDL_Surface *projectile;
void load();
public:
int count;
vector< int > c;
vector< vector< int > > p;
int positionX;
int positionY;
Projectile();
void newProjectile( int, int );
void drawCurrentState( SDL_Surface* );
};
...
...
void Projectile::newProjectile( int x, int y )
{
positionX = x;
positionY = y;
c.push_back( 10 );
c.push_back( 10 );
//p.push_back( c ); //trying to start off simple before i do multidimensional.
}
void Projectile::drawCurrentState( SDL_Surface* destination )
{
SDL_Rect offset;
offset.x = c[0]; //will eventually me the multidimensional p vector
offset.y = c[1]; //
SDL_BlitSurface( projectile, NULL, destination, &offset );
}
что именно я здесь делаю не так? Я сдвигаю назад два значения (будут x и y, после завершения тестирования), однако, кажется, что происходит сбой, когда он попадает в offset.x = c[0];
часть скрипта.
Я наверняка думал, что c [0] и c [1] должны быть равны 10. Любые предложения?