Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / examples / declarative / particles / affectors / groupgoal.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the examples of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 2.0
42 import QtQuick.Particles 2.0
43
44
45 Rectangle {
46     id: root
47     width: 360
48     height: 600
49     color: "black"
50
51     property int score: 0
52     Text {
53         color: "white"
54         anchors.right: parent.right
55         text: score
56     }
57
58     ParticleSystem {
59         id: particles
60         anchors.fill: parent
61         ParticleGroup {
62             name: "unlit"
63             duration: 1000
64             to: {"lighting":1, "unlit":99}
65             ImageParticle {
66                 source: "../images/particleA.png"
67                 colorVariation: 0.1
68                 color: "#2060160f"
69             }
70             GroupGoal {
71                 whenCollidingWith: ["lit"]
72                 goalState: "lighting"
73                 jump: true
74             }
75         }
76         ParticleGroup {
77             name: "lighting"
78             duration: 100
79             to: {"lit":1}
80         }
81         ParticleGroup {
82             name: "lit"
83             duration: 10000
84             onEntered: score++;
85             TrailEmitter {
86                 id: fireballFlame
87                 group: "flame"
88
89                 emitRatePerParticle: 48
90                 lifeSpan: 200
91                 emitWidth: 8
92                 emitHeight: 8
93
94                 size: 24
95                 sizeVariation: 8
96                 endSize: 4
97             }
98
99             TrailEmitter {
100                 id: fireballSmoke
101                 group: "smoke"
102
103                 emitRatePerParticle: 120
104                 lifeSpan: 2000
105                 emitWidth: 16
106                 emitHeight: 16
107
108                 speed: PointDirection {yVariation: 16; xVariation: 16}
109                 acceleration: PointDirection {y: -16}
110
111                 size: 24
112                 sizeVariation: 8
113                 endSize: 8
114             }
115         }
116
117         ImageParticle {
118             id: smoke
119             anchors.fill: parent
120             groups: ["smoke"]
121             source: "../images/particle.png"
122             colorVariation: 0
123             color: "#00111111"
124         }
125         ImageParticle {
126             id: pilot
127             anchors.fill: parent
128             groups: ["pilot"]
129             source: "../images/particle.png"
130             redVariation: 0.01
131             blueVariation: 0.4
132             color: "#0010004f"
133         }
134         ImageParticle {
135             id: flame
136             anchors.fill: parent
137             groups: ["flame", "lit", "lighting"]
138             source: "../images/particleA.png"
139             colorVariation: 0.1
140             color: "#00ff400f"
141         }
142
143         Emitter {
144             height: parent.height/2
145             emitRate: 4
146             lifeSpan: 4000//TODO: Infinite & kill zone
147             size: 24
148             sizeVariation: 4
149             speed: PointDirection {x:120; xVariation: 80; yVariation: 50}
150             acceleration: PointDirection {y:120}
151             group: "unlit"
152         }
153
154         Emitter {
155             id: flamer
156             x: 100
157             y: 300
158             group: "pilot"
159             emitRate: 80
160             lifeSpan: 600
161             size: 24
162             sizeVariation: 2
163             endSize: 0
164             speed: PointDirection { y:-100; yVariation: 4; xVariation: 4 }
165             GroupGoal {
166                 groups: ["unlit"]
167                 goalState: "lit"
168                 jump: true
169                 system: particles
170                 x: -15
171                 y: -55
172                 height: 75
173                 width: 30
174                 shape: MaskShape {source: "../images/matchmask.png"}
175             }
176         }
177         //Click to enflame
178         GroupGoal {
179             groups: ["unlit"]
180             goalState: "lighting"
181             jump: true
182             enabled: ma.pressed
183             width: 18
184             height: 18
185             x: ma.mouseX - width/2
186             y: ma.mouseY - height/2
187         }
188         MouseArea {
189             id: ma
190             anchors.fill: parent
191         }
192     }
193 }