Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Net;
- namespace IMJunior
- {
- class GameObject
- {
- public int x;
- public int y;
- public char visual;
- public int speed;
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- GameObject go1 = new GameObject();
- go1.x = 10;
- go1.y = 10;
- go1.visual = '#';
- go1.speed = 10;
- GameObject go2 = new GameObject();
- go2.x = 15;
- go2.y = 25;
- go2.visual = '$';
- go2.speed = 1;
- GameObject[] gameObjects = { go1, go2 };
- while (true)
- {
- foreach (GameObject go in gameObjects)
- {
- Draw(go);
- MoveRight(go);
- }
- System.Threading.Thread.Sleep(500);
- Console.Clear();
- }
- //Console.SetCursorPosition(0, 50);
- }
- static void Draw(GameObject gameObject)
- {
- Console.SetCursorPosition(gameObject.x, gameObject.y);
- Console.Write(gameObject.visual);
- }
- static void MoveRight(GameObject gameObject)
- {
- if (gameObject.x < Console.WindowWidth - 10)
- {
- gameObject.x += gameObject.speed;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement