Changeset 8896 for 2017


Ignore:
Timestamp:
2017-07-04 14:59:57 (2 years ago)
Author:
npo17_32
Message:

Added Random Generation to GravityAssist?, some more graphics, and changed controls and added a restart button.

Location:
2017/27/PyryS/GravityAssist
Files:
19 edited

Legend:

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

    r8868 r8896  
    1717    PhysicsObject player; 
    1818 
     19    // Load all images 
    1920    Image[] playerImages = LoadImages("Player0", "Player1"); 
    2021    Image wall0 = LoadImage("SpaceStationWall0"); 
    2122    Image wall1 = LoadImage("SpaceStationWall1"); 
     23 
     24    Image damagedWall0 = LoadImage("SpaceStationWallDamaged0"); 
     25 
    2226    Image obstacle0 = LoadImage("Obstacle0"); 
     27    Image background0 = LoadImage("background0"); 
    2328 
    2429 
    25  
     30    // Beginning Function 
    2631    public override void Begin() 
    2732    { 
     
    3540        Camera.ZoomFactor = 1.0; 
    3641        Camera.StayInLevel = true; 
     42 
     43        //Level.Background.Image = background0; 
     44 
     45        GameObject backgroundObject0 = new GameObject(Level.Width, 128); 
     46        backgroundObject0.Image = background0; 
     47        backgroundObject0.TextureWrapSize = new Vector(16, 1); 
     48        Add(backgroundObject0, -3); 
     49        Layers[-3].RelativeTransition = new Vector(0.5, 0); 
    3750    } 
    38  
     51    // Level loading function 
    3952    void LuoKentta() 
    4053    { 
     
    4760        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    4861        Level.CreateBorders(); 
    49         Level.Background.CreateGradient(Color.White, Color.Black); 
     62        Level.Background.Color = Color.Black; 
    5063    } 
    51  
     64    // Level generation function 
    5265    void LisaaTaso(Vector paikka, double leveys, double korkeus, bool flipped) 
    5366    { 
    5467        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    5568        taso.Position = paikka; 
    56         taso.Image = RandomGen.SelectOne(wall0, wall0, wall0, wall1); 
     69        taso.Image = RandomGen.SelectOne(wall0, wall0, wall0, wall0,wall0, wall0, wall0, wall0, wall1, damagedWall0); 
    5770        if (flipped) taso.FlipImage(); 
    5871        taso.Restitution = 0.0; 
     
    6275        Add(taso); 
    6376    } 
    64  
     77    // Obstacle creation function 
    6578    void AddObstacle(Vector paikka, double leveys, double korkeus, bool flipped) 
    6679    { 
    67         PhysicsObject obstacle = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     80        PhysicsObject obstacle = PhysicsObject.CreateStaticObject(korkeus, leveys, Shape.FromImage(obstacle0)); 
    6881        obstacle.IgnoresCollisionResponse = true; 
    6982        obstacle.Image = obstacle0; 
     
    7184        { 
    7285            obstacle.FlipImage(); 
    73             obstacle.Position = paikka + new Vector(0, -10); 
     86            obstacle.Position = paikka + new Vector(Convert.ToInt64(RandomGen.NextDouble(Level.Left, Level.Right)), -10); 
    7487        } 
    7588        else 
    7689        { 
    77             obstacle.Position = paikka + new Vector(0, 10); 
     90            obstacle.Position = paikka + new Vector(Convert.ToInt64(RandomGen.NextDouble(Level.Left, Level.Right)), 10); 
    7891        } 
    7992        obstacle.Tag = "obstacle"; 
    8093        Add(obstacle); 
    8194    } 
    82  
     95    // Player creation and movement function 
    8396    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    8497    { 
     
    94107        player.Animation.FPS = 15; 
    95108        player.Animation.Start(); 
    96         AddCollisionHandler(player, playerdeath); 
     109        AddCollisionHandler(player, collision); 
    97110        Add(player); 
    98111        player.IgnoresCollisionResponse = true; 
     
    103116 
    104117    } 
    105  
     118    // Controls function 
    106119    void LisaaNappaimet() 
    107120    { 
    108121        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Exit"); 
    109122 
    110         Keyboard.Listen(Key.W, ButtonState.Pressed, GravitySwap, "Gravity Switched", player, 1.0); 
     123        Keyboard.Listen(Key.R, ButtonState.Pressed, restart, "Restart"); 
     124 
     125        Keyboard.Listen(Key.Space, ButtonState.Pressed, GravitySwap, "Gravity Switched", player, 1.0); 
    111126 
    112127        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Exit"); 
     
    115130    } 
    116131 
    117  
     132    // Gravity swap function 
    118133    void GravitySwap(PhysicsObject Player, double Force) 
    119134    { 
    120         //Player.Jump(Force); 
    121135        if (GravityDirection == true) 
    122136        { 
    123             //Gravity = new Vector(0, -1000); 
    124             //player.Hit(new Vector(0, -10)); 
    125137            player.Velocity = new Vector(player.Velocity.X, -150); 
    126138            GravityDirection = false; 
    127             //Timer.SingleShot(0.2, delegate { player.TextureWrapSize = new Vector(1, 1); }); 
    128139            player.TextureWrapSize = new Vector(1, 1); 
    129140        } 
    130141        else if (GravityDirection == false) 
    131142        { 
    132             //Gravity = new Vector(0, 1000); 
    133143            player.Velocity = new Vector(player.Velocity.X, 150); 
    134             //player.Hit(new Vector(0, 10)); 
    135144            GravityDirection = true; 
    136             //Timer.SingleShot(0.2, delegate { player.TextureWrapSize = new Vector(1, -1); }); 
    137145            player.TextureWrapSize = new Vector(1, -1); 
    138146        } 
    139147    } 
    140  
    141     void playerdeath(PhysicsObject hahmo, PhysicsObject obstacle) 
     148    // Collision management function 
     149    void collision(PhysicsObject hahmo, PhysicsObject obstacle) 
    142150    { 
    143151 
     
    147155            MessageDisplay.Add("You died."); 
    148156            player.Destroy(); 
     157            restart(); 
    149158        } 
    150159 
    151160        if (obstacle.Tag == "wall") 
    152161        { 
    153             //Gravity = Vector.Zero; 
    154162            player.Velocity = new Vector(player.Velocity.X, 0); 
    155163            if (player.Y < obstacle.Top) 
     
    161169                player.Y = obstacle.Top + player.Height / 2.0 + 0.2; 
    162170            } 
    163         } 
    164          
     171        }   
     172    } 
     173    void restart() 
     174    { 
     175        ClearAll(); 
     176        Begin(); 
    165177    } 
    166178} 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/GravityAssist.csproj.Debug.cachefile

    r8868 r8896  
    77Content\SpaceStationWall0.xnb 
    88Content\Obstacle0.xnb 
     9Content\Background0.xnb 
     10Content\SpaceStationWallDamaged0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml

    r8868 r8896  
    2727      <Options>None</Options> 
    2828      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\kentta1.xnb</Output> 
    29       <Time>2017-07-04T11:52:27.4886554+03:00</Time> 
     29      <Time>2017-07-04T14:27:37.572787+03:00</Time> 
    3030    </Item> 
    3131    <Item> 
     
    5454      <Options>None</Options> 
    5555      <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> 
     56      <Time>2017-07-04T13:37:29.670253+03:00</Time> 
    5757    </Item> 
    5858    <Item> 
     
    7272      <Options>None</Options> 
    7373      <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> 
     74      <Time>2017-07-04T14:52:46.5246411+03:00</Time> 
     75    </Item> 
     76    <Item> 
     77      <Source>Background0.png</Source> 
     78      <Name>Background0</Name> 
     79      <Importer>TextureImporter</Importer> 
     80      <Processor>TextureProcessor</Processor> 
     81      <Options>None</Options> 
     82      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Background0.xnb</Output> 
     83      <Time>2017-07-04T13:42:01.3237597+03:00</Time> 
     84    </Item> 
     85    <Item> 
     86      <Source>SpaceStationWallDamaged0.png</Source> 
     87      <Name>SpaceStationWallDamaged0</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90      <Options>None</Options> 
     91      <Output>C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWallDamaged0.xnb</Output> 
     92      <Time>2017-07-04T14:13:37.9909988+03:00</Time> 
    7593    </Item> 
    7694    <BuildSuccessful>true</BuildSuccessful> 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/GravityAssist.csproj.FileListAbsolute.txt

    r8868 r8896  
    1515C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWall0.xnb 
    1616C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Obstacle0.xnb 
     17C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\Background0.xnb 
     18C:\MyTemp\PyryS\GravityAssist\GravityAssist\GravityAssist\bin\x86\Debug\Content\SpaceStationWallDamaged0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssist/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt

    r8868 r8896  
    77Content\SpaceStationWall0.xnb 
    88Content\Obstacle0.xnb 
     9Content\Background0.xnb 
     10Content\SpaceStationWallDamaged0.xnb 
  • 2017/27/PyryS/GravityAssist/GravityAssist/GravityAssistContent/GravityAssistContent.contentproj

    r8868 r8896  
    9797    </Compile> 
    9898  </ItemGroup> 
     99  <ItemGroup> 
     100    <Compile Include="Background0.png"> 
     101      <Name>Background0</Name> 
     102      <Importer>TextureImporter</Importer> 
     103      <Processor>TextureProcessor</Processor> 
     104    </Compile> 
     105  </ItemGroup> 
     106  <ItemGroup> 
     107    <Compile Include="SpaceStationWallDamaged0.png"> 
     108      <Name>SpaceStationWallDamaged0</Name> 
     109      <Importer>TextureImporter</Importer> 
     110      <Processor>TextureProcessor</Processor> 
     111    </Compile> 
     112  </ItemGroup> 
    99113  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    100114  <!--  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

    r8868 r8896  
    1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
    2           ,       ,        , 
     1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
     2          ,,,,,,,,,,,,,,,,,, 
    33                  
    4  N            .         . 
    5 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV 
     4 N       ................... 
     5VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV 
Note: See TracChangeset for help on using the changeset viewer.