Jump to content
  • Advertisement

Mr N1nja

  • Content Count

  • Joined

  • Last visited

Community Reputation

111 Neutral

About Mr N1nja

  • Rank
  1. Mr N1nja

    Getting a variable inside a loop

    ah i get you now, so if i had my character stored away in an array with already stated x and y coords, array[i]->moveby();is above what i would be after in order to move the values already given?
  2. Mr N1nja

    Getting a variable inside a loop

    I'm trying to call my moveBy function from my character cpp file. This is my .h   class Character { protected: int x, y; // co-ordinate positions public: Character(int start_x, int start_y); virtual void print(); void moveBy(); };my c++ file function   void Character::moveBy() { cout << "called function" << endl; }my main c++ file trying to call the function in the main int _tmain(int argc, _TCHAR* argv[]){ Character moveBy(); exit(); return 0; }That receives no errors however it doesn't call my moveBy function, so just wondering how i would call this
  3. Mr N1nja

    Getting a variable inside a loop

    You are trying to create a new instance of Character. That is not possible because the only available constructor requires two parameters (for initializing the starting position). However, the core problem appears to be that you are unintentionally creating a new instance when that is not your intention and not useful to your cause. You really need to post more code for anyone to really help you though. Didn't even realize that sorry! Yeah i've changed it no errors at the moment its just not calling the function, I'll try to figure it out first before asking for help.
  4. Mr N1nja

    Getting a variable inside a loop

    Yeah i have passed them to the character class, but i'm struggling on how i would call that character's x and y coords EDIT: also r and c both = 10 EDIT: well no, what i mean is i have the x and y in character class, by doing this Character::Character(int start_x, int start_y){ x = start_x; y = start_y; } void Character::print() { cout << "\n" << "Character Position: " << "xPos " << x << " yPos " << y << endl; }But the problem i'm having now is when i'm trying to call my moveBy() function which is also in the character class, it gives me this error 'Character' : no appropriate default constructor available. Character character;I've called other functions from classes before so i'm not sure why this is.
  5. I know that once the loop is finished the variable is destroyed meaning you can't get the value once the loop has finished, however is there a way to do this? I want to keep the variable and change it.   // x coord x = character_location / r; // y coord y = character_location % c; //this creates 1 character clist[0] = new Character(x, y); I want to be able to call x and y inside another function which will allow me to move the character say +- 1 units. Any help would be appreciated .
  6. Would this set them in my 10x10 matrix and not just give me an x and y co-ord between 0-10? I have just played a bout with it and it does give me random co-ords thanks a lot of that little bit of help with random include
  7. Hi there, I've created a 10x10 matrix class, which is 10x10. The 2d world is invisible as its going to act as a co-ordinate system, so rows and columns. I've created a character and monster class but what the problem i am having is thinking of how i place my created character or monster into a random row and column on the matrix, // A test function to fill a MatrixM object with random numbers void Matrix(MatrixM *m, int r, int c) { int count = 0; //r = row, c = column for (int i = 0; i<r; i++) { for (int j = 0; j<c; j++) { //this just fills the 10x10 matrix with random numbers ( i want it to fill with 10 monsters randomly) m->set(i, j, rand() % 10); //m->set(i, j, count++); } } /* THIS OBVIOUSLY ATM JUST STATES THEY ARE IN R10 C10 AS ITS NOT ACTUALLY PLACING THEM IN THE MATRIX?*/ Monster* mlist[10]; //give the monsters random co-ords mlist[0] = new Monster(r, c); mlist[1] = new Monster(r, c); mlist[2] = new Monster(r, c); mlist[3] = new Monster(r, c); mlist[4] = new Monster(r, c); mlist[5] = new Monster(r, c); mlist[6] = new Monster(r, c); mlist[7] = new Monster(r, c); mlist[8] = new Monster(r, c); mlist[9] = new Monster(r, c); // print out the characters starting co-ordinates for (int i = 0; i < 10; i++) { mlist->print(); } EDIT: i was thinking something like this row = m->get(i, 0); column = m->get(0,j); but how would i make it randomly pick a row and column
  8. for (int i = 5; i < 7; i++) { GeometryActor* base = new GeometryActor(); base->SetColor(Vector4f(0, 0.25, 0.25, 1)); base->DrawCylinder(Vector3f(0.0f,-12.0f,0.0f), Vector3f(0.0f, 12.0f, 0.0f), 12, 12); base->UseSolidMaterial();   }   //base 1 this->_objects[5]->GetNode()->Position() = Vector3f(0.0f, 0.0f, -200.0f); this->_objects[5]->GetNode()->Scale() = Vector3f(0.5f,0.5f, 1.0f); this->_objects[5]->GetNode()->Rotation().RotationZYX(Vector3f(0.0f, 0.0f, 0.0f));     why does this only create half of the cylinder, can anyone help please?  
  9. Where can i find the mouse header files? I'm struggling to understand what calculation needs to be made, could you produce any psuedo code for me to follow?
  10. Hey there, I'm currently making a game using DirectX11 with c++ I've managed to create key inputs to move the camera, forward,backwards,left,right,up,down. However i'm struggling with making the mouse control. I need to use the mouse to view which direction the camera is facing. So it doesn't need clicks its just whichever way you move the mouse with the cursor, the camera will follow.   Had no luck so far.   Any pointers or help would be appreciated thanks
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!