Changeset 8142 for 2016/30


Ignore:
Timestamp:
2016-07-27 11:32:05 (3 years ago)
Author:
jolehto
Message:
 
Location:
2016/30/JoonasL/Arrow
Files:
6 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • 2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.cs

    r8122 r8142  
    99public class Arrow : PhysicsGame 
    1010{ 
    11     private PhysicsObject player, first, second, third, fourth; 
    12     private ExplosionSystem explosionSystem = new ExplosionSystem (LoadImage ("particle"), 1000); 
    13     private bool down = true, dead = false; 
     11    private PhysicsObject player; 
     12 
     13    private PhysicsObject[] percents = new PhysicsObject[4]; 
     14 
     15    private ExplosionSystem noteEffect = new ExplosionSystem(LoadImage("note"), 250); 
     16    private ExplosionSystem coinEffect = new ExplosionSystem(LoadImage("coin"), 250); 
     17 
     18    private double labelLeft; 
     19 
     20    private bool down = true, dead = true; 
    1421    private float MOVEMENT_SPEED = 0, multiplier = 1000; 
    1522    private List<Vector> points = new List<Vector>(); 
    1623    private Image redPercent, greenPercent; 
    1724 
     25    private float yearsLeft = 100; 
     26    private Label labelYearsLeft; 
     27 
    1828    public override void Begin() 
    1929    { 
     30        labelLeft = Screen.Left * 0.965; 
     31        MultiSelectWindow multiSelectWindow = new MultiSelectWindow("Arrow", "Alota peli", "Lopeta peli"); 
     32        multiSelectWindow.AddItemHandler(0, Start); 
     33        multiSelectWindow.AddItemHandler(1, Exit); 
    2034        Window.Fullscreen = true; 
     35        SmoothTextures = false; 
     36        Add(multiSelectWindow); 
     37        SetListeners(); 
     38    } 
     39 
     40    private void Start () 
     41    { 
     42        dead = false; 
    2143        redPercent = LoadImage("percent"); 
    2244        greenPercent = LoadImage("percent_1"); 
    23         Level.Background.Color = Color.Black; 
    24         SetListeners(); 
    25  
    26         first = new PhysicsObject(100, 100); 
    27          
    28         first.Image = greenOrRed(); 
    29         first.Tag = "Percent"; 
    30         second = new PhysicsObject(100, 100); 
    31         second.Image = greenOrRed(); 
    32         second.Tag = "Percent"; 
    33         third = new PhysicsObject(100, 100); 
    34         third.Image = greenOrRed(); 
    35         third.Tag = "Percent"; 
    36         fourth = new PhysicsObject(100, 100); 
    37         fourth.Image = greenOrRed(); 
    38         fourth.Tag = "Percent"; 
    39  
    40         Add(first); 
    41         Add(second); 
    42         Add(third); 
    43         Add(fourth); 
    44         Add(explosionSystem); 
    45  
    46         RandomPercentPosition(first, 0); 
    47         RandomPercentPosition(second, 1); 
    48         RandomPercentPosition(third, 2); 
    49         RandomPercentPosition(fourth, 3); 
     45        Level.Background.Color = Color.White; 
     46 
     47        Add(noteEffect); 
     48        Add(coinEffect); 
     49 
     50        CreatePercent(0); 
     51        CreatePercent(1); 
     52        CreatePercent(2); 
     53        CreatePercent(3); 
     54 
     55        labelYearsLeft = new Label(yearsLeft + " years left"); 
     56        labelYearsLeft.X = -880; 
     57        labelYearsLeft.Y = 500; 
     58        Add(labelYearsLeft); 
    5059 
    5160        player = new PhysicsObject(50, 50, Shape.Triangle); 
     61        player.Color = Color.Black; 
    5262        player.Angle = Angle.FromDegrees(225); 
    5363        player.Restitution = 10; 
     
    112122 
    113123        if (!dead) 
    114         { 
     124        {      
    115125            MOVEMENT_SPEED = multiplier * (float)time.SinceLastUpdate.TotalSeconds; 
    116126            multiplier += (float) time.SinceLastUpdate.TotalMilliseconds / 60; 
     
    119129            { 
    120130                player.Y -= MOVEMENT_SPEED; 
     131                yearsLeft -= 0.1f; 
    121132            } 
    122133            else 
    123134            { 
    124135                player.Y += MOVEMENT_SPEED; 
    125             } 
    126              
    127             first.X -= MOVEMENT_SPEED; 
    128             second.X -= MOVEMENT_SPEED; 
    129             third.X -= MOVEMENT_SPEED; 
    130             fourth.X -= MOVEMENT_SPEED; 
    131  
    132             if (first.X < Level.Left * 2) { RandomPercentPosition(first, 0); } 
    133  
    134             if (second.X < Level.Left * 2) { RandomPercentPosition(second, 1); } 
    135  
    136             if (third.X < Level.Left * 2) { RandomPercentPosition(third, 2); } 
    137  
    138             if (fourth.X < Level.Left * 2) { RandomPercentPosition(fourth, 3); } 
     136                yearsLeft -= 0.01f; 
     137            } 
     138 
     139            labelYearsLeft.Text = (int) yearsLeft + " vuotta jäljellä enemmin maailman konkurssia"; 
     140 
     141            labelYearsLeft.Left = labelLeft; 
     142 
     143            for (int i = 0; i < 4; i++) 
     144            { 
     145                percents[i].X -= MOVEMENT_SPEED; 
     146                if (percents[i].X < Screen.Left * 1.2) { RandomPercentPosition(percents[i], i); } 
     147            } 
    139148 
    140149            for (int i = 0; i < points.Count; i++) { points[i] -= new Vector(MOVEMENT_SPEED, 0); } 
    141  
    142  
    143150        } 
    144151   } 
     
    181188   } 
    182189 
    183    private void Die (PhysicsObject a, PhysicsObject b) 
    184    { 
    185         player.Destroy(); 
    186         dead = true; 
    187         explosionSystem.AddEffect(player.Position, 1000); 
     190   private void Die (PhysicsObject a, PhysicsObject percent) 
     191   { 
     192        if (percent.Image.Equals(greenPercent)) 
     193        { 
     194            yearsLeft += 1; 
     195        } 
     196        else 
     197        { 
     198            player.Destroy(); 
     199            dead = true; 
     200            noteEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 150); 
     201            coinEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 150); 
     202        } 
    188203   } 
    189204 
     
    205220        down = true; 
    206221    } 
     222 
     223    private PhysicsObject CreatePercent (int index) 
     224    { 
     225        PhysicsObject physicsObject = new PhysicsObject(100, 100); 
     226        physicsObject.Image = greenOrRed(); 
     227        physicsObject.Tag = "Percent"; 
     228        percents[index] = physicsObject; 
     229        RandomPercentPosition(physicsObject, index); 
     230        Add(physicsObject); 
     231        return physicsObject; 
     232    } 
    207233} 
  • 2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.csproj.Debug.cachefile

    r8122 r8142  
    1 Content\particle.xnb 
    21Content\percent.xnb 
    32Content\percent_1.xnb 
     3Content\ruutuja.xnb 
     4Content\note.xnb 
     5Content\coin.xnb 
  • 2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/Arrow.csproj.FileListAbsolute.txt

    r8122 r8142  
    77C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\obj\x86\Debug\Arrow.exe 
    88C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\obj\x86\Debug\Arrow.pdb 
    9 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\particle.xnb 
    109C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\percent.xnb 
    1110C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\percent_1.xnb 
     11C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\ruutuja.xnb 
     12C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\note.xnb 
     13C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\coin.xnb 
  • 2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/ContentPipeline-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}.xml

    r8122 r8142  
    22<XnaContent xmlns:Pipeline="Microsoft.Xna.Framework.Content.Pipeline"> 
    33  <Asset Type="Pipeline:BuildItemCollection"> 
    4     <Item> 
    5       <Source>particle.png</Source> 
    6       <Name>particle</Name> 
    7       <Importer>TextureImporter</Importer> 
    8       <Processor>TextureProcessor</Processor> 
    9       <Options>None</Options> 
    10       <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\particle.xnb</Output> 
    11       <Time>2016-07-26T14:20:09.2824241+03:00</Time> 
    12     </Item> 
    134    <Item> 
    145      <Source>percent.png</Source> 
     
    2819      <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\percent_1.xnb</Output> 
    2920      <Time>2016-07-26T14:52:12.5064241+03:00</Time> 
     21    </Item> 
     22    <Item> 
     23      <Source>ruutuja.jpg</Source> 
     24      <Name>ruutuja</Name> 
     25      <Importer>TextureImporter</Importer> 
     26      <Processor>TextureProcessor</Processor> 
     27      <Options>None</Options> 
     28      <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\ruutuja.xnb</Output> 
     29      <Time>2016-07-27T10:13:12.2122876+03:00</Time> 
     30    </Item> 
     31    <Item> 
     32      <Source>note.jpg</Source> 
     33      <Name>note</Name> 
     34      <Importer>TextureImporter</Importer> 
     35      <Processor>TextureProcessor</Processor> 
     36      <Options>None</Options> 
     37      <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\note.xnb</Output> 
     38      <Time>2016-07-27T10:29:57.9114414+03:00</Time> 
     39    </Item> 
     40    <Item> 
     41      <Source>coin.png</Source> 
     42      <Name>coin</Name> 
     43      <Importer>TextureImporter</Importer> 
     44      <Processor>TextureProcessor</Processor> 
     45      <Options>None</Options> 
     46      <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\coin.xnb</Output> 
     47      <Time>2016-07-27T10:30:39.3061092+03:00</Time> 
    3048    </Item> 
    3149    <BuildSuccessful>true</BuildSuccessful> 
  • 2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/cachefile-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}-targetpath.txt

    r8122 r8142  
    1 Content\particle.xnb 
    21Content\percent.xnb 
    32Content\percent_1.xnb 
     3Content\ruutuja.xnb 
     4Content\note.xnb 
     5Content\coin.xnb 
  • 2016/30/JoonasL/Arrow/Arrow/ArrowContent/ArrowContent.contentproj

    r8122 r8142  
    4646  </ItemGroup> 
    4747  <ItemGroup> 
    48     <Compile Include="particle.png"> 
    49       <Name>particle</Name> 
    50       <Importer>TextureImporter</Importer> 
    51       <Processor>TextureProcessor</Processor> 
    52     </Compile> 
    53   </ItemGroup> 
    54   <ItemGroup> 
    5548    <Compile Include="percent.png"> 
    5649      <Name>percent</Name> 
     
    6659    </Compile> 
    6760  </ItemGroup> 
     61  <ItemGroup> 
     62    <Compile Include="ruutuja.jpg"> 
     63      <Name>ruutuja</Name> 
     64      <Importer>TextureImporter</Importer> 
     65      <Processor>TextureProcessor</Processor> 
     66    </Compile> 
     67  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="note.jpg"> 
     70      <Name>note</Name> 
     71      <Importer>TextureImporter</Importer> 
     72      <Processor>TextureProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="coin.png"> 
     77      <Name>coin</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
    6882  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    6983  <!--  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.