source: 2011/31/JoonasM/TankSurvival/TankSurvival/TankSurvival/Peli.cs @ 2509

Revision 2509, 1.9 KB checked in by joarmuho, 12 years ago (diff)

Talletus.

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public class Peli : PhysicsGame
10{
11    Image olionKuva = LoadImage("pelaaja");
12    PhysicsObject pelaaja;
13
14    public override void Begin()
15    {
16        LuoKenttä();
17
18        Level.CreateBorders(1.0, false);
19        Camera.ZoomToLevel();
20        Level.BackgroundColor = Color.ForestGreen;
21        pelaaja = new PhysicsObject(24, 45);
22        pelaaja.Image = olionKuva;
23        pelaaja.Restitution = 1.0;
24        pelaaja.KineticFriction = 1.0;
25        pelaaja.LinearDamping = 0.5;
26        Add( pelaaja );
27
28        Keyboard.Listen(Key.Left,  ButtonState.Down, 
29        LiikutaPelaajaa, null, new Vector( -250, 0 ));
30        Keyboard.Listen(Key.Right, ButtonState.Down, 
31        LiikutaPelaajaa, null, new Vector( 250, 0 ));
32        Keyboard.Listen(Key.Up, ButtonState.Down, 
33        LiikutaPelaajaa, null, new Vector( 0, 250 ));
34        Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector( 0, -250 ));
35        Keyboard.Listen(Key.A, ButtonState.Down, KäännäPelaajaa, null, 5.0);
36        Keyboard.Listen(Key.D, ButtonState.Down, KäännäPelaajaa, null, -5.0);
37        Keyboard.Listen(Key.A, ButtonState.Released, KäännäPelaajaa, null, 0.0);
38        Keyboard.Listen(Key.D, ButtonState.Released, KäännäPelaajaa, null, -0.0);
39        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");
40        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet");
41
42     }
43
44    void LuoKenttä()
45    {
46      TileMap ruudut = TileMap.FromLevelAsset("level1");
47    }
48
49    void KäännäPelaajaa(double kulmanopeus)
50    {
51        pelaaja.AngularVelocity = kulmanopeus;
52    }
53
54    void LiikutaPelaajaa(Vector vektori)
55    {
56        pelaaja.Move(vektori);
57    }
58}
Note: See TracBrowser for help on using the repository browser.