Показать сообщение отдельно
  #10  
Старый 08.04.2011, 14:09
KOTIUM KOTIUM вне форума
Прохожий
 
Регистрация: 07.04.2011
Сообщения: 8
Репутация: 10
По умолчанию

К сожалению это всё уже пробовал но не работает может я что не так делаю вот весь код от и до:
Код:
program Invaders;

uses
  OMEGA in 'headers\Delphi\OMEGA.pas',
  uSpriteEngine in 'units\Delphi\uSpriteEngine.pas',
  Player in 'Player.pas',
  Monster1 in 'Monster1.pas',
  Bullet in 'Bullet.pas',
  Boom in 'Boom.pas',
  GEngine in 'GEngine.pas',
  Res in 'Res.pas',
  uGUIEngine,
  Bullet2 in 'Bullet2.pas',
  Lan in 'Lan.pas',
  WinSock,
  Windows,
  Messages,
  unit1,
  moster1_bullet in 'moster1_bullet.pas',
  bullet3 in 'bullet3.pas',
  bullet4 in 'bullet4.pas',
  scktcomp,
  SysUtils,
  forms,
  Classes,
  Dialogs;

  type
  TServerSocketEvent = class
    procedure OnClientConnect(Sender: TObject; Socket: TCustomWinSocket);
  end;

var
  Process  : POTimer;
  Proc     : POTimer;
  full_scr : integer;
  id3,id4,id5      : integer;
  id4cl    : integer;
  id5cl    : integer;
    ServerSocket: TServerSocket;
  ClientSocket: TClientSocket;
   FServerSocket: TServerSocket;
  FServerSocketEvent: TServerSocketEvent;

  procedure TServerSocketEvent.OnClientConnect(Sender: TObject;
  Socket: TCustomWinSocket);
  var i:integer;
begin
  // собственно сам обработчик
i := GameEngine.AddNew;
GameEngine.PlayerID := i;
GameEngine.List[ i ] := TPlayer.Create;
GameEngine.List[ i ].ID := i;
end;

procedure SetFullScreen( Checked : Boolean; Sender, Parent : CGUIElement );
Begin
OE_ChangeScreenOptions( 1024, 768, 32, 0, Checked, FALSE );
End;



procedure MyButtonEventClick( mButton : Integer; Sender, Parent : CGUIElement );
var i : Integer;
Begin
if id4cl=0 then
begin
  FServerSocket:=TServerSocket.Create(nil);
  FServerSocketEvent:=TServerSocketEvent.Create;
  FServerSocket.OnClientConnect:=FServerSocketEvent.OnClientConnect;
  FServerSocket.ServerType:=stNonBlocking;
  FServerSocket.Port:=strtoint(( GUI.List[ id2 ] as CGUIedit ).Caption);
  FServerSocket.Active:=True;
( GUI.List[ id2 ] as CGUIedit ).Enabled:=false;
( GUI.List[ id3 ] as CGUIedit ).Enabled:=false;
( GUI.List[ id5 ] as CGUIButton ).Enabled:=false;
( GUI.List[ id4 ] as CGUIButton ).Caption:=('Остановить');
id4cl:=1;
end
else
begin
  FServerSocket.Active:=False;
  FServerSocketEvent.Free;
  ( GUI.List[ id2 ] as CGUIedit ).Enabled:=true;
( GUI.List[ id3 ] as CGUIedit ).Enabled:=true;
( GUI.List[ id5 ] as CGUIButton ).Enabled:=true;
( GUI.List[ id4 ] as CGUIButton ).Caption:=('Создать');
id4cl:=0;
end;
End;



procedure MyButtonEvent1Click( mButton : Integer; Sender, Parent : CGUIElement );
Begin
if id5cl=0 then
begin
( GUI.List[ id2 ] as CGUIedit ).Enabled:=false;
( GUI.List[ id3 ] as CGUIedit ).Enabled:=false;
( GUI.List[ id4 ] as CGUIButton ).Enabled:=false;
  ClientSocket:=TClientSocket.Create(nil);
  ClientSocket.ClientType:=ctNonBlocking;
  ClientSocket.Port:=strtoint(( GUI.List[ id2 ] as CGUIedit ).Caption);
  ClientSocket.Host:=( GUI.List[ id3 ] as CGUIedit ).Caption;
  ClientSocket.Address:=( GUI.List[ id3 ] as CGUIedit ).Caption;
  ClientSocket.Active:=True;
( GUI.List[ id5 ] as CGUIButton ).Caption:=('Отключится');
id5cl:=1;
end
else
begin
ClientSocket.Active:=False;
( GUI.List[ id2 ] as CGUIedit ).Enabled:=true;
( GUI.List[ id3 ] as CGUIedit ).Enabled:=true;
( GUI.List[ id4 ] as CGUIButton ).Enabled:=true;
( GUI.List[ id5 ] as CGUIButton ).Caption:=('Подключится');
id5cl:=0;
end;
End;



procedure MyButtonEvent2Click( mButton : Integer; Sender, Parent : CGUIElement );
Begin
if full_scr=0 then
begin
OE_ChangeScreenOptions( 1024, 768, 32, 0, true, FALSE );
( GUI.List[ id ] as CGUIButton ).Caption := 'В окне';
 full_scr:=1;
End
else
begin
OE_ChangeScreenOptions( 1024, 768, 32, 0, false, FALSE );
( GUI.List[ id ] as CGUIButton ).Caption := 'На весь экран';
 full_scr:=0;
end;
end;


procedure MyButtonEvent3Click( mButton : Integer; Sender, Parent : CGUIElement );
Begin
OE_Quit;
End;



procedure Init;
  var
    i : Integer;
Begin
// Загружаем все ресурсы
res_Load;
Mouse.Texture := tex_Mouse;
LastEnemyAdd := U_GetTime;
id3:=GUI.AddElement( CreateEdit( nil, nil, MyFont, 1, 500, 148, 20, '127.0.0.1') );
id2:=GUI.AddElement( CreateEdit( nil, nil, MyFont, 1, 530, 148, 20, '777' ) );
id4:=GUI.AddElement( CreateButton( nil, nil, MyFont, 'Создать', 1, 600, 148, 20, @MyButtonEventClick ) );
id5:=GUI.AddElement( CreateButton( nil, nil, MyFont, 'Подключится', 1, 630, 148, 20, @MyButtonEvent1Click ) );
id:=GUI.AddElement( CreateButton( nil, nil, MyFont, 'На весь экран', 1, 660, 148, 20, @MyButtonEvent2Click ) );

GUI.AddElement( CreateButton( nil, nil, MyFont, 'Выход', 1, 690, 148, 20, @MyButtonEvent3Click ) );
id1:=GUI.AddElement( CreateProgressBar( nil, nil, Font, 1, 30, 148, 10 ) );



// Инициализируем движок игры
GameEngine := TGameEngine.Create;
GameEngine.InvertSort := TRUE;
i := GameEngine.AddNew;
GameEngine.PlayerID := i;
GameEngine.List[ i ] := TPlayer.Create;
GameEngine.List[ i ].ID := i;

End;

procedure Draw;
Begin
SSprite_Draw( tex_BackGround, 150, 0, 1920, 1080 );
SSprite_Draw( tex_Left, 0, 0, 150, 768 );

// Рисуем инфу
{Text_Draw( Font, 1, 40, PChar( 'Жизнь: ' + Chr( 13 ) +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).Life ) + '%' ),
           1, 1, 255, $00FF00 );
Text_Draw( Font, 1, 110, PChar( 'Опыт: ' + Chr( 13 ) +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).Score ) +PChar( '/' +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).ul ) )),
           1, 1, 255, $FF0000 );
Text_Draw( Font, 1, 180, PChar( 'Энергия: ' + Chr( 13 ) +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).inergy )+PChar( '/' +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).uing ) )),
           1, 1, 255, $555555 );
Text_Draw( Font, 1, 250, PChar( 'Уровень: ' + Chr( 13 ) +
           U_IntToStr( ( GameEngine.List[ 0 ] as TPlayer ).lvl ) ),
           1, 1, 255, $990099 );}
Text_Draw( Font, 1, 0, PChar( 'FPS: ' + U_IntToStr( OE_GetFPS ) ) );

if GameEngine.GameOver Then
Text_Draw( Font, 500, 400, PChar( 'Вы проиграли!' + Chr( 13 ) ),
           1, 1, 255, $0000FF );
GameEngine.Draw;
// Рисуем весь GUI
GUI.Draw;
End;

procedure GameTimer;
Begin
GameEngine.Process;
gui.Process;
( GUI.List[ id1 ] as CGUIProgressBar ).Max := 400;
( GUI.List[ id1 ] as CGUIProgressBar ).Progress := OE_GetFPS;

if ( GUI.List[ id1 ] as CGUIProgressBar ).Progress > 290 then
( GUI.List[ id1 ] as CGUIProgressBar ).Color := 500;
if (( GUI.List[ id1 ] as CGUIProgressBar ).Progress < 290) and (( GUI.List[ id1 ] as CGUIProgressBar ).Progress > 240) then
( GUI.List[ id1 ] as CGUIProgressBar ).Color := $00FFFF;
if (( GUI.List[ id1 ] as CGUIProgressBar ).Progress < 240) and (( GUI.List[ id1 ] as CGUIProgressBar ).Progress > 0) then
( GUI.List[ id1 ] as CGUIProgressBar ).Color := $00FF00;

if Key_Down( K_ESCAPE ) Then OE_Quit;
// соберем данные для отправки
 { Buf[0]:=ShapeCBox.ItemIndex;
  Buf[1]:=ColorCBox.ItemIndex;
  Buf[2]:=StrToInt(Value1Edit.Text);
  Buf[3]:=StrToInt(Value2Edit.Text);}

End;
procedure GameTimer1;
Begin
if (GameEngine.List[ GameEngine.PlayerID ] as TPlayer ).inergy<(GameEngine.List[ GameEngine.PlayerID ] as TPlayer ).uing then (GameEngine.List[ GameEngine.PlayerID ] as TPlayer ).inergy:=(GameEngine.List[ GameEngine.PlayerID ] as TPlayer ).inergy+1;
End;



{ TServerSocket1 }



begin
LoadOMEGA( 'bin DX8\rus\OMEGA.dll' );



 Randomize;
 Process := Timer_Create( @GameTimer, 16 );
 Proc := Timer_Create( @GameTimer1, 560 );

//Установка параметров экрана
OE_SetScreenOptions( 1024, 768, 32, 0, false, false );

//Регистрация процедур
OE_RegProcedure( SYS_INIT, @Init );
OE_RegProcedure( SYS_DRAW, @Draw );

// Выключаем очистку буфера цвета для оптимизации
OE_Disable( FLAG_CLEAR_COLOR_BUFFER );
// Выключаем отрезку невидных обьектов, потому как все в пределах одного экрана
OE_Disable( FLAG_CROP_UNVISIBLE_OBJ );

OE_SetAdvancedOptions( TRUE ); //Включить движковый лог
OE_Init; // Запуск движка
end.
Ответить с цитированием