source: 2017/24/EllaT/The Dinosaur/The Dinosaur/The_Dinosaur/The_Dinosaur.cs @ 8683

Revision 8683, 1.7 KB checked in by npo17_26, 6 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public class The_Dinosaur : PhysicsGame
10{
11    //haosui hapsiu hapsui
12
13    PlatformCharacter dino;
14    Image dinokuva = LoadImage("DINOOOOOOO");
15    Image possukuva = LoadImage("se ilkee possuli");
16    public override void Begin()
17    {
18        // Moiiiiii
19
20        dino = new PlatformCharacter(215.0, 200.0);
21        dino.Image = dinokuva;
22        Add(dino);
23        dino.X = -500.0;
24        dino.Y = 0.0;
25
26        PhysicsObject sika = new PhysicsObject(150.0, 150.0);
27        sika.Image = possukuva;
28        Add(sika);
29        sika.X = 200.0;
30        sika.Y = -150.0;
31        sika.Oscillate(new Vector(1.0, 0.0), 500.0, 0.15);
32
33        Level.Background.Color = Color.SkyBlue;
34
35        PhysicsObject palikka = new PhysicsObject(700.0, 200.0);
36        palikka.MakeStatic();
37        Add(palikka);
38
39
40
41
42        Gravity = new Vector(0.0, -400.0);
43
44
45        Vector impulssi = new Vector(500.0, 0.0);
46        sika.Hit(impulssi);
47
48
49        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Hyppää");
50        Keyboard.Listen(Key.Right, ButtonState.Down, KaveleeOikealle, "kävelee oikealle");
51        Keyboard.Listen(Key.Left, ButtonState.Down, KaveleeVasemmalle, "kävelee vasemmalle");
52
53
54
55        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
56        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
57    }
58
59    void Hyppaa()
60    {
61        dino.ForceJump(175.0);
62
63    }
64
65    void KaveleeOikealle()
66    {
67        dino.Walk(150.0);
68
69    }
70
71    void KaveleeVasemmalle()
72    {
73        dino.Walk(-150.0);
74
75    }
76}
77
Note: See TracBrowser for help on using the repository browser.