Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Oggman

Redraw

This topic is 5320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All, A very newbie question, so bare with me. For the sake of arguement I am building a Pong clone, its easy enought to get that ball bouncing around a screen, but what I want to a "trail" to follow it. The GIF I am using is a solid colour, and I just want a solid line to follow the ball. As this is my first stab at a game, I''m a little lost. Every game loop I am redrawing the background, then drawing the ball, so I can see 2 ways to do this, please correct me if I am wrong. 1) Don''t redraw the background, so the ball moving will create it''s own trails. 2) Rememeber every pixel the ball has been too and draw at those locations + the new location the ball is at. Am I simplifying this too much? Is there a third option? I''m using C# and Managed Dx, but this problem seems to be more of a design issue then anything else. Any help would be much appreciated. Cheers, Andrew

Share this post


Link to post
Share on other sites
Advertisement
Doh, totally misread your question. Heh.

I would use option 2. It is much higher level. Easier to control the length of the trails, etc. Presumably at some point you will want to erase the trails, have them blend into another color, etc. If, however, you want the trails to stay forever and nothing else is moving around or appearing and disappearing (ie like when you win at microsoft solitaire) 1 would be easier.

So option 3: fake it.
Instead of using the real past positions of the ball you might be able to project back along the balls velocity vector and create several trailing ball positions. These will not accurate unless the ball is moving in a straight line at constant speed, but it might run faster (though probably it would be slower) or be easier to code. This is a good way to make things like missile smoke, where the trail is fairly short and minor inaccuracies will not be noticed.


[edited by - JeffF on February 27, 2004 6:06:51 PM]

[edited by - JeffF on February 27, 2004 6:07:51 PM]

Share this post


Link to post
Share on other sites
to create a temporary trail you could use a sort of simple particle approach. For example, you could make a series of bitmaps that resemble the animation of a fading ball or line etc. create an object that each time it draws itself or after a certain amount of time it cycles down to the next animation frame and then destroys itself when it finishes the cycle. Each time the ball moves, create one of these particles in its last position. Usually these particles will end up in a linked list with the most recent particle being at the end so that newer particles are drawn on top of older particles in the drawing order. There are lots of ways to do this. I just outlined a simple way I have used in the past but you will find there are lots of ways to go about this as well as much cleaner and nicer ways.

Hope it helped a little anyway.



Evillive2
E-Mail

Share this post


Link to post
Share on other sites
I appreciate the replys. After I posted my question, I went about and tried it on my own. I tried my first method, and it worked fine in-so-much as the ball now has a trail that follows it around which is good. There could be some future issues with slow framerates causing a "staggered" trail, but this is such a simple game that I don''t see it ever being a problem.

Now my problem is collision detection. The only collision detection I''ve read about it BMP to BMP (is your ball hitting the paddle, etc.) not BMP to background colour. Considering the entire background is also a BMP, I''m kind of at a loss.

I guess a little more background might help. The game started out like breakout, but has kind of morphed into a Tron Lightbikes kind of thing, but with 6 balls on teh screen trying to cut everyone off.

Any help would be most appreciated


Cheers,
Andrew

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!