Class restructure for octopus
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 20 Jun 2011 17:35:06 +0000 (20:35 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 20 Jun 2011 17:36:17 +0000 (20:36 +0300)
Class TimerControlledTursas replaced by class Octopus that derives from
the class TimerControlledGraphicsPixmapObject (where most of the
contents of TimerControlledTursas now are).

Also updated UML model.

Some work towards dropping the ghosts when the ship is hit by an
octopus.

Ghost Ship UML.xmi
ghostsoverboard.pro
octopus.cpp [new file with mode: 0644]
octopus.h [new file with mode: 0644]
seascene.cpp
ship.cpp
ship.h
timercontrolledgraphicspixmapobject.cpp [new file with mode: 0644]
timercontrolledgraphicspixmapobject.h [new file with mode: 0644]

index 495f257..7a73607 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<XMI verified="false" xmi.version="1.2" timestamp="2011-06-06T15:09:03" xmlns:UML="http://schema.omg.org/spec/UML/1.3">
+<XMI verified="false" xmi.version="1.2" timestamp="2011-06-20T20:29:23" xmlns:UML="http://schema.omg.org/spec/UML/1.3">
  <XMI.header>
   <XMI.documentation>
    <XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
@@ -78,7 +78,7 @@
        </UML:Classifier.feature>
       </UML:Class>
       <UML:Generalization discriminator="" visibility="public" isSpecification="false" namespace="Logical View" child="Tbq52XmJtNFL" xmi.id="RL5P5aqtVkRF" parent="pvwYlKFsbFLP" name=""/>
-      <UML:Class visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="KptrjeIHW3lK" name="TimerControlledTursas">
+      <UML:Class visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="KptrjeIHW3lK" name="TimerControlledGraphicsPixmapObject">
        <UML:GeneralizableElement.generalization>
         <UML:Generalization xmi.idref="vvx5w0jrcSg7"/>
         <UML:Generalization xmi.idref="twoWPVbMn5Aa"/>
           <UML:Parameter visibility="private" isSpecification="false" xmi.id="t2V0XEChPtdL" type="pTuUwgQs5pee" value="" comment="pixels per second&#xa;" name="speed"/>
          </UML:BehavioralFeature.parameter>
         </UML:Operation>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="r5VanFidNggU" name="droppingGhosts">
+         <UML:BehavioralFeature.parameter>
+          <UML:Parameter kind="return" xmi.id="lljPjtIIvtaL" type="LEHanyUaSN4M"/>
+         </UML:BehavioralFeature.parameter>
+        </UML:Operation>
        </UML:Classifier.feature>
       </UML:Class>
       <UML:Generalization discriminator="" visibility="public" isSpecification="false" namespace="Logical View" child="KptrjeIHW3lK" xmi.id="vvx5w0jrcSg7" parent="JtWWJpEA6bpd" name=""/>
           <UML:Parameter kind="return" xmi.id="40hiJUKhr0cN" type="LEHanyUaSN4M"/>
          </UML:BehavioralFeature.parameter>
         </UML:Operation>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="W5LAHHBhe0Bu" name="updateShipImage"/>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Y4bIQRv4gPkM" comment="signal" name="pickingghost">
+         <UML:BehavioralFeature.parameter>
+          <UML:Parameter visibility="private" isSpecification="false" xmi.id="7w02naM34kzv" type="d1eSVFVH0Eei" value="" name="pGhost"/>
+         </UML:BehavioralFeature.parameter>
+        </UML:Operation>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="U8bWxkARpWb4" comment="signal" name="droppingGhost">
+         <UML:BehavioralFeature.parameter>
+          <UML:Parameter visibility="private" isSpecification="false" xmi.id="IUOwt8ILHtrC" type="pTuUwgQs5pee" value="" name="ghosts"/>
+         </UML:BehavioralFeature.parameter>
+        </UML:Operation>
+        <UML:Operation visibility="public" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="gPIlLSKV77fz" comment="slot" name="dropAllGhosts"/>
        </UML:Classifier.feature>
       </UML:Class>
       <UML:Association visibility="public" isSpecification="false" namespace="Logical View" xmi.id="Ng4SfjTmdUrO" name="">
         <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" xmi.id="WDklEX6lEDug" type="Tbq52XmJtNFL" name="" aggregation="none"/>
        </UML:Association.connection>
       </UML:Association>
+      <UML:Class visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="MVTSCQB83hIP" name="Octopus">
+       <UML:GeneralizableElement.generalization>
+        <UML:Generalization xmi.idref="g3fIS8NqC1Ev"/>
+       </UML:GeneralizableElement.generalization>
+       <UML:Classifier.feature>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="sAy29CwhFmcS" name="handleCollisions">
+         <UML:BehavioralFeature.parameter>
+          <UML:Parameter kind="return" xmi.id="scB6MoYlDYFt" type="LEHanyUaSN4M"/>
+         </UML:BehavioralFeature.parameter>
+        </UML:Operation>
+        <UML:Operation visibility="protected" isSpecification="false" isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="OR1Wg0nKBB11" name="droppingGhosts"/>
+       </UML:Classifier.feature>
+      </UML:Class>
+      <UML:Generalization discriminator="" visibility="public" isSpecification="false" namespace="Logical View" child="MVTSCQB83hIP" xmi.id="g3fIS8NqC1Ev" parent="KptrjeIHW3lK" name=""/>
+      <UML:Association visibility="public" isSpecification="false" namespace="Logical View" xmi.id="W2BfEAe5G9e3" name="">
+       <UML:Association.connection>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" xmi.id="NMhi2LDsvMwF" type="MVTSCQB83hIP" name="" aggregation="none"/>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" xmi.id="AT0L1FDXGOBS" type="cmJcFyooDBTl" name="" aggregation="none"/>
+       </UML:Association.connection>
+      </UML:Association>
+      <UML:Association visibility="public" isSpecification="false" namespace="Logical View" xmi.id="ZpXpx9qKTV2T" name="Signal-slot association">
+       <UML:Association.connection>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" multiplicity="1" xmi.id="oFKhcGxkjv4i" type="MVTSCQB83hIP" name="" aggregation="none"/>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" multiplicity="1" xmi.id="9HEPfPrEEM1B" type="HoOKzsbjGV56" name="" aggregation="none"/>
+       </UML:Association.connection>
+      </UML:Association>
+      <UML:Class visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="d1eSVFVH0Eei" name="QGraphicsItem*"/>
+      <UML:Association visibility="public" isSpecification="false" namespace="Logical View" xmi.id="sHG785Kj5yAa" name="">
+       <UML:Association.connection>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" xmi.id="BfpAtSs1Mq1A" type="MVTSCQB83hIP" name="" aggregation="none"/>
+        <UML:AssociationEnd changeability="changeable" visibility="public" isNavigable="true" isSpecification="false" xmi.id="QNDT7BMyQd5Z" type="Tbq52XmJtNFL" name="" aggregation="none"/>
+       </UML:Association.connection>
+      </UML:Association>
      </UML:Namespace.ownedElement>
      <XMI.extension xmi.extender="umbrello">
       <diagrams>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="151" showattsigs="601" showstereotype="1" y="68" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="97" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="JtWWJpEA6bpd" showscope="1" height="55" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="333" showattsigs="601" showstereotype="1" y="155" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="136" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="5lTu70iDvlJn" showscope="1" height="54" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="1249" showattsigs="601" showstereotype="1" y="451" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="157" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="pvwYlKFsbFLP" showscope="1" height="68" showopsigs="601"/>
-         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="1" showpackage="1" x="1226" showattsigs="601" showstereotype="1" y="589" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="273" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="Tbq52XmJtNFL" showscope="1" height="179" showopsigs="601"/>
-         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="47" showattsigs="601" showstereotype="1" y="759" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="237" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="KptrjeIHW3lK" showscope="1" height="100" showopsigs="601"/>
+         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="1226" showattsigs="601" showstereotype="1" y="589" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="273" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="Tbq52XmJtNFL" showscope="1" height="179" showopsigs="601"/>
+         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="40" showattsigs="601" showstereotype="1" y="484" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="237" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="KptrjeIHW3lK" showscope="1" height="100" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="909" showattsigs="601" showstereotype="1" y="176" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="124" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="6JzeGYDHWFth" showscope="1" height="71" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="908" showattsigs="601" showstereotype="1" y="290" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="264" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="AbKKOgodDVuj" showscope="1" height="133" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="1325" showattsigs="601" showstereotype="1" y="170" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="232" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="I7cafWFM6qXf" showscope="1" height="142" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="1601" showattsigs="601" showstereotype="1" y="207" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="97" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="DN7nNQFDFoHs" showscope="1" height="91" showopsigs="601"/>
          <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="1576" showattsigs="601" showstereotype="1" y="418" showattributes="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" width="100" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="XzOcNaMph9yB" showscope="1" height="120" showopsigs="601"/>
-         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="1" showpackage="1" x="806" showattsigs="601" showstereotype="1" y="577" showattributes="1" font="Ubuntu,9,-1,5,75,0,0,0,0,0" width="264" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="HoOKzsbjGV56" showscope="1" height="73" showopsigs="601"/>
+         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="806" showattsigs="601" showstereotype="1" y="577" showattributes="1" font="Ubuntu,9,-1,5,75,0,0,0,0,0" width="267" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="HoOKzsbjGV56" showscope="1" height="95" showopsigs="601"/>
+         <classwidget linecolor="#ff0000" usesdiagramfillcolor="0" linewidth="none" showoperations="1" usesdiagramusefillcolor="0" showpubliconly="0" showpackage="1" x="82" showattsigs="601" showstereotype="1" y="686" showattributes="1" font="Ubuntu,9,-1,5,75,0,0,0,0,0" width="203" isinstance="0" usefillcolor="1" fillcolor="#ffff00" xmi.id="MVTSCQB83hIP" showscope="1" height="91" showopsigs="601"/>
         </widgets>
         <messages/>
         <associations>
          </assocwidget>
          <assocwidget indexa="1" indexb="1" widgetaid="KptrjeIHW3lK" linecolor="none" totalcounta="3" xmi.id="vvx5w0jrcSg7" widgetbid="JtWWJpEA6bpd" totalcountb="3" type="500" linewidth="none">
           <linepath>
-           <startpoint startx="243" starty="759"/>
+           <startpoint startx="243" starty="484"/>
            <endpoint endx="243" endy="123"/>
           </linepath>
          </assocwidget>
          <assocwidget indexa="2" indexb="1" widgetaid="KptrjeIHW3lK" linecolor="none" totalcounta="3" xmi.id="twoWPVbMn5Aa" widgetbid="5lTu70iDvlJn" totalcountb="4" type="500" linewidth="none">
           <linepath>
-           <startpoint startx="284" starty="759"/>
+           <startpoint startx="277" starty="484"/>
            <endpoint endx="333" endy="209"/>
           </linepath>
          </assocwidget>
-         <assocwidget indexa="1" indexb="3" widgetaid="KptrjeIHW3lK" linecolor="none" totalcounta="2" xmi.id="lqSdTsoEdYpR" widgetbid="Tbq52XmJtNFL" totalcountb="4" type="503" linewidth="none">
-          <linepath>
-           <startpoint startx="284" starty="759"/>
-           <endpoint endx="1226" endy="759"/>
-          </linepath>
-         </assocwidget>
          <assocwidget indexa="1" indexb="1" widgetaid="AbKKOgodDVuj" linecolor="none" totalcounta="2" xmi.id="HHkZOkVS1S7H" widgetbid="6JzeGYDHWFth" totalcountb="2" type="500" linewidth="none">
           <linepath>
            <startpoint startx="949" starty="290"/>
            <endpoint endx="1226" endy="589"/>
            <point x="807" y="377"/>
           </linepath>
-          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="638" showstereotype="1" y="293" text="ghosts and rocks" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="703" width="99" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="Wymv4jOL4AUH" height="18"/>
-          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="445" showstereotype="1" y="215" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="701" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="kOwOr9vH357z" height="18"/>
-          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="1219" showstereotype="1" y="551" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="702" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="e09u14nX1YS5" height="18"/>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="638" showstereotype="1" y="293" text="ghosts and rocks" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="703" width="99" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="gUZwegEUyaY2" height="18"/>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="445" showstereotype="1" y="215" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="701" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="ivSCsLsTCic6" height="18"/>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="1219" showstereotype="1" y="551" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="702" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="ixlwfWBM0lGc" height="18"/>
          </assocwidget>
          <assocwidget indexa="1" indexb="1" widgetaid="AbKKOgodDVuj" linecolor="none" totalcounta="3" xmi.id="nRcOFJO68hTA" widgetbid="I7cafWFM6qXf" totalcountb="2" type="512" linewidth="none">
           <linepath>
            <endpoint endx="1576" endy="538"/>
           </linepath>
          </assocwidget>
-         <assocwidget indexa="1" indexb="1" widgetaid="HoOKzsbjGV56" linecolor="none" totalcounta="2" xmi.id="X8SX8aulZnCp" widgetbid="cmJcFyooDBTl" totalcountb="2" type="500" linewidth="none">
+         <assocwidget indexa="1" indexb="1" widgetaid="HoOKzsbjGV56" linecolor="none" totalcounta="3" xmi.id="X8SX8aulZnCp" widgetbid="cmJcFyooDBTl" totalcountb="2" type="500" linewidth="none">
           <linepath>
            <startpoint startx="806" starty="625"/>
            <endpoint endx="750" endy="625"/>
          </assocwidget>
          <assocwidget indexa="1" indexb="2" widgetaid="HoOKzsbjGV56" linecolor="none" totalcounta="2" xmi.id="Zh78SJwh0t5f" widgetbid="Tbq52XmJtNFL" totalcountb="4" type="503" linewidth="none">
           <linepath>
-           <startpoint startx="1070" starty="625"/>
+           <startpoint startx="1073" starty="625"/>
            <endpoint endx="1226" endy="625"/>
           </linepath>
          </assocwidget>
+         <assocwidget indexa="1" indexb="1" widgetaid="MVTSCQB83hIP" linecolor="none" totalcounta="2" xmi.id="g3fIS8NqC1Ev" widgetbid="KptrjeIHW3lK" totalcountb="2" type="500" linewidth="none">
+          <linepath>
+           <startpoint startx="203" starty="686"/>
+           <endpoint endx="203" endy="584"/>
+          </linepath>
+         </assocwidget>
+         <assocwidget indexa="1" indexb="2" widgetaid="MVTSCQB83hIP" linecolor="none" totalcounta="3" xmi.id="ZpXpx9qKTV2T" widgetbid="HoOKzsbjGV56" totalcountb="3" type="503" linewidth="none">
+          <linepath>
+           <startpoint startx="285" starty="686"/>
+           <endpoint endx="806" endy="658"/>
+           <point x="570" y="658"/>
+          </linepath>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="688" showstereotype="1" y="658" text="Signal-slot association" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="703" width="127" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="zk2jg6RpNfC2" height="18"/>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="269" showstereotype="1" y="652" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="701" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="QAW9tJRs2TZi" height="18"/>
+          <floatingtext linecolor="none" usesdiagramfillcolor="1" linewidth="none" usesdiagramusefillcolor="1" x="780" showstereotype="1" y="637" text="1" font="Ubuntu,9,-1,5,50,0,0,0,0,0" pretext="" role="702" width="15" isinstance="0" posttext="" usefillcolor="1" fillcolor="none" xmi.id="QOpUIasikOqd" height="18"/>
+         </assocwidget>
+         <assocwidget indexa="2" indexb="3" widgetaid="MVTSCQB83hIP" linecolor="none" totalcounta="3" xmi.id="sHG785Kj5yAa" widgetbid="Tbq52XmJtNFL" totalcountb="4" type="503" linewidth="none">
+          <linepath>
+           <startpoint startx="285" starty="686"/>
+           <endpoint endx="1226" endy="686"/>
+          </linepath>
+         </assocwidget>
         </associations>
        </diagram>
       </diagrams>
   </UML:Model>
  </XMI.content>
  <XMI.extensions xmi.extender="umbrello">
-  <docsettings viewid="p6gcOt8u0cHb" uniqueid="2E6PtWv6EeIl" documentation=""/>
+  <docsettings viewid="p6gcOt8u0cHb" uniqueid="gPIlLSKV77fz" documentation=""/>
   <listview>
    <listitem open="1" type="800" id="Views">
     <listitem open="1" type="801" id="Logical View">
       <listitem open="0" type="815" id="RZKZFmiM0Z1K"/>
       <listitem open="0" type="815" id="pO3oWF2ymLV1"/>
      </listitem>
-     <listitem open="1" type="813" id="HoOKzsbjGV56">
-      <listitem open="0" type="815" id="f0tRGUWAB0dm"/>
+     <listitem open="1" type="813" id="MVTSCQB83hIP">
+      <listitem open="0" type="815" id="sAy29CwhFmcS"/>
+      <listitem open="0" type="815" id="OR1Wg0nKBB11"/>
      </listitem>
-     <listitem open="1" type="813" id="5lTu70iDvlJn"/>
-     <listitem open="1" type="813" id="pvwYlKFsbFLP"/>
-     <listitem open="1" type="813" id="DN7nNQFDFoHs"/>
-     <listitem open="1" type="813" id="6JzeGYDHWFth"/>
-     <listitem open="1" type="813" id="JtWWJpEA6bpd"/>
-     <listitem open="1" type="813" id="HVgEKTRTuAUS"/>
-     <listitem open="1" type="813" id="huMZoM2mtHwZ"/>
      <listitem open="1" type="813" id="cmJcFyooDBTl">
       <listitem open="0" type="814" id="E7SiLdDJf0vR"/>
       <listitem open="0" type="815" id="E30DyQUU4imX"/>
       <listitem open="0" type="815" id="rpMZq5v28tF5"/>
       <listitem open="0" type="815" id="VqLThQ89hYAn"/>
      </listitem>
+     <listitem open="1" type="813" id="d1eSVFVH0Eei"/>
+     <listitem open="1" type="813" id="5lTu70iDvlJn"/>
+     <listitem open="1" type="813" id="pvwYlKFsbFLP"/>
+     <listitem open="1" type="813" id="DN7nNQFDFoHs"/>
+     <listitem open="1" type="813" id="6JzeGYDHWFth"/>
+     <listitem open="1" type="813" id="JtWWJpEA6bpd"/>
+     <listitem open="1" type="813" id="HVgEKTRTuAUS"/>
+     <listitem open="1" type="813" id="huMZoM2mtHwZ"/>
      <listitem open="1" type="813" id="I7cafWFM6qXf"/>
      <listitem open="1" type="813" id="Tbq52XmJtNFL">
       <listitem open="0" type="815" id="CpguGvyu0blO"/>
       <listitem open="0" type="815" id="ZwnQYunWnsAf"/>
      </listitem>
      <listitem open="1" type="813" id="XzOcNaMph9yB"/>
+     <listitem open="1" type="813" id="HoOKzsbjGV56">
+      <listitem open="0" type="815" id="f0tRGUWAB0dm"/>
+      <listitem open="0" type="815" id="W5LAHHBhe0Bu"/>
+      <listitem open="0" type="815" id="Y4bIQRv4gPkM"/>
+      <listitem open="0" type="815" id="U8bWxkARpWb4"/>
+      <listitem open="0" type="815" id="gPIlLSKV77fz"/>
+     </listitem>
      <listitem open="1" type="813" id="KptrjeIHW3lK">
       <listitem open="0" type="814" id="o2YtXbuIPnJS"/>
       <listitem open="0" type="815" id="yk5lpDJWzxbC"/>
       <listitem open="0" type="815" id="XnVLOSN7LZs4"/>
       <listitem open="0" type="815" id="ybhL7q63bBnO"/>
       <listitem open="0" type="815" id="V51mov12wdwr"/>
+      <listitem open="0" type="815" id="r5VanFidNggU"/>
      </listitem>
      <listitem open="0" type="830" id="Datatypes">
       <listitem open="1" type="829" id="LEHanyUaSN4M"/>
index 70fe129..f847c88 100644 (file)
@@ -17,7 +17,9 @@ SOURCES += main.cpp\
     seascene.cpp \
     seaview.cpp \
     ship.cpp \
-    screenlitkeeper.cpp
+    screenlitkeeper.cpp \
+    timercontrolledgraphicspixmapobject.cpp \
+    octopus.cpp
 
 HEADERS  += mainwindow.h \
     orientationcontrolledgraphicspixmapobject.h \
@@ -25,7 +27,9 @@ HEADERS  += mainwindow.h \
     seascene.h \
     seaview.h \
     ship.h \
-    screenlitkeeper.h
+    screenlitkeeper.h \
+    timercontrolledgraphicspixmapobject.h \
+    octopus.h
 
 CONFIG += mobility
 MOBILITY = sensors
diff --git a/octopus.cpp b/octopus.cpp
new file mode 100644 (file)
index 0000000..2efc346
--- /dev/null
@@ -0,0 +1,26 @@
+#include "octopus.h"
+
+Octopus::Octopus(QPixmap pixmap, int speed, QGraphicsItem *parent) :
+    TimerControlledGraphicsPixmapObject(pixmap,speed,parent)
+{
+}
+
+bool Octopus::handleCollisions()
+{
+
+    QList<QGraphicsItem*>  collidesList = collidingItems();
+    if (collidesList.isEmpty())
+            return true; //retain new position
+
+    else
+    {
+        //change direction if hit anything
+        changeDirection();
+        //the game allows only one object to saty at given spot, so just check the firs one
+        if (collidesList.at(0)->data(0) == "ship")
+        {
+            emit droppingGhosts();
+        }
+        return false; //go back to old position
+    }
+}
diff --git a/octopus.h b/octopus.h
new file mode 100644 (file)
index 0000000..2e5fcb6
--- /dev/null
+++ b/octopus.h
@@ -0,0 +1,24 @@
+#ifndef OCTOPUS_H
+#define OCTOPUS_H
+
+#include "timercontrolledgraphicspixmapobject.h"
+
+class Octopus : public TimerControlledGraphicsPixmapObject
+{
+    Q_OBJECT
+public:
+    explicit Octopus(QPixmap pixmap, int speed = 10, QGraphicsItem *parent = 0);
+
+signals:
+
+    void droppingGhosts();
+
+public slots:
+
+protected:
+
+    virtual bool handleCollisions();
+
+};
+
+#endif // OCTOPUS_H
index 0e4ff6c..2986f2d 100644 (file)
@@ -1,5 +1,5 @@
 #include "seascene.h"
-#include "timercontrolledtursas.h"
+#include "octopus.h"
 #include "ship.h"
 #include <QGraphicsPixmapItem>
 #include <QDebug>
@@ -88,6 +88,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
 
     //spread the octopuses
 
+    QList<Octopus*> octopuses;
 
     for (int i=0; i < octopuses; i++)
     {
@@ -98,7 +99,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
             break;
 
     QPixmap octopusPixmap (":/pix/tursas.png");
-    TimerControlledTursas * pOctopus = new TimerControlledTursas (octopusPixmap,100);
+    Octopus * pOctopus = new Octopus(octopusPixmap,100);
     pOctopus->setData(0,"octopus");
     pOctopus->setPos(*pPosition);
     addItem(pOctopus);
@@ -106,6 +107,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     movingItems_.append(pOctopus);
     connect(this,SIGNAL(pauseOn()),pOctopus,SLOT(stopMoving()));
     connect(this,SIGNAL(pauseOff()),pOctopus,SLOT(startMoving()));
+    octopuses.append(pOctopus);
     delete pPosition;
 
     }
@@ -145,6 +147,10 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     movingItems_.append(pShip);
     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
     connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
+    foreach (Octopus* pOctopus, octopuses)
+    {
+        connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
+    }
     delete pPosition;
 }
 
index 5c353d8..1e80194 100644 (file)
--- a/ship.cpp
+++ b/ship.cpp
@@ -53,3 +53,9 @@ void Ship::updateShipImage()
     int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
     setPixmap(shipImages_.at(index));
 }
+
+void Ship::dropAllGhosts()
+{
+//TODO
+}
+
diff --git a/ship.h b/ship.h
index 47c4cff..cbc3cc8 100644 (file)
--- a/ship.h
+++ b/ship.h
@@ -22,6 +22,8 @@ signals:
 
 public slots:
 
+    void dropAllGhosts();
+
 protected:
 
 protected:
diff --git a/timercontrolledgraphicspixmapobject.cpp b/timercontrolledgraphicspixmapobject.cpp
new file mode 100644 (file)
index 0000000..e6b838c
--- /dev/null
@@ -0,0 +1,152 @@
+#include "timercontrolledgraphicspixmapobject.h"
+#include <QGraphicsScene>
+#include <QDebug>
+
+
+TimerControlledGraphicsPixmapObject::TimerControlledGraphicsPixmapObject(QPixmap pixmap, int speed, QGraphicsItem* parent) :
+    QObject(), QGraphicsPixmapItem(pixmap, parent)
+{
+    setSpeed(speed);
+    direction_ = S;
+    connect(&timer_,SIGNAL(timeout()),this,SLOT(move()));
+}
+
+void TimerControlledGraphicsPixmapObject::startMoving()
+{
+    timer_.start();
+}
+
+void TimerControlledGraphicsPixmapObject::stopMoving()
+{
+    timer_.stop();
+}
+
+void TimerControlledGraphicsPixmapObject::setSpeed(int speed)
+{
+    timer_.setInterval(1000/speed); //converts from pixels in second to milliseconds per pixel
+}
+
+void TimerControlledGraphicsPixmapObject::move()
+{
+
+    int oldx = x();
+    int oldy = y();
+
+    int newx = oldx;
+    int newy = oldy;
+
+
+    //calculate the new position
+
+    if (direction_ == E || direction_ == SE || direction_ == NE)
+    {
+        newx++;
+    }
+
+    if (direction_ == W || direction_ == SW || direction_ == NW)
+    {
+        newx--;
+    }
+
+    if (direction_ == S || direction_ == SE || direction_ == SW)
+    {
+        newy++;
+    }
+
+    if (direction_ == N || direction_ == NE || direction_ == NW)
+    {
+        newy--;
+    }
+
+
+
+    //Bound the item into the scene and change direction if hitting a boundary
+    //Only works if the old position is inside the boundaries
+
+    if (!scene()) //no movement if this item does not belong to a scene
+        return;
+
+    QRect sceneRectangle = scene()->sceneRect().toRect();
+
+    if (newx < sceneRectangle.left() || newx > sceneRectangle.right()-40)
+    {
+        changeDirection();
+        return;
+    }
+
+
+    if (newy < sceneRectangle.top() || newy > sceneRectangle.bottom()-40)
+    {
+        changeDirection();
+        return;     //the old x and y values remain intact
+    }
+
+
+    //Set the new position
+
+    setX(newx);
+    setY(newy);
+
+
+    //check for collisions and handle them (up to subclassess to implement)
+    //return to the old position if requested
+
+    if (handleCollisions() == false)
+    {
+        setX(oldx);
+        setY(oldy);
+    }
+
+
+}
+
+void TimerControlledGraphicsPixmapObject::changeDirection()
+{
+    qDebug () << "Supposed to change direction";
+
+    int direction = (qrand()%8);
+    qDebug()  << direction;
+
+    switch (direction)
+    {
+        case 0:
+            direction_ = S;
+            break;
+
+        case 1:
+            direction_ = SW;
+            break;
+
+       case 2:
+            direction_ = W;
+            break;
+
+       case 3:
+            direction_ = NW;
+            break;
+
+       case 4:
+            direction_ = N;
+            break;
+
+       case 5:
+            direction_ = NE;
+            break;
+
+       case 6:
+            direction_ = E;
+            break;
+
+      case 7:
+            direction_ = SE;
+            break;
+
+
+    }
+
+}
+
+bool TimerControlledGraphicsPixmapObject::handleCollisions()
+{
+    return true;
+}
diff --git a/timercontrolledgraphicspixmapobject.h b/timercontrolledgraphicspixmapobject.h
new file mode 100644 (file)
index 0000000..da179f7
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
+#define TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
+
+#include <QObject>
+#include <QGraphicsPixmapItem>
+#include <QTimer>
+
+class TimerControlledGraphisPixmapObject : public QObject, public QGraphicsPixmapItem
+{
+    Q_OBJECT
+public:
+    explicit TimerControlledGraphicsPixmapObject(QPixmap pixmap = QPixmap(), int speed = 1, QGraphicsItem *parent = 0);
+
+
+signals:
+
+public slots:
+
+    void startMoving();
+    void stopMoving();
+
+    /*! Intended to be used internally by connecting to a timer
+      */
+    void move();
+
+    /*! Sets the movement speed of the item
+      @param speed given in pixels per second
+      */
+    void setSpeed(int speed);
+
+
+ protected:
+
+    void changeDirection();
+
+    virtual bool handleCollisions();
+
+    QTimer timer_;
+
+    enum direction {N, NE, E, SE, S, SW, W, NW};
+
+    direction direction_;
+
+
+};
+
+#endif // TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H