Тема: проект
Показать сообщение отдельно
Старый 29.12.2005, 22:57   #6
jimon
 
Сообщений: n/a
народ ! неправильно строим код !
смотреть на мой пример (крестики нолики без ai и пару недоработок)
+ я незделал то что midlet на паузу может уходить

program game1;
var

//midlet main varibales
 run:boolean;
 need_to_update:boolean;
 Midlet_reboot:boolean;

//game variables
 a:array[1..3,1..3] of integer; 
 buf1,buf2:integer; 
 winer:integer;

procedure Cls;
begin
	setcolor(255,255,255);
	fillRect(0, 0, 128, 128); 
	setcolor(0,0,0);
end;

procedure Midlet_update;
begin
	if Midlet_reboot=true then 
 begin
 for buf1:=1 to 3 do
 	for buf2:=1 to 3 do
  a[buf1,buf2]:=0;
 Midlet_reboot:=false;
 need_to_update:=true;
 end;

	repaint;	
	need_to_update:=false;
end;

procedure Graphics;
begin
	for buf1:=1 to 3 do
	for buf2:=1 to 3 do
	begin

	drawline(buf1*10,buf2*10,(buf1+1)*10,buf2*10);
	drawline(buf1*10,buf2*10,buf1*10,(buf2+1)*10);

 if a[buf1,buf2]=1 then
 begin
 	drawline(buf1*10,buf2*10,(buf1+1)*10,(buf2+1)*10);
 	drawline(buf1*10,(buf2+1)*10,(buf1+1)*10,buf2*10);
 end;

 if a[buf1,buf2]=2 then drawEllipse(buf1*10+1,buf2*10+1,10,10);
	end;
	
	drawline(40,10,40,40);
	drawline(10,40,40,40);
end;

procedure Ai;
begin
//fuccckkkk
end;

procedure Keys;
begin
if getKeyPressed<>KE_NONE then
	begin
 if getKeyPressed=KE_KEY1 then if a[1,1]=0 then a[1,1]:=1;
 if getKeyPressed=KE_KEY2 then if a[2,1]=0 then a[2,1]:=1;
 if getKeyPressed=KE_KEY3 then if a[3,1]=0 then a[3,1]:=1;
 if getKeyPressed=KE_KEY4 then if a[1,2]=0 then a[1,2]:=1;
 if getKeyPressed=KE_KEY5 then if a[2,2]=0 then a[2,2]:=1;
 if getKeyPressed=KE_KEY6 then if a[3,2]=0 then a[3,2]:=1;
 if getKeyPressed=KE_KEY7 then if a[1,3]=0 then a[1,3]:=1;
 if getKeyPressed=KE_KEY8 then if a[2,3]=0 then a[2,3]:=1;
 if getKeyPressed=KE_KEY9 then if a[3,3]=0 then a[3,3]:=1;
 if getKeyPressed=KE_KEY0 then run:=false;
 if getKeyPressed=KE_STAR then Midlet_reboot:=true;

 need_to_update:=true;
	end;
end;

procedure Find_Winer;
begin


end;

procedure Update_Game;
begin
	if need_to_update=true then 
	begin
 Cls;
 Graphics;
 Midlet_update;
 Ai;
 Find_Winer;
	end;
	Keys;
	

end;

begin
	//midlet start run
	run:=true;
	need_to_update:=true;
	//main loop
 while run=true do Update_Game;
end.
учитесь ! )
 
Ответить с цитированием