Ignore:
Timestamp:
2016-07-07 14:56:38 (3 years ago)
Author:
tesatapa
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/RuhanAnjanK/Noname/Noname/Noname/Noname.cs

    r7945 r7956  
    99public class Noname : PhysicsGame 
    1010{ 
    11     const double speed = 2000; 
     11    const double speed = 30000; 
    1212    const double jumpspeed = 750; 
    1313    const int TILE_SIZE = 40; 
     
    1818    Image treeimage = LoadImage("tree2"); 
    1919    Image grassimage = LoadImage("grass2"); 
     20    Image[] charecterimages = LoadImages("CJ1", "CJ2", "CJ3", "CJ4", "CJ5", "CJ6", "CJ7", "CJ8"); 
     21    Image[] charecterrunimages = LoadImages("CR1", "CR2", "CR3", "CR4", "CR5", "CR6"); 
     22    Boolean rotation = true; 
     23    Image startimage = LoadImage("CR4"); 
     24    Image cacphonicimage = LoadImage("orange2"); 
    2025 
    2126    SoundEffect collectsound = LoadSoundEffect("maali"); 
     
    4449        level.SetTileMethod('&', AddBarrier); 
    4550        level.SetTileMethod('D', AddGrass); 
     51        level.SetTileMethod('O', AddOrange); 
    4652        level.Execute(TILE_SIZE, TILE_SIZE); 
    4753 
    4854        Level.CreateBorders(); 
    49         Level.Background.CreateGradient(Color.Brown, Color.Brown); 
     55        Level.Background.Image = grassimage; 
     56        Level.Background.FitToLevel(); 
    5057    } 
    5158 
     
    5663        soil.Color = Color.Brown; 
    5764        Add(soil); 
     65    } 
     66     
     67    void AddOrange(Vector place, double width, double hieght) 
     68    { 
     69        GameObject orange = new GameObject(width, hieght); 
     70        orange.Position = place; 
     71        orange.Image = cacphonicimage; 
     72        orange.Tag = orange; 
     73        orange.Color = Color.Orange; 
     74        Add(orange); 
     75 
    5876    } 
    5977 
     
    123141        player1.Position = place; 
    124142        player1.Mass = 4.0; 
    125         player1.Image = playerimage; 
    126143        AddCollisionHandler(player1, "apple", HitApple); 
    127144        player1.CollisionIgnoreGroup = 5; 
     145        player1.Image = startimage; 
    128146        Add(player1); 
    129147        player1.CanRotate = false; 
     
    135153        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "end game"); 
    136154 
    137         Keyboard.Listen(Key.Left, ButtonState.Down, move, "move right", player1, new Vector(-speed, 0)); 
    138         Keyboard.Listen(Key.Left, ButtonState.Released, player1.Stop, ""); 
    139         Keyboard.Listen(Key.Right, ButtonState.Down,move, "move left", player1, new Vector(speed, 0)); 
    140         Keyboard.Listen(Key.Right, ButtonState.Released, player1.Stop, ""); 
    141         Keyboard.Listen(Key.Up, ButtonState.Down, move, "player jumps", player1, new Vector(0, speed)); 
    142         Keyboard.Listen(Key.Up, ButtonState.Released, player1.Stop, ""); 
    143         Keyboard.Listen(Key.Down, ButtonState.Down, move, "player jumps", player1, new Vector(0, -speed)); 
    144         Keyboard.Listen(Key.Down, ButtonState.Released, player1.Stop, ""); 
     155        Keyboard.Listen(Key.Left, ButtonState.Pressed, move, "move right", player1, new Vector(-speed, 0)); 
     156       // Keyboard.Listen(Key.Left, ButtonState.Released, , ""); 
     157        Keyboard.Listen(Key.Right, ButtonState.Pressed,moveright, "move left", player1, new Vector(speed, 0)); 
     158        //Keyboard.Listen(Key.Right, ButtonState.Released, player1.Stop, ""); 
     159        Keyboard.Listen(Key.Up, ButtonState.Pressed, move, "player jumps", player1, new Vector(0, speed)); 
     160        //Keyboard.Listen(Key.Up, ButtonState.Released, player1.Stop, ""); 
     161        Keyboard.Listen(Key.Down, ButtonState.Pressed, move, "player jumps", player1, new Vector(0, -speed)); 
     162        //Keyboard.Listen(Key.Down, ButtonState.Released, player1.Stop, ""); 
     163        Keyboard.Listen(Key.Left, ButtonState.Released, animation, "", player1); 
     164        Keyboard.Listen(Key.Right, ButtonState.Released, animation, "", player1); 
     165        Keyboard.Listen(Key.Up, ButtonState.Released, animation, "", player1); 
     166        Keyboard.Listen(Key.Down, ButtonState.Released, animation, "", player1); 
    145167        /*ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "exit game"); 
    146168 
     
    155177    void move(PhysicsObject charecter, Vector speed) 
    156178    { 
     179        player1.Animation = new Animation(charecterrunimages); 
     180        if (speed.X <= 0.0) 
     181        { 
     182            player1.MirrorImage(); 
     183            rotation = false; 
     184        } 
     185        player1.Animation.Start(); 
    157186        charecter.Push(speed); 
     187         
     188 
     189    } 
     190    void moveright(PhysicsObject charecter, Vector speed) 
     191    { 
     192        player1.Animation = new Animation(charecterrunimages); 
     193        if (rotation == false) 
     194        { 
     195            player1.MirrorImage(); 
     196            rotation = true; 
     197        } 
     198            player1.Animation.Start(); 
     199            charecter.Push(speed); 
     200 
     201 
     202    } 
     203 
     204    void animation(PhysicsObject charecter) 
     205 
     206    { 
     207        player1.Animation.Stop(); 
     208        player1.Stop(); 
    158209    } 
    159210 
Note: See TracChangeset for help on using the changeset viewer.