XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

How would i go about adding in a 3d model after the draw method?

Last post 6/2/2009 2:10 PM by Craig Martin. 6 replies.
  • 6/1/2009 5:08 AM

    How would i go about adding in a 3d model after the draw method?

    Say i want 3d enimies to pop up at every 10 seconds how would i do this?

    I cant call them are update so any help?
  • 6/1/2009 5:24 AM In reply to

    Re: How would i go about adding in a 3d model after the draw method?


    // delay between spawns
    double spawnTimeInSeconds = 10.0;

    // current timer
    double spawnCounterInSeconds;

    void Update(GameTime gameTime)
    {
         // decrease timer by the amout of time passed since the last update call
         spawnCounterInSeconds -= gameTime.ElapsedGameTime.TotalSeconds;

         // if the timer is less than zero then 10 seconds of time has passed
         if (spawnCounterInSeconds <= 0.0)
         {
             // create a new enemy
             SpawnNewEnemy();

             // reset the timer to 10 seconds, ready to start counting down again for the next enemy spawn
             spawnCounterInSeconds = spawnTimeInSeconds;
         }
    }
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 6/1/2009 11:19 AM In reply to

    Re: How would i go about adding in a 3d model after the draw method?

    I was told you cant draw after the update method and you had to do device.Present or something???
    I put in device.present and the model just dissapears after 1 second!
  • 6/1/2009 11:32 AM In reply to

    Re: How would i go about adding in a 3d model after the draw method?

    Harminal:
    I was told you cant draw after the update method and you had to do device.Present or something???
    I put in device.present and the model just dissapears after 1 second!
    That has nothing to do with anything.

    Every frame, update runs, and draw runs. Put your game logic in the update function, and then draw whatever you need. In the draw function, loop through the array of enemies and draw all of them.
    return;
  • 6/2/2009 7:49 AM In reply to

    Re: How would i go about adding in a 3d model after the draw method?

    But whenever i do this the model does not appear.



    Im also told that when draw occurs it clears the screen. After that anything else drawn doesnt appear??True or false??
  • 6/2/2009 8:48 AM In reply to

    Re: How would i go about adding in a 3d model after the draw method?

    Harminal:
    Im also told that when draw occurs it clears the screen. After that anything else drawn doesnt appear??True or false??
    Your game is an endless loop of update and draw calls.

    Update runs, and you code anything you want to happen there.

    Draw is then called, and you draw everything that is occurring in your game state.

    The first call in the draw function is a call to clear the screen and the depth buffer. You can remove this call if you want, but you want the screen to be cleared most of the time before you start drawing new stuff. Especially the depth buffer.
    return;
  • 6/2/2009 2:10 PM In reply to

    Re: How would i go about adding in a 3d model after the draw method?

    Harminal:
    But whenever i do this the model does not appear.



    Im also told that when draw occurs it clears the screen. After that anything else drawn doesnt appear??True or false??



    Take a look as some of the beginner samples in the education section of this site. They will show you what to do and how it works.
    Game hobbyist hell-bent on coding a diabolical Matrix
Page 1 of 1 (7 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG