Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DVDScreensaver
- {
- class Program
- {
- static void Main()
- {
- Console.Title = "lmoa";
- Screensaver.Start(120,30,new Screensaver.Pos(5,5));
- }
- }
- public class Screensaver
- {
- public static void Start(int maxX, int maxY, Pos startPos)
- {
- maxY = maxY > Console.LargestWindowHeight ? Console.LargestWindowHeight : maxY;
- maxX = maxX > Console.LargestWindowWidth ? Console.LargestWindowWidth : maxX;
- Console.WindowWidth = maxX;
- Console.WindowHeight = maxY;
- Console.BufferWidth = maxX;
- Console.BufferHeight = maxY;
- io.writeAt(50, 13, "Press enter to start");
- Console.ReadLine();
- var modifierX = 1;
- var modifierY = 1;
- var currentPos = startPos;
- while (true)
- {
- Console.Clear();
- if (currentPos[0] == maxX -1 || currentPos[0] == 0) modifierX *= -1;
- if (currentPos[1] == maxY -1 || currentPos[1] == 0) modifierY *= -1;
- io.writeAt(currentPos[0] + modifierX, currentPos[1] + modifierY,"X");
- currentPos[0] += modifierX;
- currentPos[1] += modifierY;
- System.Threading.Thread.Sleep(100);
- }
- }
- public class io
- {
- public static void writeAt(int x, int y, string v)
- {
- Console.CursorLeft = x;
- Console.CursorTop = y;
- Console.Write(v);
- }
- }
- public class Pos
- {
- private int PosX;
- private int PosY;
- public Pos(int x, int y)
- {
- PosX = x;
- PosY = y;
- }
- public int this[int index]
- {
- get
- {
- if (index == 0) return PosX;
- if (index == 1) return PosY;
- throw new Exception("whooops");
- }
- set {
- if (index == 0) PosX = value;
- if (index == 1) PosY = value;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement