source: 2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo/HanniAndHoo.cs @ 9098

Revision 9098, 1.4 KB checked in by npo17_65, 2 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 HanniAndHoo : PhysicsGame
10{
11    Image HanninKuva = LoadImage("Hanni");
12    Image HoonKuva = LoadImage("Hoo");
13
14    PhysicsObject Hanni;
15    PhysicsObject Hoo;
16    public override void Begin()
17    {
18        LuoNappaimet();
19        LuoPelaajat();
20
21
22
23
24    }
25
26    void LuoPelaajat()
27    {
28
29        Hanni = new PhysicsObject(80.0, 80.0);
30        Hanni.X = Level.Left + 20.0;
31        Hanni.Y = 0.0;
32        Hanni.Shape = Shape.Circle;
33        Hanni.Color = Color.Blue;
34        Hanni.Image = HanninKuva;
35        Add(Hanni);
36        Hoo = new PhysicsObject(100.0, 100.0);
37        Hoo.X = Level.Right - 20.0;
38        Hoo.Y = 0.0;
39        Hoo.Shape = Shape.Circle;
40        Hoo.Color = Color.Red;
41        Hoo.Image = HoonKuva;
42        Add(Hoo);
43    }
44    void LuoNappaimet()
45    {
46        Keyboard.Listen(Key.W, ButtonState.Down, LiikutaHannia, null, new Vector(0, 1000));
47        Keyboard.Listen(Key.W, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0));
48
49        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
50
51    }
52    void LuoKentta()
53    {
54        Gravity = new Vector(0.0, -800.0);
55       
56    }
57
58
59
60    void LiikutaHannia(Vector vektori)
61    {
62        Hanni.Push(vektori);
63
64    }
65
66
67
68
69
70
71
72
73}
Note: See TracBrowser for help on using the repository browser.