Changeset 673 for 2010/23


Ignore:
Timestamp:
2010-06-10 11:46:48 (13 years ago)
Author:
paaaanro
Message:
 
Location:
2010/23/teematma/Tasohyppely2
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/teematma/Tasohyppely2/Content/Content.contentproj

    r645 r673  
    6868    </Compile> 
    6969  </ItemGroup> 
     70  <ItemGroup> 
     71    <Compile Include="taso.png"> 
     72      <Name>taso</Name> 
     73      <Importer>TextureImporter</Importer> 
     74      <Processor>TextureProcessor</Processor> 
     75    </Compile> 
     76  </ItemGroup> 
    7077  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    7178  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2010/23/teematma/Tasohyppely2/Peli.cs

    r645 r673  
    33using Jypeli.ScreenObjects; 
    44using Jypeli.Assets; 
     5using System.Collections.Generic; 
    56 
    67 
     
    1213        const double hyppyVoima = 2000; 
    1314 
     15        const int ruudunLeveys = 50; 
     16        const int ruudunKorkeus = 50; 
     17 
     18 
    1419        IntMeter pisteLaskuri; 
    1520        ValueDisplay pisteNaytto; 
     
    2530        { 
    2631            kenttaNro = 0; 
    27             Level.Width = 9000; 
    28             Level.Height = 1000; 
     32            Level.Width = 1800; 
     33            Level.Height = 1050; 
    2934 
    3035            // Luodaan pistelaskuri 
     
    4146            // Zoomataan lähemmäksi 
    4247            Camera.ZoomFactor = 2.0; 
    43  
    44             Camera.StayInLevel = true; 
     48            //Camera.ZoomToLevel(); 
     49            //Camera.StayInLevel = false; 
    4550 
    4651            seuraavaKentta(); 
     
    6873        void luoKentta() 
    6974        { 
    70             Level.CreateBorders(); 
    71             Level.Background.CreateGradient( Color.LightYellow, Color.DarkMagenta ); 
    72  
     75            Level.CreateBorders(1.0, false); 
     76            Level.Background.CreateGradient( Color.Lime, Color.DarkMagenta ); 
     77 
     78            var merkit = new Dictionary<char, ObjectCreator>(); 
     79            merkit['X'] = lisaaTaso; 
     80            merkit['M'] = lisaaMaali; 
     81            merkit['P'] = lisaaPelaajat; 
     82 
     83            char[,] ruudut = Tiles.ReadFromFile("kentta.txt"); 
     84            Tiles.Insert(this, ruudut, merkit, 50, 50); 
     85 
     86            /* 
    7387            lisaaTaso(-4200, -500); 
    7488            lisaaTaso(-4100, -400); 
     
    8599            lisaaTaso(-4500, -500); 
    86100            lisaaTaso(-4400, -500); 
    87  
    88             for (int i = 0; i < 1000; i++) 
     101            */ 
     102            for (int i = 0; i < 10; i++) 
    89103            { 
    90104                lisaaPallo(); 
    91105            } 
    92106            lisaaMaali(); 
    93             lisaaPelaajat(); 
    94         } 
    95  
    96         void lisaaTaso( double x, double y ) 
    97         { 
    98             PhysicsObject taso = PhysicsObject.CreateStaticObject( 100, 50 ); 
    99             taso.Color = Color.DarkCyan; 
     107        } 
     108 
     109        PhysicsObject lisaaTaso() 
     110        { 
     111            PhysicsObject taso = PhysicsObject.CreateStaticObject( 50, 50 ); 
     112            taso.Image = LoadImage("taso"); 
    100113            taso.LinearDamping = 1; 
    101114            taso.Tag = "taso"; 
    102             taso.X = x; 
    103             taso.Y = y; 
    104             Add( taso ); 
     115            return taso; 
     116 
    105117        } 
    106118 
     
    118130        } 
    119131 
    120         void lisaaPelaajat() 
    121         { 
    122             //pelaaja1 = new PlatformCharacter( 40, 40 ); 
     132        PhysicsObject lisaaPelaajat() 
     133        { 
    123134            pelaaja1 = new PhysicsObject(40, 40, Shapes.Circle); 
    124135            pelaaja1.Mass = 2.0; 
     
    127138            pelaaja1.KineticFriction = 1; 
    128139            pelaaja1.LinearDamping = 0.95; 
    129  
    130             pelaaja1.X = Level.Left + 120; 
    131             pelaaja1.Y = Level.Bottom + 120; 
     140            pelaaja1.Restitution = 0.4; 
    132141 
    133142            AddCollisionHandler( pelaaja1, osuiMaaliin ); 
    134             AddCollisionHandler(pelaaja1, lisaaHyppy); 
     143            AddCollisionHandler( pelaaja1, lisaaHyppy); 
    135144             
    136             Add( pelaaja1 ); 
    137         } 
    138  
    139         void lisaaMaali() 
     145            return pelaaja1; 
     146        } 
     147 
     148        PhysicsObject lisaaMaali() 
    140149        { 
    141150            PhysicsObject maali = PhysicsObject.CreateStaticObject( 50, 50, Shapes.Circle ); 
    142151            maali.Tag = "maali"; 
    143152            maali.IgnoresCollisionResponse = true; 
    144             maali.X = 30; 
    145             maali.Y = -60; 
    146153            maali.Image = LoadImage( "tahti" ); 
    147             Add( maali ); 
     154            return maali; 
    148155        } 
    149156 
     
    172179        void liikuta( PhysicsObject hahmo, Vector nopeus ) 
    173180        { 
    174             //hahmo.Walk( nopeus ); Kokeile liikuttamiseen .Push-metodia 
     181            //hahmo.Walk( nopeus ); //Kokeile liikuttamiseen .Push-metodia 
    175182            hahmo.Push(nopeus); 
    176183        } 
  • 2010/23/teematma/Tasohyppely2/Tasohyppely2.csproj

    r565 r673  
    8989    <Content Include="Game.ico" /> 
    9090    <Content Include="GameThumbnail.png" /> 
     91    <Content Include="kentta.txt"> 
     92      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     93    </Content> 
    9194  </ItemGroup> 
    9295  <ItemGroup> 
Note: See TracChangeset for help on using the changeset viewer.