source: 2016/30/AleksiN/name/name/name/name.cs @ 8115

Revision 8115, 1.7 KB checked in by almajono, 4 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 name : PhysicsGame
10{
11    PhysicsStructure tires = new PhysicsStructure();
12    public override void Begin()
13    {
14       points();
15
16        Surface level = Surface.CreateBottom(Level, 30, 100, 10, 100);
17        Add(level);
18
19        Gravity = new Vector(0.0, -800.0);
20
21        PhysicsObject leftTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
22        PhysicsObject rightTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
23        leftTire.X = -65.0;
24        leftTire.Y = -250.0;
25        rightTire.X = 65.0;
26        rightTire.Y = -250.0;
27        tires = new PhysicsStructure(leftTire, rightTire);
28        Add(tires);
29
30        Keyboard.Listen(Key.Left, ButtonState.Down, movement, null, new Vector(-2000, 0));
31        Keyboard.Listen(Key.Right, ButtonState.Down, movement, null, new Vector(2000, 0));
32        Keyboard.Listen(Key.Up, ButtonState.Down, angle, null, new Vector(-500, 0));
33        Keyboard.Listen(Key.Down, ButtonState.Down, angle, null, new Vector(500, 0));
34
35        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
36    }
37
38    void movement(Vector movement)
39    {
40        tires.Push(movement);
41    }
42
43    void angle(Vector angle)
44    {
45
46    }
47
48    IntMeter pointCounter;
49
50    void points()
51    {
52        pointCounter = new IntMeter(0);
53        Label pointLabel = new Label();
54        pointLabel.X = Screen.Left + 100;
55        pointLabel.Y = Screen.Top - 100;
56        pointLabel.TextColor = Color.Black;
57        pointLabel.Color = Color.White;
58        pointLabel.BindTo(pointCounter);
59        Add(pointLabel);
60    }
61
62}
Note: See TracBrowser for help on using the repository browser.