Sign in to follow this  
Sourabh Pradhan

Rendering objects to screen at different time intervals

Recommended Posts

What you want to achieve is definitely possible, but it's important to realise that Direct3D only allows you to create the final image - the simulation is still entirely down to you. When and where you put the individual parts of the image is defined by you...

It will be hard for any of us to explain this to you as, well, your question covers everything and nothing - have you tried reading through any tutorials? Have you looked at the SDK samples? Are there any specific parts you don't understand and need further help on?


Share this post

Link to post
Share on other sites
Well the game idea is something like this: The player would be in the centre fixed position. The target object which could be a balloon would keep popping up in any position around the player. The object would be displayed for a few seconds during which the player would have to shoot. After the time interval, the object would be rendered to a different position on the screen ( or the 3d world ).
I want to know how to go about rendering the object at various positions at diff time intervals.

Share this post

Link to post
Share on other sites
Ok, but that's still a sufficiently vague description so we can't give you a technical answer to it.

Most D3D applications run in a tight loop rendering frames as fast as possible. You tend to have two parts to each frame - OnFrameMove() that updates any calculations and OnFrameRender() that actually sends the objects down the D3D pipeline to be displayed on screen.

In OnFrameMove() you'd use the timing information to check whether a balloon/target should be visible and where it is. This is nothing to do with Direct3D and is as simple or as complex as YOU want your simulation to be.

In OnFrameRender() you'd be configuring the pipeline and despatching a mesh to be rendered, or if you were happy with 2D then just rendering a simple sprite.

How experienced are you with Direct3D? Is this your first project, or have you done (3D) graphics before? What else do you actually want to know - help us to help you! [smile]


Share this post

Link to post
Share on other sites
I think what you need to do first (if you have not already), is to get a program that draws your player, and draws the target object in a single pre-programmed position. Thus, the image would be static.

Once you've gotten to that stage, you'll need to set up some type of timing loop, that lets the rest of the program know how much time has passed, what the absolute time is, and so forth.

At that point, hopefully you'll be in a much better opportunity to see how to implement a moving target, or at least how to ask a more focused and directed question.

Being able to draw anything at all, and being able to track the time are really the two critical components that you need at the moment. Then it's just a matter of coordinating the two so that what is drawn is based off of what the time is in some way or another.

Share this post

Link to post
Share on other sites
My first thought is a sprite image that gets its position updated every x seconds before being taken off the screen and position in an entirely new area.


class CMySprite
// Holds the starting position
CVector StartPosition;
// Hides the Sprite ready for moving to a new location
// Show the Sprite
// Move the Sprite in a set direction and speed
Drift(float speed, float x, float y, float z);


Drift could then be called to update every scene whereas the Show and Hide would be called everytime a set timer is released. So I think a timer for the scene perhaps (I've seen that done in many examples) and a timer for the show/hide. Maybe this second timer could be a part of the sprite class and is initialised/updated etc in your main program. This way you could have more than 1 version of sprite running at the same time but at different intervals making the game harder as they player progresses.


CMySprite* sprite1;
CMySprite* sprite2;
sprite1 = new CMySprite(StartPos1, Interval1);
sprite2 = new CMySprite(StartPos2, Interval2);

Hopefully I've helped you progress your idea somewhat.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this