Changeset 4400


Ignore:
Timestamp:
2013-07-03 14:17:18 (10 years ago)
Author:
mijoilmo
Message:

Talletus.

Location:
2013/27/MikkoI
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/MikkoI/omapeli/omapeli.sln

    r4338 r4400  
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "omapeli", "omapeli\omapeli\omapeli.csproj", "{7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "omapeliContent", "omapeli\omapeliContent\omapeliContent.contentproj", "{24AE9396-4A7E-4632-B155-51A465B2CC94}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "omapeliContent", "omapeli\omapeliContent\omapeliContent.contentproj", "{24AE9396-4A7E-4632-B155-51A465B2CC94}" 
     7EndProject 
     8Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mikonLib", "..\mikonLib\mikonLib\mikonLib.csproj", "{C232E7E2-FD72-4019-A924-0F01400DE899}" 
    79EndProject 
    810Global 
    911        GlobalSection(SolutionConfigurationPlatforms) = preSolution 
     12                Debug|Any CPU = Debug|Any CPU 
     13                Debug|Mixed Platforms = Debug|Mixed Platforms 
    1014                Debug|x86 = Debug|x86 
     15                Release|Any CPU = Release|Any CPU 
     16                Release|Mixed Platforms = Release|Mixed Platforms 
    1117                Release|x86 = Release|x86 
    1218        EndGlobalSection 
    1319        GlobalSection(ProjectConfigurationPlatforms) = postSolution 
     20                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Debug|Any CPU.ActiveCfg = Debug|x86 
     21                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 
     22                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Debug|Mixed Platforms.Build.0 = Debug|x86 
    1423                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Debug|x86.ActiveCfg = Debug|x86 
    1524                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Debug|x86.Build.0 = Debug|x86 
     25                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Release|Any CPU.ActiveCfg = Release|x86 
     26                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Release|Mixed Platforms.ActiveCfg = Release|x86 
     27                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Release|Mixed Platforms.Build.0 = Release|x86 
    1628                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Release|x86.ActiveCfg = Release|x86 
    1729                {7E0624B6-CD0C-45A5-BE56-D8BCF997D4F5}.Release|x86.Build.0 = Release|x86 
     30                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Debug|Any CPU.ActiveCfg = Debug|x86 
     31                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 
    1832                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Debug|x86.ActiveCfg = Debug|x86 
     33                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Release|Any CPU.ActiveCfg = Release|x86 
     34                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Release|Mixed Platforms.ActiveCfg = Release|x86 
    1935                {24AE9396-4A7E-4632-B155-51A465B2CC94}.Release|x86.ActiveCfg = Release|x86 
     36                {C232E7E2-FD72-4019-A924-0F01400DE899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 
     37                {C232E7E2-FD72-4019-A924-0F01400DE899}.Debug|Any CPU.Build.0 = Debug|Any CPU 
     38                {C232E7E2-FD72-4019-A924-0F01400DE899}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 
     39                {C232E7E2-FD72-4019-A924-0F01400DE899}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 
     40                {C232E7E2-FD72-4019-A924-0F01400DE899}.Debug|x86.ActiveCfg = Debug|Any CPU 
     41                {C232E7E2-FD72-4019-A924-0F01400DE899}.Release|Any CPU.ActiveCfg = Release|Any CPU 
     42                {C232E7E2-FD72-4019-A924-0F01400DE899}.Release|Any CPU.Build.0 = Release|Any CPU 
     43                {C232E7E2-FD72-4019-A924-0F01400DE899}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 
     44                {C232E7E2-FD72-4019-A924-0F01400DE899}.Release|Mixed Platforms.Build.0 = Release|Any CPU 
     45                {C232E7E2-FD72-4019-A924-0F01400DE899}.Release|x86.ActiveCfg = Release|Any CPU 
    2046        EndGlobalSection 
    2147        GlobalSection(SolutionProperties) = preSolution 
  • 2013/27/MikkoI/omapeli/omapeli/omapeli/omapeli.cs

    r4338 r4400  
    1111    public override void Begin() 
    1212    { 
     13        Mouse.IsCursorVisible = true; 
     14        CreateBox(0, 800, 200, 200, "destroyer", double.MinValue, double.MaxValue); 
     15        CreateBox(10, 10, 150, 150, "normal", double.MinValue, double.MaxValue); 
     16        AssignLevel(); 
     17        Keyboard.Listen(Key.Escape, ButtonState.Pressed, delegate { Exit(); }, "Lopeta peli"); 
     18    } 
     19 
     20    void CreateShards(double x, double y, double w, double h, Vector velocity) 
     21    { 
     22        double shardWidth = w; double shardHeight = h; 
     23        if (shardWidth < 4) { shardWidth = 4; } 
     24        if (shardHeight < 4) { shardHeight = 4; } 
     25 
     26        for (int i = 0; i < ((w * h) / 10); i++) 
     27        { 
     28            PhysicsObject shard = new PhysicsObject(shardWidth / 2, shardHeight / 2); 
     29            double divider = RandomGen.NextDouble(1, 7); 
     30 
     31            //double shardWidth = ((((w * h) / 2) / ((w * h) / 15)) / divider);   //(((w * h) / 2) / ((w * h) / 15)) laskee pinta-alan yhdelle kolmiolle, entäs leveys?  
     32            //double shardHeight = ((((w * h) / 2) / ((w * h) / 15)) * divider); 
     33 
     34            double randomX = RandomGen.NextDouble((x - w / 2) + (shardWidth / 2), (x + w / 2) - (shardWidth / 2)); 
     35            double randomY = RandomGen.NextDouble((y - h / 2) + (shardHeight / 2), (y + h / 2) - (shardHeight / 2)); 
     36            AddCollisionHandler(shard, "destroyer", CollisionHandler.DestroyObject); 
     37            shard.Shape = Shape.Triangle; 
     38            shard.Color = Color.Black; 
     39            shard.Velocity = velocity; 
     40            shard.X = randomX; 
     41            shard.Y = randomY; 
     42            shard.Width = shardWidth; 
     43            shard.Height = shardHeight; 
     44 
     45            Add(shard); 
     46        } 
     47    } 
     48 
     49    PhysicsObject CreateBox(double x, double y, double w, double h, string type, double min, double max) 
     50    { 
     51 
     52        if (w < min || w > max) 
     53        { 
     54            return null; 
     55        } 
     56        if (h < min || h > max) 
     57        { 
     58            return null; 
     59        } 
     60 
     61        PhysicsObject box = new PhysicsObject(w, h); 
     62        box.X = x; 
     63        box.Y = y; 
     64        Mouse.ListenOn(box, MouseButton.Left, ButtonState.Pressed, BreakBox, null, box); 
     65        switch (type) 
     66        { 
     67            case "normal": 
     68                box.Color = Color.Black; 
     69                box.Restitution = 0.4; 
     70                AddCollisionHandler(box, "destroyer", delegate(PhysicsObject obj, PhysicsObject toin) { if (toin.Velocity.X > 10 || toin.Velocity.Y > 10) { BreakBox(obj); } }); 
     71                break; 
     72            case "destroyer": 
     73                box.Color = Color.Red; 
     74                box.Tag = "destroyer"; 
     75                box.Mass = 60; 
     76                break; 
     77        } 
     78        Add(box); 
     79        return box; 
     80    } 
     81    void BreakBox(PhysicsObject obj) 
     82    { 
     83        //ExplosionSystem explosion = new ExplosionSystem(explosionImage,10); 
     84        //explosion.MinVelocity = 2.1; 
     85        //explosion.MaxVelocity = 6.2; 
     86        //Add(explosion); 
     87        //explosion.AddEffect(obj.Position,10); 
     88        Vector maxShardSize = new Vector(obj.Width / 1.6, obj.Height / 1.6); 
     89        ObjSlicer(obj, 
     90            RandomGen.NextDouble(obj.Left + (obj.Width / 1.6 / 2), obj.Right - (obj.Width / 1.6 / 2)), 
     91            RandomGen.NextDouble(obj.Top - (obj.Width / 1.6 / 2), obj.Bottom + (obj.Width / 1.6 / 2)), 
     92            50, maxShardSize, 4); 
     93        obj.Destroy(); 
     94    } 
     95    void ObjSlicer(PhysicsObject obj, double parentBoxX, double parentBoxY, int maxShards, Vector maxShardSize, double minShardSize) 
     96    { 
     97        double maxSize = 0; 
     98        if (maxShardSize.X > maxShardSize.Y) maxSize = maxShardSize.X; 
     99        else maxSize = maxShardSize.Y; 
     100 
     101        PhysicsObject parent = CreateBox(parentBoxX, parentBoxY, maxShardSize.X, maxShardSize.Y, "normal", minShardSize, maxSize); // keski(parent) 
     102        if (parent == null) 
     103        { 
     104            CreateShards(parentBoxX, parentBoxY, maxShardSize.X, maxShardSize.Y, obj.Velocity);  
     105            return; 
     106        } 
     107        else 
     108        { 
     109            parent.Velocity = obj.Velocity;  
     110            parent.Angle = obj.Angle; 
     111        } 
     112 
     113        double x = parent.Left - ((parent.Left - obj.Left) / 2); 
     114        double y = parent.Top + (obj.Top - parent.Top) / 2; 
     115        double width = parent.Left - obj.Left; 
     116        double height = obj.Top - parent.Top; 
     117 
     118        PhysicsObject box = new PhysicsObject(1, 1); 
     119 
     120        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     121 
     122        if (box == null) 
     123        { 
     124            CreateShards(x, y, width, height, obj.Velocity); 
     125        } 
     126        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     127 
     128        x = parentBoxX; 
     129        width = parent.Width; 
     130 
     131        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     132 
     133        if (box == null) 
     134        { 
     135            CreateShards(x, y, width, height, obj.Velocity); 
     136        } 
     137        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     138        x = parent.Right + ((obj.Right - parent.Right) / 2); 
     139        width = obj.Right - parent.Right; 
     140 
     141        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     142 
     143        if (box == null) 
     144        { 
     145            CreateShards(x, y, width, height, obj.Velocity); 
     146        } 
     147        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     148 
     149        x = parent.Left - ((parent.Left - obj.Left) / 2); 
     150        y = parent.Y; 
     151        width = parent.Left - obj.Left; 
     152        height = parent.Height; 
     153 
     154        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     155 
     156        if (box == null) 
     157        { 
     158            CreateShards(x, y, width, height, obj.Velocity); 
     159        } 
     160        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     161        x = parent.Right + ((obj.Right - parent.Right) / 2); 
     162        width = obj.Right - parent.Right; 
     163 
     164        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     165 
     166        if (box == null) 
     167        { 
     168            CreateShards(x, y, width, height, obj.Velocity); 
     169        } 
     170        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     171        x = parent.Left - ((parent.Left - obj.Left) / 2); 
     172        height = (parent.Bottom - obj.Bottom); 
     173        y = parent.Bottom - height / 2; 
     174        width = parent.Left - obj.Left; 
     175 
     176        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     177 
     178        if (box == null) 
     179        { 
     180            CreateShards(x, y, width, height, obj.Velocity); 
     181        } 
     182        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     183        x = parentBoxX; 
     184        width = parent.Width; 
     185 
     186        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     187 
     188        if (box == null) 
     189        { 
     190            CreateShards(x, y, width, height, obj.Velocity); 
     191        } 
     192        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     193        x = parent.Right + ((obj.Right - parent.Right) / 2); 
     194        width = obj.Right - parent.Right; 
     195 
     196        box = CreateBox(x, y, width, height, "normal", minShardSize, maxSize); 
     197 
     198        if (box == null) 
     199        { 
     200            CreateShards(x, y, width, height, obj.Velocity); 
     201        } 
     202        else { box.Velocity = obj.Velocity; box.Angle = obj.Angle; } 
     203 
     204        //if (parent.Left - obj.Left > minShardSize){ObjSlicer(parent, parent.X, parent.Y, maxShards, (parent.Left - obj.Left), minShardSize);} 
     205 
     206    } 
     207    void AssignLevel() 
     208    { 
    13209        Level.BackgroundColor = Color.White; 
    14         PhysicsObject box = new PhysicsObject(40,40); 
    15         box.Color = Color.Green; 
    16         Add(box); 
    17         Keyboard.Listen(Key.Escape, ButtonState.Pressed, delegate { Exit(); }, "Lopeta peli"); 
    18     } 
    19      
     210        Gravity = new Vector(0, -500); 
     211        Level.CreateBottomBorder(); 
     212    } 
    20213} 
  • 2013/27/MikkoI/omapeli/omapeli/omapeli/omapeli.csproj

    r4338 r4400  
    120120  </ItemGroup> 
    121121  <ItemGroup> 
     122    <ProjectReference Include="..\..\..\mikonLib\mikonLib\mikonLib.csproj"> 
     123      <Project>{C232E7E2-FD72-4019-A924-0F01400DE899}</Project> 
     124      <Name>mikonLib</Name> 
     125    </ProjectReference> 
    122126    <ProjectReference Include="..\omapeliContent\omapeliContent.contentproj"> 
    123127      <Name>omapeliContent</Name> 
  • 2013/27/MikkoI/omapeli/omapeli/omapeliContent/omapeliContent.contentproj

    r4338 r4400  
    4545    <Reference Include="AnimationExtension" /> 
    4646  </ItemGroup> 
     47  <ItemGroup> 
     48    <Compile Include="exp.png"> 
     49      <Name>exp</Name> 
     50      <Importer>TextureImporter</Importer> 
     51      <Processor>TextureProcessor</Processor> 
     52    </Compile> 
     53  </ItemGroup> 
    4754  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    4855  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.