1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local IM_EFFECT_MSECS = 3000	--how long image will be move in milliseconds
local IM_EFFECT_OFFSETX = 0	--position to which the image will be moved from "center" position
local IM_EFFECT_OFFSETY = -30
local IM_EFFECT_CENTERX = 0	--"center" position, (0, 0) - position of player
local IM_EFFECT_CENTERY = 0
local im = {}
function effectIm(param)
	param = tonumber(param)
	local pImEl = im[param]
	local time = IM_EFFECT_MSECS / 10
	local distX = IM_EFFECT_OFFSETX/time * (time-pImEl.timer)
	local distY = IM_EFFECT_OFFSETY/time * (time-pImEl.timer)
	if pImEl then
		imagepos(pImEl.id,
			player(param, "x") + IM_EFFECT_CENTERX + distX,
			player(param, "y") + IM_EFFECT_CENTERY + distY,
			0
		)
		tween_move(
			pImEl.id,
			IM_EFFECT_MSECS,
			player(param, "x")+IM_EFFECT_OFFSETX,
			player(param, "y")+IM_EFFECT_OFFSETY
		)
		pImEl.timer = pImEl.timer - 1
		if pImEl.timer==0 then
			freeimage(pImEl.id)
			pImEl.id = nil
		end
	end
end
function fillIm(plid)
	if plid and im[plid] then
		if im[plid].id then
			freetimer("effectIm", tostring(plid))
			freeimage(im[plid].id)
			im[plid].id = nil
		end
		im[plid] = {
			id = image("gfx/gametitle.png", 0, 0, 3),
			timer = IM_EFFECT_MSECS / 10,
		}
	end
end
function startImEffect(plid)
	if plid>=#im then
		table.insert(im, {id = nil, timer = 0})
	end
	fillIm(plid)
	timer(10, "effectIm", tostring(plid), IM_EFFECT_MSECS / 10)
end