Effects/LayerMover.cpp

Thu, 21 Apr 2011 01:53:15 +0000

author
cemkalyoncu
date
Thu, 21 Apr 2011 01:53:15 +0000
changeset 20
cc549c0f8ebd
parent 1
1ef17765f966
child 21
016809939f8a
permissions
-rw-r--r--

* geffects >> gorgon::effects
* gre >> gorgon::resource
* gorgonwidgets >> gorgon::widgets
* graphics moved to gorgon::graphics
* no longer using any namespace in headers
* widget layer moved to widgets

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
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
10 Target->X=from.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
11 Target->Y=from.y;
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;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
22 Target->X=to.x;
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
23 Target->Y=to.y;
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 }
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
42 Target->X=current.x;
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 }
1ef17765f966 * Moving to trunk step 2
cemkalyoncu
parents:
diff changeset
55 Target->Y=current.y;
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