Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Sep 2008
    Posts
    21

    VTM Complete Source?

    Hey I'm wondering if there's a place to download the completed source from VTM3. I am working on the last part of VTM3_08 and I get no compilation errors, but when I run my program it crashes. I went into debug mode to step through the code and it crashes right at:

    Code:
    vector Sprite::getPosition(void)
    {
    	return pos;
    }
    Right as the arrow is pointing to return pos; with this message:

    Unhandled exception at 0x01307f26 in MyGame.exe: 0xC0000005: Access violation reading location 0xccccccd8.
    I went back through the lessons to see if I missed anything (like I've done many times so far ) but I haven't caught my mistake. In lesson 8 there are so many changes that I'm thinking I might have just missed one little thing that's caused a chain reaction.

    Is there any way I can get a copy of the source code to compare mine with? I was pretty surprised when I bought the DVD and it didn't come with any source code, resource files, etc.

  2. #2
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    Perhaps you can get somebody here to send you their cope stumps for that part.
    But as i understand it the main reason you dont get complete source code is to make sure you will be learning rather than copying.
    Alot of people will be able to edit existing code, but you will not really learn it untill you type for yourself.

    Hmm im no C++ guy expert, but try returning null or something instead see if that works. If it does the problem lies with what you are trying to return, so look into what there might be of issues there
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  3. #3
    Join Date
    Nov 2007
    Posts
    8
    yep...screams of unitialized pointer. Might want to set up a watch on pos and make sure it gets initialized.

  4. #4
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    Bit off topic: I often notice people saying to debug they went through all the VTM's to see if they made a mistake. Thats not a bad idea, though i would reccomend (not that i am a coding guru or anything) to actually stop, slow down and think about the error and try some things before spending time re-watchig the videos as such. Just think logically about it, and experiment for 10 minutes (love experimenting). If that doesnt give you clues, try explaining the problem to somebody else... maybe that wont work for you but for me i frequently have a "house" moment were i realise the fault and subsequently stop talking and start fixing leaving my 'audience' a little confused
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  5. #5
    Join Date
    Jan 2004
    Location
    Kemptville, Ontario
    Posts
    6,242
    Swoop is correct 3DBuzz does not and will not provide source code. They firmly believe that the best way to learn is to do even if that means debugging code.

    So seeing your post I will assume that didn't work so you did the next logical thing and asked. Which is what Buzz wants you to do. Trust me you will find the problem with the help of the good people here and you will learn something out of the process.
    I have figured out what the internet is. You know what they say about an infinite number of monkeys hitting keys at random on an infinite number of typewriters for an infinite amount of time? Well the internet is like that. There is some big cosmic alien running that experiment here in order to find the answer to some big question or to create the greatest piece of literature known to the universe. From what I have seen so far I am sorry to say they are going to be greatly disappointed.

  6. #6
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by teromous View Post
    Hey I'm wondering if there's a place to download the completed source from VTM3. I am working on the last part of VTM3_08 and I get no compilation errors, but when I run my program it crashes. I went into debug mode to step through the code and it crashes right at:

    Code:
    vector Sprite::getPosition(void)
    {
    	return pos;
    }
    Right as the arrow is pointing to return pos; with this message:
    the problem is most probably that Sprite was not initialized correctly. take a look at the call stack window of your debugger. there should be a green arrow next to an entry reading Sprite:getPosition(). by double-clicking on the entry right below that one, you will jump to the callee of that function. you should be able to identify which object didn't get initialized and (hopefully) why.

    the debugger is one of the most powerful tools you have as a developer, so be sure to use it often and wisely!

  7. #7
    Join Date
    Sep 2008
    Posts
    21
    The first line inside the call stack when breaking is:

    > MyGame.exe!Sprite::getPosition() Line 31 + 0x3 bytes C++
    which gives:
    vector Sprite::getPosition(void)
    {
    return pos;
    }
    Then the one below that inside the call stack is:
    MyGame.exe!Enemy::simulateAI() Line 59 C++
    which gives:

    void Enemy::simulateAI(void)
    {
    vector goal_pos = goal->getPosition();
    vector direction;

    direction.x = goal_pos.x - pos.x;
    direction.y = goal_pos.y - pos.y;

    float mag = sqrt(direction.x * direction.x + direction.y *direction.y);

    direction.x = direction.x / mag;
    direction.y = direction.y / mag;

    if(!move(direction.x, direction.y))
    {
    while (!move(float(rand() % 3 - 1), float(rand() % 3 - 1))) // returns -1 0 and 1 ...uses float(...) to convert from int to float
    {
    }
    }
    }

    I looked at both of these blocks of code and to me it looks the same as the VTM, although I could just be missing something.

  8. #8
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    So, go back to the call just before that where its most liklely that the sprite you're calling doesnt exist yet.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  9. #9
    Join Date
    Sep 2008
    Posts
    21
    Code:
    	level = new Level(&drawArea, 30, 20);
    
    	drawArea.createBackgroundTile(TILE_EMPTY, ' ');
    	drawArea.createBackgroundTile(TILE_WALL, 219);
    
    	drawArea.createSprite(SPRITE_PLAYER, 1); // creates the evil monkey :D
    	drawArea.createSprite(SPRITE_ENEMY, '$');	level->draw();
    	level->addPlayer(player);
    
    	level->addEnemies(3);
    I wanted to see if addEnemies was doing anything, so I commented it out. Instead of the game crashing immediately like it did last time, it just sat there until I pressed a key and then it crashed.

    This time the call stack points to:
    Code:
    bool Level::keyPress(char c)
    {
    	if(player)
    		if(player->keyPress(c))
    			return true;
    	return false;
    }
    I'm still looking through everything though
    I'm looking for what might be related between the two different crash types.

  10. #10
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    I dont see you making an instance of player in that code.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •