Effects/LayerMover.cpp

Thu, 21 Apr 2011 13:25:39 +0000

author
cemkalyoncu
date
Thu, 21 Apr 2011 13:25:39 +0000
changeset 21
016809939f8a
parent 20
cc549c0f8ebd
child 30
5a1daa2eb409
permissions
-rw-r--r--

* No more warnings in fixed areas, widgets still have warnings

1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
1 #include "LayerMover.h"
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
2
20
cc549c0f8ebd * geffects >> gorgon::effects
cemkalyoncu
parents: 1
diff changeset
3 namespace gge { namespace effects {
1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
4 void LayerMover::Setup(Point From, Point To, int Time) {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
5
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
6 from=From;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
7 current=from;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
8 to=To;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
9
21
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
10 Target->X=(int)from.x;
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
11 Target->Y=(int)from.y;
1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
12 this->progressed=0;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
13
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
14 if(Time) {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
15 speed.x=(float)(to.x-from.x)/Time;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
16 speed.y=(float)(to.y-from.y)/Time;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
17 this->Play();
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
18 } else {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
19 speed.x=0;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
20 speed.y=0;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
21 current=from=to;
21
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
22 Target->X=(int)to.x;
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
23 Target->Y=(int)to.y;
1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
24 }
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
25 }
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
26
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
27 bool LayerMover::isFinished() {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
28 return current.x==to.x && current.y==to.y;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
29 }
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
30
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
31 void LayerMover::Process(int Time) {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
32 if(from.x>to.x) {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
33 current.x=from.x+Time*speed.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
34
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
35 if(current.x<to.x)
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
36 current.x=to.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
37 } else {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
38 current.x=from.x+Time*speed.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
39 if(current.x>to.x)
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
40 current.x=to.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
41 }
21
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
42 Target->X=(int)current.x;
1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
43
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
44
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
45 if(from.y>to.y) {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
46 current.y=from.y+Time*speed.y;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
47
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
48 if(current.y<to.y)
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
49 current.y=to.y;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
50 } else {
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
51 current.y=from.y+Time*speed.y;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
52 if(current.y>to.y)
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
53 current.y=to.y;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
54 }
21
016809939f8a * No more warnings in fixed areas, widgets still have warnings
cemkalyoncu
parents: 20
diff changeset
55 Target->Y=(int)current.y;
1
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
56
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
57 }
20
cc549c0f8ebd * geffects >> gorgon::effects
cemkalyoncu
parents: 1
diff changeset
58 } }

mercurial