source: 2013/26/AleksiP/tasohyppely/tasohyppely/tasohyppely/tasohyppely/tasohyppely.cs @ 4220

Revision 4220, 1.7 KB checked in by alpynnon, 10 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 tasohyppely : PhysicsGame
10{
11
12    PlatformCharacter Pelaaja;
13
14
15
16    public override void Begin()
17    {
18        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
19        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
20    }
21        void LuoKentta()
22
23        {
24ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Kentta1");
25
26            ruudut.SetTileMethod(Color.Purple, LuoPelaaja);
27            ruudut.SetTileMethod(Color.Black, LuoTaso);
28            ruudut.SetTileMethod(Color.Green, LuoTahti);
29
30            ruudut.Execute(20, 20);
31        }
32
33    void LuoPelaaja(Vector Paikka, double leveys, double korkeus)
34    {
35        Pelaaja = new PlatformCharacter(10, 10);
36        Pelaaja.Position = Paikka;
37        AddCollisionHandler(LuoPelaaja, "tahti", TormaaTahteen);
38        Add(Pelaaja);
39
40    }
41
42    void LuoTaso(Vector paikka, double leveys, double korkeus)
43    {
44        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus);
45        taso.Position = paikka; 
46        taso.Image = groundImage;
47        taso.CollisionIgnoreGroup = 1;
48        Add(taso);
49    }
50
51    void LuoTahti(Vector paikka, double leveys, double korkeus)
52    {
53    PhysicsObject tahti = new PhysicsObject(5, 5);
54    tahti.IgnoresCollisionResponse = true;
55    tahti.Position = paikka;
56    tahti.Image = tahdenkuva;
57    tahti.Tag = "tahti";
58    add(tahti, 1);
59}
60
61    void AsetaOhjaimet()
62    {
63        Keyboard.Listen(Key.W ButtonState.Down);
64        Keyboard.Listen(Key.W ButtonState.Released);
65
66
67
68    }
69}
Note: See TracBrowser for help on using the repository browser.