I did a parent class of all classes in my C# program, and I would like make a loop through them, but I don’t know how?
Is it possible with a foreach loop?
Here is my code:
class GameElements
{
public int xplace,yplace;
}
class Player: GameElements
{
public Bitmap itsimage;
public byte animtimer=5;
}
class Bullets: GameElements
{
public Bitmap itsimage;
}
class Enemies: GameElements
{
public int dirx,diry;
public Bitmap itsimage;
public byte animtimer=5;
}
And I tried iterate through them, but this is not good:
void MainFormResize(object sender, EventArgs e)
{
foreach (var agameelement in GameElements) {
agameelement.xhely*=Width/newwwidth;
agameelement.yhely*=Height/newwheight;
}
}