Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
So, I'm trying to make meteor using this code (worldh is world height):
if (b == 204)
{
for (int i = 0; i < worldh - y; ++i)
{
con.Send(editkey, 0, x, y + i + 1, 203);
Thread.Sleep(10);
con.Send(editkey, 0, x, y + i, 368);
Thread.Sleep(10);
con.Send(editkey, 0, x, y + i, 0);
Thread.Sleep(10);
}//for
}//if
I thought it works properly... until i placed more than 1 meteors.
The question is: how to make many meteors fall at the same time?
Offline
You can do this by multithreading.
Tutorial: https://www.youtube.com/watch?v=8mjqXiggWNc
Offline
Hmm.. Are there any ways to multithread in console application?
Offline
yup basicly the same as in a windows form
if you can read this....good for you
Offline
async tasks might be a possible solution, too..
//TODO implement b, x, y, worldh etc.
static void Main(){
Meteor();
Meteor();
}
static async void Meteor(){
if (b == 204){
for (int i = 0; i < worldh - y; ++i){
con.Send(editkey, 0, x, y + i + 1, 203);
await Task.Delay(10);
con.Send(editkey, 0, x, y + i, 368);
await Task.Delay(10);
con.Send(editkey, 0, x, y + i, 0);
await Task.Delay(10);
}//for
}//if
}
Note: I code in Vb.NET - can't gurantee this is even working and doing what you want..
Offline
async & await Should do fine.
Though, you can try using
ThreadPool.QueueUserWorkItem(delegate{/*Do stuff.*/});
// Unless it's in a void, at which case you'd want to replace the delegate with the void's name.
ThreadPool.QueueUserWorkItem(Meteor());
It's best to use async & await though, unless you have an old visual studio.
So mylo's code would do it.
Offline
Pages: 1
[ Started around 1732677578.2117 - Generated in 0.072 seconds, 10 queries executed - Memory usage: 1.45 MiB (Peak: 1.57 MiB) ]