static void Main() { Random r = new Random(); AnimatedSprite[] aniSpr = new AnimatedSprite[10]; int hei = r.Next(0, 25); int wit = r.Next(3, 78); aniSpr[0] = new GoldFish(wit, hei); hei = r.Next(0, 25); wit = r.Next(3, 78); aniSpr[1] = new Fish(wit, hei); hei = r.Next(0, 25); wit = r.Next(3, 78); aniSpr[2] = new RapeFish(wit, hei); hei = r.Next(0, 25); wit = r.Next(3, 78); aniSpr[3] = new SwordFish(wit, hei); hei = r.Next(0, 25); wit = r.Next(3, 78); aniSpr[4] = new SharkFish(wit, hei); for (int i = 5; i < 10; i++) { aniSpr[i] = new Bubble(r.Next(0, 81), r.Next(0, 20)); } while (true) { Console.Clear(); for (int i = 0; i < 10; i++) { aniSpr[i].Draw(); } for (int i = 0; i < 10; i++) { aniSpr[i].Move(); } Thread.Sleep(100); // 100 ms pause } }
static void Main() { // Initialization bool fullScreen = false; Hardware hard = new Hardware(800, 600, 24, fullScreen); // Creation of elements Image background = new Image("Images/back.jpg", 800, 600); Random r = new Random(); AnimatedSprite[] aniSpr = new AnimatedSprite[10]; short y = (short)r.Next(0, 700); short x = (short)r.Next(10, 500); aniSpr[0] = new GoldFish(x, y); y = (short)r.Next(0, 700); x = (short)r.Next(10, 500); aniSpr[1] = new GoldFish(x, y); y = (short)r.Next(0, 700); x = (short)r.Next(10, 500); aniSpr[2] = new RapeFish(x, y); y = (short)r.Next(0, 700); x = (short)r.Next(10, 500); aniSpr[3] = new SwordFish(x, y); y = (short)r.Next(0, 700); x = (short)r.Next(10, 500); aniSpr[4] = new SharkFish(x, y); for (int i = 5; i < 10; i++) { aniSpr[i] = new Bubble( (short)r.Next(0, 700), (short)r.Next(0, 500)); } bool finished = false; while (!finished) { // Drawing elements hard.ClearScreen(); hard.DrawImage(background); for (int i = 0; i < 10; i++) { aniSpr[i].Draw(hard); } hard.UpdateScreen(); // Moving elements to ttheir next position for (int i = 0; i < 10; i++) { aniSpr[i].Move(); } // Checking input devices if (hard.IsKeyPressed(Hardware.KEY_ESC)) { finished = true; } // And pausing after each frame Thread.Sleep(100); // 100 ms pause } }