| Poster | : jbaisden | | Posts | : 1 | | Country | : usa | | City | : Brandon |
| | | | Posted by jbaisden on 06/09/2008 at 10:46:32
| |
Okay, so I've got the 2d tutorial working...well, everything except the last part. I'm getting some wierd error...No matter, that's not why I'm writing.
I'm curious how to remove the old smoke trail from the rocket. Right now, it sort of paints the screen like brush would in Paint. Realistically, the smoke would dissipate after a little while. I'm fine with just removing old smoke trails after so many draws...
Is there a way to simply remove a drawn texture? I'm just getting my feet wet here, but could we just keep an array of all drawn smoke positions and remove those after so many draws...or perhaps after a second...?
Any ideas here would be helpful. | |
|
|
| |
| |
| Poster | : jasonbarry | | Posts | : 21 | | Country | : USA | | City | : Ringgold |
| | | | Posted by jasonbarry on 07/09/2008 at 10:57:06
| | | You don't remove a drawn texture from the screen, you would just not draw the texture when the Draw method is called. The positions to draw the smoke texture is stored in smokeList. When you go to add some positions in the List, you could remove some of the positions at the beginning so that it would give it the effect that the smoke disappears. | |
|
|
| |
| |
| Poster | : m_Maky | | Posts | : 67 | | Country | : france | | City | : Nice |
| | | | Posted by m_Maky on 07/09/2008 at 15:18:38
| | what you are describing here is a particle engine. riemer promised a particle engine to handle the explosions, so things like this might be covered there.
i'm just wondering when the next parts of the series will be posted, as it's already been a few days since the last chapter ... not that i'm complaining ;) | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 01/02/2009 at 17:41:27
| | Create two bool variable, enableSmoke and smokeIsEnough.
Now in update methom, put a if((rocketflying)||(smokeIsEnough)) for call update rocket.
inside the rocket update Put the lis.remove.... of list class, but only if smokeIsEnough = true.
smokeIsEnough on top of game1 Class = false , change to true when draw the smoke.
EnableSmoke on top of game1 class = false, change to true when the positionrefresh of rocket in updaterocket() and arctangent is seted (when the rocket has been moved) and draw the smoke under condition if(enableSmoke) here in my pc, the smoke draw on xtreme left if the rocket isnt launched (cuz I put rocketflying=false if it get out of screen and only launched if !rocketflying).
if((rocketflying)||(smokeIsEnough)) for call update rocket. : this two conditions is needed cuz only rocketflying: rocket out the screen, rocketflying = false; THE SMOKE STOPS THE REMOVE!!AND CONTINUES ONLY IF YOU SHOT OTHER ROCKET!! and that isn't realistic
In my work I do some more. if list.count()>50 remove (randomizer(50)) if list.count()>100 remove(ra...(100) and so on, this make more smokes be removed when there are more.
Sorry if I became you confused, but this is my way of think. | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 14/02/2009 at 09:26:35
| | just add int n at the beginning and n++ in the update rocket() for cycle and
if (n > 500)
{
smokelist.RemoveRange(0, 5);
}
at the begging of drawrocket()
| |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 27/01/2010 at 18:33:57
| | | Just use smokeList.Count() instead of n in the above code. It is much cleaner. | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 03/07/2012 at 14:59:01
| | I created this:
smokeList.Add(smokePos);
smokeList.TrimExcess();
if (smokeList.Count > 0)
currentSmoke = smokeList.First<Vector2>();
if (smokeList.Count > 20 && smokeList.Any())
smokeList.Remove(currentSmoke);
}
if (!rocketFlying)
if (smokeList.Count > 0)
smokeList.Remove(smokeList.First<Vector2>());
if (rocketPosition.X < 0 || rocketPosition.X > screenWidth || rocketPosition.Y > screenHeight)
rocketFlying = false;
It adds up to 21 smoke sprites, then removes the oldest ones, making the trail follow the rocket but not stay. It also allows the trail to "follow" the rocket off the screen, even though no new sprites are being drawn. | |
|
|