PDA

View Full Version : move the block



wantonman
11-16-2012, 04:59 AM
var
i,a,x,y,img1,buf1,buf2:integer;
begin
img1:=CreateBitmap(10,10)
buf2:=CreateBitmap(600,400)
buf1:=CreateBitmap(600,400)
FastDrawClear(img1,1655209)
x:=300
y:=200
DisplayDebugImgWindow(600,400);
repeat
for i:=37 to 40 do
begin
if a=4 then a:=0;
inc(a)
if iskeydown(i) then
begin
if a=1 then x:=x-2;
if a=2 then y:=y-2;
if a=3 then x:=x+2;
if a=4 then y:=y+2;
FastDrawTransparent(0,0,buf2,buf1);
FastDrawTransparent(x,y,img1,buf1);
DrawBitmapDebugImg(buf1);
end;
end;
until iskeydown(27)
end.


cough* use arrows
use esc to exit


//so i made this in search of efficientcy... least amount of code for most amount of profit

i did not free bitmaps this not the issue - its okay but this simple way of arrow input wa the shortest way of moving up down left right... that is all

P1ng
11-16-2012, 05:30 AM
Haha! That's pretty cool. But why you no free bitmaps on terminate?

wantonman
11-16-2012, 06:12 PM
theres a problem with the flickering... i did not propery use a buffer... im not sure on how to utilitalize the tmufasa bitmapclass for direct canvas draw