Показать сообщение отдельно
Старый 12.09.2006, 18:38   #3
dermeg
Оператор ЭВМ
 
Регистрация: 01.09.2006
Сообщений: 36
Написано одно полезное сообщение
Лампочка Re: Как сделать

Вот смотри пример:

program NewProject;
var menuCommand,exitCommand:command;
exitGame:integer;
keyCode:integer;
clicked: command;
exit, about,backgame,news: integer;
img: image;

//вызов меню
procedure menu;
var play:command;
begin
showMenu('Crazy Monkey', CH_IMPLICIT);

backgame := menuAppendString('Вернуться в игру');
news := menuAppendString('Новости проекта');
about := menuAppendString('О игре...');
exit := menuAppendString('Выход из игры');

play := createCommand('Выбрать', CM_SCREEN, 1);
addCommand(play);
repaint;
repeat
delay(100);
clicked := getClickedCommand;
until clicked = play;
showCanvas;
end;

//новости
procedure newsShow;
var conn: http;
htmlBody: string;
contentType: string;
label_id: integer;
cm : command;
begin
ShowForm;
label_id:=formAddString('Подождите, идёт загрузка новостей...');
if not openHttp(conn, 'http://www.cr.pskov.name/crnews.php') then halt;
setHttpMethod(conn, GET);
addHttpHeader(conn, 'User-agent', 'MIDletPascal browser');
if sendHttpMessage(conn) <> 200 then halt;
htmlBody := getHttpResponse(conn);
contentType := getHttpHeader(conn, 'Content-type');
closeHttp(conn);
clearForm;
label_id:=formAddString(htmlBody);
cm := createCommand('Назад', CM_BACK, 1);
addCommand(cm);
repaint;
repeat
delay(100);
clicked := getClickedCommand;
until clicked = cm;
removeCommand(cm);
clearForm;
menu;
end;

//о программе
procedure aboutShow;
var label_id,space_id: integer;
cm : command;
begin
showForm;
setTicker('Игра написана MEG-Studio 2006');
label_id:=formAddString('Crazy Monkey - эмулятор игрового автомата.');
cm := createCommand('OK', CM_OK, 1);
addCommand(cm);
repaint;
repeat
delay(100);
clicked := getClickedCommand;
until clicked = cm;
removeCommand(cm);
clearForm;
menu; // Убираем предупреждение с экрана
end;

//основной цикл программы
begin
exitGame:=0;
menuCommand := createCommand('Меню', CM_OK, 1);
exitCommand := createCommand('Выход', CM_BACK, 1);
img:=LoadImage('/icon.png');
addCommand(menuCommand);
addCommand(exitCommand);
repeat
//читает нажатие клавиш 1 2 3 4 5 6 7 8 9 0 # *
// keyCode := GetKeyClicked;
//читает нажатие командных клавиш
clicked:=getClickedCommand;
if (clicked = menuCommand) then
begin
menu;
end;
if (clicked = exitCommand) then
begin
exitGame:=1;
end;
//провека какой пункт меню был выбран
if menuGetSelectedIndex = news then newsShow;
if menuGetSelectedIndex = about then aboutShow;
if menuGetSelectedIndex = exit then exitGame:=1;
DrawImage(img,Random(170),Random(170));
repaint;
delay(500);
until (exitGame=1);
end.
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
KAK? TAK! (17.03.2009)