SRL Archive - SRL Archives

pixelshift():integer and IsMoving: boolean


marpis

2009-05-20 13:50:20

I tried the IsMoving function made by Bullzeye95, edited by Nava2 but i didn't find it work as it should, so i made my own which i think is pretty reliable.
I also think PixelShift() is very useful for many things, just use your imagination

works with smart.

UPDATE THE SRL ONE?
or at least make a function like this, cause the current function doesn't work properly.

please someone test it and tell me how it works and how fast it is!
my computer is somehow broken and its über laggy

function PixelShift(x1, y1, x2, y2, step, t: integer): integer;
var
bmp, bmp2, x, y: integer;
begin
bmp := BitmapFromString((x2 -x1), (y2 - y1), '');
bmp2 := BitmapFromString((x2 -x1), (y2 - y1), '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(bmp), x1, y1, x2, y2, 0, 0, (x2 - x1), (y2 - y1));
wait(t);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(bmp2), x1, y1, x2, y2, 0, 0, (x2 - x1), (y2 - y1));
for x := 1 to ((x2 - x1)/step) do
for y := 1 to ((y2 - y1)/step) do
if FastGetPixel(bmp2, x * step, y * step) <> FastGetPixel(bmp, x * step, y * step) then
Inc(result);
FreeBitmap(bmp);
FreeBitmap(bmp2);
end;

function m_IsMoving: boolean;
begin
result := PixelShift(MMX1, MMY1, MMX2, MMY2, 5, 200) > 100;
end;

edit: omg freebitmaps :o
edit: tested with smart and it works. also edited IsMoving a bit (120 -> 150)
edit: added step

Home

2009-05-20 13:58:52

From: marpis
I tried the IsMoving function made by Bullzeye95, edited by Nava2 but i didn't find it work as it should, so i made my own which i think is pretty reliable.
I also think PixelShift() is very useful for many things, just use your imagination

i did not test it with SMART yet.


function PixelShift(x1, y1, x2, y2, t: integer): integer;
var
bmp, bmp2, x, y: integer;
begin
bmp := BitmapFromString((x2 -x1), (y2 - y1), '');
bmp2 := BitmapFromString((x2 -x1), (y2 - y1), '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(bmp), x1, y1, x2, y2, 0, 0, (x2 - x1), (y2 - y1));
wait(t);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(bmp2), x1, y1, x2, y2, 0, 0, (x2 - x1), (y2 - y1));
for x := 1 to (x2 - x1) do
for y := 1 to (y2 - y1) do
if FastGetPixel(bmp2, x, y) <> FastGetPixel(bmp, x, y) then
Inc(result);
FreeBitmap(bmp);
FreeBitmap(bmp2);
end;

function IsMoving: boolean;
begin
result := PixelShift(MMCX-25, MMCY-25, MMCX+25, MMCY+25, 200) > 120;
end;

edit: omg freebitmaps :o



Hey that's kinda cool :) I had same idea like 2 months ago :) But i never did it :)


~Home

marpis

2009-05-20 14:04:00

From: Home
Hey that's kinda cool :) I had same idea like 2 months ago :) But i never did it :)


~Home


heh i understand why u didn't do it cause it took 3 valuable minutes of my life :p

Gu3st...

2009-05-20 14:25:42

Have you tested this with 100x100 bmps? how fast is it?

ZephyrsFury

2009-05-20 14:29:26

This is basically what IsMoving does except IsMoving skips all colours that move often (like Player and NPC dots).

marpis

2009-05-20 15:20:13

From: ZephyrsFury
This is basically what IsMoving does except IsMoving skips all colours that move often (like Player and NPC dots).

IsMoving occasionally freezes for seconds… and skipping those colors is pretty much useless, because when NPCs and other players move around you, the shift is always < 100 px. When you move the shift can jump up to 1000px, depending on how vast area we are checking

From: Zyt3x
Have you tested this with 100x100 bmps? how fast is it?

It's not very fast with over 50*50, but i can update it now… just a min
EDIT: ADDED STEP

Nava2

2009-05-20 17:03:19

I like IsMoving and it works fine..

No offense..

Home

2009-05-20 17:25:17

From: Nava2
I like IsMoving and it works fine..

No offense..


For me it doesn't work :D And give him some support guys :)

EDIT: And why.. I don't really have interest :D


~Home