Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 17.03.2014, 12:51   #11
phomm
personality
Старожил
 
Аватар для phomm
 
Регистрация: 28.04.2009
Сообщений: 2,882
По умолчанию

Что значит рисовать таймер ? Зачем его вообще рисовать ? Таймер это генератор событий, в свете темы - событий изменения координат игровых объектов.

Проект когда уже приложите ? Отрывками очень неудобно читать тут что-то, тем более, что код оставляет желать лучшего, эти портянки надо разбивать на функции и/или классы.
phomm вне форума Ответить с цитированием
Старый 22.03.2014, 18:30   #12
mixon-21
Я только Учусь
Форумчанин
 
Аватар для mixon-21
 
Регистрация: 06.03.2013
Сообщений: 193
По умолчанию

Вот что у меня есть

Код:
using System;
using System.Threading;

namespace ПРОБА
	{
	class Program
		{
		static void Main( string[] args )
			{
			
			int x = 0;
			int y = 0;
			int y1 =22;
			int x1 = 0;
			int x2 = 0;
			int y2 = 0;
			ConsoleKeyInfo g;
			Console.CursorVisible = false;
			Class1 my = new Class1 ();
			y = 23;
		
				do
					{
					
						Console.SetCursorPosition ( x, y );
						my.show ();
						g = Console.ReadKey ( true );
						if( g.Key == ConsoleKey.RightArrow && x < 75 )
							{
							x++;
							}
						if( g.Key == ConsoleKey.LeftArrow && x > 0 )
							{
							x--;
							}
						Console.Clear ();
						y1 = 22;
						x1 = x;
						if( g.Key == ConsoleKey.NumPad5 && y1 > 0 )
							{
							 do
								{

								Console.BackgroundColor = ConsoleColor.Yellow;
								Console.Write ( "  " );
								x2++; Console.BackgroundColor = ConsoleColor.DarkGray;
								} while( x2 <= 39 ) ;
							do
								{
								Console.SetCursorPosition ( x1 + 2, y1 );
								Console.ForegroundColor = ConsoleColor.Red;
								Console.Write ( "|" );
								Console.ForegroundColor = ConsoleColor.DarkGray;

								y1 -= 1;

								} while( y1 > 0 );
							}
						
					} while( g.Key != ConsoleKey.Escape );

				
			}
		}
	}

Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ПРОБА
	{
	class Class1
		{
		private int vectorX;
		private int vectorY;
		public Class1()
			{
			}
		public Class1(int x,int y)
			{
			this.vectorX = x;
			this.vectorY = y;
			}
	public static Class1 operator ++	( Class1 x )
			{
			x.vectorX++;
			return x;
			}
		public void show()
			{
			Console.BackgroundColor = ConsoleColor.DarkGray;
			Console.ForegroundColor = ConsoleColor.DarkBlue;
			Console.Write ("__|__");
			Console.BackgroundColor = ConsoleColor.DarkGray;
			}
		}

			
}
mixon-21 вне форума Ответить с цитированием
Старый 31.03.2014, 12:24   #13
mixon-21
Я только Учусь
Форумчанин
 
Аватар для mixon-21
 
Регистрация: 06.03.2013
Сообщений: 193
По умолчанию

Код:
using System; 
using System.Threading;

namespace ПРОБА
	{
	class Program
		{
		static void Main( string[] args )
			{
			
			int x = 35,zet=75;
			int y = 0;
			int y1 =22;
			int x1 = 0;
			int x2 = 0,x3;
			int y2 = 2,y3;
			ConsoleKeyInfo g;
			Console.CursorVisible = false;
			Class1 my = new Class1 ();
			y = 23;
           
                for (int i = 0; i < 1; i++)
                {
                    do
                    {
                        Console.SetCursorPosition(x, y);
                        my.show();
                        g = Console.ReadKey(true);
                        if (g.Key == ConsoleKey.RightArrow && x < 75)
                        {
                            x++;
                        }
                        if (g.Key == ConsoleKey.LeftArrow && x > 0)
                        {
                            x--;
                        }
                        Console.Clear();
                        y1 = 22;
                        x1 = x;
                        if (g.Key == ConsoleKey.NumPad5 && y1 > 0)
                        {
 
                                {
                            do
                            {
                              	    if (x2 <= zet)
                                    if (((x2 == x) & (y2 == y1)) | ((x2 - 1 == x) & (y2 == y1)) | ((x2 + 2 == x) & (y2 == y1)) | ((x2 + 1 == x) & (y2 == y1)))
                                    {
                                        Console.Clear();
                                        x3 = 33;
                                        y3 = 12;
                                        Console.SetCursorPosition(x3, y3);

                                        Console.ForegroundColor = ConsoleColor.DarkRed;
                                        Console.WriteLine("You win");
                                        Console.BackgroundColor = ConsoleColor.White;
                                        break;
                                    }
                                    else
                                    {
                                        Console.SetCursorPosition(x2, y2);
                                        Console.BackgroundColor = ConsoleColor.DarkGreen;
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.Write("    ");
                                        Console.BackgroundColor = ConsoleColor.DarkGray;
                                        x2 += 1; Thread.Sleep(200);
                                        Console.Clear();
                                        Console.SetCursorPosition(x1 + 2, y1);
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.Write('|');
                                        Console.ForegroundColor = ConsoleColor.DarkGray;
                                        y1 -= 1;
                                        Console.SetCursorPosition(x, y);
                                        my.show(); Console.BackgroundColor = ConsoleColor.White;
                                    }
										else
                                {
                                    Console.WriteLine("Game over");
                                    break;
                                }

                              
                            } while (y1 > 0);  }
                                
                        }
                    } while (g.Key != ConsoleKey.Escape);
                }
           
			}
		}
	}
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ПРОБА
	{
	class Class1
		{
		private int vectorX;
		private int vectorY;
		public Class1()
			{
			}
		public Class1(int x,int y)
			{
			this.vectorX = x;
			this.vectorY = y;
			}
	public static Class1 operator ++	( Class1 x )
			{
			x.vectorX++;
			return x;
			}
		public void show()
			{
			Console.BackgroundColor = ConsoleColor.DarkGray;
			Console.ForegroundColor = ConsoleColor.DarkBlue;
			Console.Write ("__|__");
			Console.BackgroundColor = ConsoleColor.DarkGray;
			}
		}

			
}
Вот что требовалось решить.

Последний раз редактировалось mixon-21; 31.03.2014 в 12:31.
mixon-21 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Как корабль назовешь, так он и поплывет? Alar Свободное общение 32 28.02.2014 22:27
Не уничтожается корабль helpkz Gamedev - cоздание игр: Unity, OpenGL, DirectX 7 15.05.2013 08:57
нарисовать движущийся корабль delphi Фари Мультимедиа в Delphi 4 04.04.2013 06:03
Робот-разведчик и космический корабль Ulq Паскаль, Turbo Pascal, PascalABC.NET 1 05.11.2011 21:03
Корабль в паскале Allemon Паскаль, Turbo Pascal, PascalABC.NET 0 23.12.2010 18:23