Тема: Keypressing
Показать сообщение отдельно
Старый 14.11.2010, 05:02   #4
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Keypressing

I searched the forum, and i found this:


Program test;

uses
game;

const
UP_PRESSED = 2;
DOWN_PRESSED = 64;
LEFT_PRESSED = 4;
RIGHT_PRESSED = 32;
FIRE_PRESSED = 256;
GAME_A_PRESSED = 512;
GAME_B_PRESSED = 1024;
GAME_C_PRESSED = 2048;
GAME_D_PRESSED = 4096;

var
img: image;
key: integer;
x,y: integer;

procedure cls;
begin
setcolor(255,255,255);
fillrect(0,0,getwidth,getheight);
end;

procedure init;
begin
img:=loadimage('/icon.png');
x:=20;
y:=20;
game.init;
game.show;
end;

Begin
init;
repeat
key:=game.get_key_states;
if game.get_bit(key, LEFT_PRESSED)<>0 then
x:=x-5;
if game.get_bit(key, RIGHT_PRESSED)<>0 then
x:=x+5;
if game.get_bit(key, UP_PRESSED)<>0 then
y:=y-5;
if game.get_bit(key, DOWN_PRESSED)<>0 then
y:=y+5;
cls;
drawimage(img,x,y);
game.refresh;
delay(50);
until game.get_bit(key, FIRE_PRESSED)<>0;
End.



That's exactly what i need. I compiled it, but i when i run *.jar, i get blank white screen again!

Please help..
(Offline)
 
Ответить с цитированием