Changeset 8868 for 2017


Ignore:
Timestamp:
2017-07-04 12:00:52 (2 years ago)
Author:
npo17_32
Message:

Fixed jitter in GravityAssist?, adeed new graphics.

Location:
2017/27/PyryS/GravityAssist
Files:
8 added
17 edited

Legend:

Unmodified
Added
Removed
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/GravityAssist.cs

    r8854 r8868  
    99public class GravityAssist : PhysicsGame 
    1010{ 
    11     const double nopeus = 300; 
     11    const double nopeus = 30; 
    1212    const double hyppyNopeus = 750; 
    1313    const int RUUDUN_KOKO = 40; 
     
    1818 
    1919    Image[] playerImages = LoadImages("Player0", "Player1"); 
    20     Image obstacleImage = LoadImage("tahti"); 
     20    Image wall0 = LoadImage("SpaceStationWall0"); 
     21    Image wall1 = LoadImage("SpaceStationWall1"); 
     22    Image obstacle0 = LoadImage("Obstacle0"); 
    2123 
    22      
     24 
    2325 
    2426    public override void Begin() 
    2527    { 
    26         Gravity = new Vector(0, -1000); 
     28        Gravity = new Vector(0, 0); 
    2729        SmoothTextures = false; 
    2830 
     
    3133 
    3234        Camera.Follow(player); 
    33         Camera.ZoomFactor = 1.6; 
     35        Camera.ZoomFactor = 1.0; 
    3436        Camera.StayInLevel = true; 
    3537    } 
     
    3840    { 
    3941        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    40         kentta.SetTileMethod('#', LisaaTaso); 
    41         kentta.SetTileMethod('*', LisaaTahti); 
     42        kentta.SetTileMethod('A', LisaaTaso, false); 
     43        kentta.SetTileMethod('V', LisaaTaso, true); 
     44        kentta.SetTileMethod('.', AddObstacle, true); 
     45        kentta.SetTileMethod(',', AddObstacle, false); 
    4246        kentta.SetTileMethod('N', LisaaPelaaja); 
    4347        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    4448        Level.CreateBorders(); 
    45         Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     49        Level.Background.CreateGradient(Color.White, Color.Black); 
    4650    } 
    4751 
    48     void LisaaTaso(Vector paikka, double leveys, double korkeus) 
     52    void LisaaTaso(Vector paikka, double leveys, double korkeus, bool flipped) 
    4953    { 
    5054        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    5155        taso.Position = paikka; 
    52         taso.Color = Color.Gray; 
     56        taso.Image = RandomGen.SelectOne(wall0, wall0, wall0, wall1); 
     57        if (flipped) taso.FlipImage(); 
    5358        taso.Restitution = 0.0; 
    5459        taso.KineticFriction = 0.0; 
    5560        taso.StaticFriction = 0.0; 
     61        taso.Tag = "wall"; 
    5662        Add(taso); 
    5763    } 
    5864 
    59     void LisaaTahti(Vector paikka, double leveys, double korkeus) 
     65    void AddObstacle(Vector paikka, double leveys, double korkeus, bool flipped) 
    6066    { 
    6167        PhysicsObject obstacle = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    6268        obstacle.IgnoresCollisionResponse = true; 
    63         obstacle.Position = paikka; 
    64         obstacle.Image = obstacleImage; 
     69        obstacle.Image = obstacle0; 
     70        if (flipped) 
     71        { 
     72            obstacle.FlipImage(); 
     73            obstacle.Position = paikka + new Vector(0, -10); 
     74        } 
     75        else 
     76        { 
     77            obstacle.Position = paikka + new Vector(0, 10); 
     78        } 
    6579        obstacle.Tag = "obstacle"; 
    6680        Add(obstacle); 
     
    6983    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    7084    { 
    71         player = new PhysicsObject(leveys, korkeus); 
     85        player = new PhysicsObject(32, 13); 
    7286        player.Position = paikka; 
    73         player.Mass = 20.0; 
     87        player.Mass = 100.0; 
    7488        player.CanRotate = false; 
    7589        player.KineticFriction = 0.0; 
     
    7791        player.Restitution = 0.0; 
    7892        player.Image = playerImages[0]; 
    79         //player.AnimIdle = new Animation(playerImages); 
    80         //player.AnimIdle.FPS = 15; 
    8193        player.Animation = new Animation(playerImages); 
    8294        player.Animation.FPS = 15; 
    83         AddCollisionHandler(player, "obstacle", playerdeath); 
     95        player.Animation.Start(); 
     96        AddCollisionHandler(player, playerdeath); 
    8497        Add(player); 
    85  
     98        player.IgnoresCollisionResponse = true; 
    8699        Timer liikutusAjastin = new Timer(); 
    87100        liikutusAjastin.Interval = 0.02; 
    88         //liikutusAjastin.Timeout += delegate { player.Walk(Direction.Right); }; 
    89101        liikutusAjastin.Timeout += delegate { player.Velocity = new Vector(150, player.Velocity.Y); }; 
    90102        liikutusAjastin.Start(); 
     
    109121        if (GravityDirection == true) 
    110122        { 
    111             Gravity = new Vector(0, -1000); 
     123            //Gravity = new Vector(0, -1000); 
     124            //player.Hit(new Vector(0, -10)); 
     125            player.Velocity = new Vector(player.Velocity.X, -150); 
    112126            GravityDirection = false; 
     127            //Timer.SingleShot(0.2, delegate { player.TextureWrapSize = new Vector(1, 1); }); 
    113128            player.TextureWrapSize = new Vector(1, 1); 
    114129        } 
    115130        else if (GravityDirection == false) 
    116131        { 
    117             Gravity = new Vector(0, 1000); 
     132            //Gravity = new Vector(0, 1000); 
     133            player.Velocity = new Vector(player.Velocity.X, 150); 
     134            //player.Hit(new Vector(0, 10)); 
    118135            GravityDirection = true; 
     136            //Timer.SingleShot(0.2, delegate { player.TextureWrapSize = new Vector(1, -1); }); 
    119137            player.TextureWrapSize = new Vector(1, -1); 
    120138        } 
     
    123141    void playerdeath(PhysicsObject hahmo, PhysicsObject obstacle) 
    124142    { 
    125         MessageDisplay.Add("You died."); 
    126         obstacle.Destroy(); 
    127         player.Destroy(); 
     143 
     144        if (obstacle.Tag == "obstacle") 
     145        { 
     146 
     147            MessageDisplay.Add("You died."); 
     148            player.Destroy(); 
     149        } 
     150 
     151        if (obstacle.Tag == "wall") 
     152        { 
     153            //Gravity = Vector.Zero; 
     154            player.Velocity = new Vector(player.Velocity.X, 0); 
     155            if (player.Y < obstacle.Top) 
     156            { 
     157                player.Y = obstacle.Bottom - player.Height / 2.0 - 0.2; 
     158            } 
     159            else 
     160            { 
     161                player.Y = obstacle.Top + player.Height / 2.0 + 0.2; 
     162            } 
     163        } 
     164         
    128165    } 
    129166} 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/GravityAssist.csproj.Debug.cachefile

    r8854 r8868  
    44Content\Player0.xnb 
    55Content\Player1.xnb 
     6Content\SpaceStationWall1.xnb 
     7Content\SpaceStationWall0.xnb 
     8Content\Obstacle0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml

    r8854 r8868  
    2727      <Options>None</Options> 
    2828      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\kentta1.xnb</Output> 
    29       <Time>2017-07-03T14:59:56.4607876+03:00</Time> 
     29      <Time>2017-07-04T11:52:27.4886554+03:00</Time> 
    3030    </Item> 
    3131    <Item> 
     
    3636      <Options>None</Options> 
    3737      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Player0.xnb</Output> 
    38       <Time>2017-07-03T13:24:44.0070879+03:00</Time> 
     38      <Time>2017-07-04T11:34:57.1060532+03:00</Time> 
    3939    </Item> 
    4040    <Item> 
     
    4545      <Options>None</Options> 
    4646      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Player1.xnb</Output> 
    47       <Time>2017-07-03T14:08:22.7535216+03:00</Time> 
     47      <Time>2017-07-04T11:34:54.9063827+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>SpaceStationWall1.png</Source> 
     51      <Name>SpaceStationWall1</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWall1.xnb</Output> 
     56      <Time>2017-07-04T10:33:23.290659+03:00</Time> 
     57    </Item> 
     58    <Item> 
     59      <Source>SpaceStationWall0.png</Source> 
     60      <Name>SpaceStationWall0</Name> 
     61      <Importer>TextureImporter</Importer> 
     62      <Processor>TextureProcessor</Processor> 
     63      <Options>None</Options> 
     64      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWall0.xnb</Output> 
     65      <Time>2017-07-04T10:33:41.6525652+03:00</Time> 
     66    </Item> 
     67    <Item> 
     68      <Source>Obstacle0.png</Source> 
     69      <Name>Obstacle0</Name> 
     70      <Importer>TextureImporter</Importer> 
     71      <Processor>TextureProcessor</Processor> 
     72      <Options>None</Options> 
     73      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Obstacle0.xnb</Output> 
     74      <Time>2017-07-04T11:57:24.71403+03:00</Time> 
    4875    </Item> 
    4976    <BuildSuccessful>true</BuildSuccessful> 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/GravityAssist.csproj.FileListAbsolute.txt

    r8854 r8868  
    1212C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Player0.xnb 
    1313C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Player1.xnb 
     14C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWall1.xnb 
     15C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWall0.xnb 
     16C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Obstacle0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt

    r8854 r8868  
    44Content\Player0.xnb 
    55Content\Player1.xnb 
     6Content\SpaceStationWall1.xnb 
     7Content\SpaceStationWall0.xnb 
     8Content\Obstacle0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssistContent/GravityAssistContent.contentproj

    r8854 r8868  
    7676    </Compile> 
    7777  </ItemGroup> 
     78  <ItemGroup> 
     79    <Compile Include="SpaceStationWall0.png"> 
     80      <Name>SpaceStationWall0</Name> 
     81      <Importer>TextureImporter</Importer> 
     82      <Processor>TextureProcessor</Processor> 
     83    </Compile> 
     84  </ItemGroup> 
     85  <ItemGroup> 
     86    <Compile Include="SpaceStationWall1.png"> 
     87      <Name>SpaceStationWall1</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90    </Compile> 
     91  </ItemGroup> 
     92  <ItemGroup> 
     93    <Compile Include="Obstacle0.png"> 
     94      <Name>Obstacle0</Name> 
     95      <Importer>TextureImporter</Importer> 
     96      <Processor>TextureProcessor</Processor> 
     97    </Compile> 
     98  </ItemGroup> 
    7899  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    79100  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssistContent/kentta1.txt

    r8854 r8868  
    1 #################################################################### 
    2            *        * 
     1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
     2          ,       ,        , 
    33                  
    4  N    *        * 
    5 ##################################################################### 
     4 N            .         . 
     5VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV 
Note: See TracChangeset for help on using the changeset viewer.