Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
- namespace SnakeV2
- {
- class RocksObject
- {
- public List<Point> List;
- Point Rock;
- Random rnd = new Random();
- public RocksObject(Point Food)
- {
- List = new List<Point>();
- refreshRocks(Food);
- }
- public void refreshRocks(Point Food)
- {
- List.Clear();
- for (int i = 0; i < 5; i++)
- {
- Rock = new Point(rnd.Next(2, Console.WindowHeight - 2), rnd.Next(2, Console.WindowWidth - 2));
- while (Rock.X == Food.X && Rock.Y == Food.Y)
- Rock = new Point(rnd.Next(2, Console.WindowHeight - 2), rnd.Next(2, Console.WindowWidth - 2));
- List.Add(Rock);
- }
- }
- public void Draw()
- {
- foreach (Point Rock in List)
- {
- Console.SetCursorPosition(Rock.Y, Rock.X);
- Console.Write('=');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement