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

Revision 8137, 2.2 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
12    Image tire = LoadImage("tire");
13    PhysicsStructure tires;
14    public override void Begin()
15
16    {
17
18        SmoothTextures = true;
19        IsFullScreen = true;
20
21        SpawnTires();
22        Points();
23        Keys();
24       
25        Surface level = Surface.CreateBottom(Level, 30, 100, 10, 100);
26        Add(level);
27        Gravity = new Vector(0.0, -800.0);
28
29        //Wind = new Vector(-25, 0);
30        //Smoke smoke = new Smoke();
31        //smoke.Position = tires.Position;
32        //Add(smoke);
33       
34    }
35
36    void SpawnTires()
37    {
38        PhysicsObject leftTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
39        PhysicsObject rightTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
40        leftTire.X = -65.0;
41        leftTire.Y = -250.0;
42        rightTire.X = 65.0;
43        rightTire.Y = -250.0;
44        leftTire.Image = tire;
45        rightTire.Image = tire;
46        tires = new PhysicsStructure(leftTire, rightTire);
47        Add(tires);
48    }
49    void Keys()
50    {
51        Keyboard.Listen(Key.Down, ButtonState.Down, Movement, null, new Vector(-2000, 0));
52        Keyboard.Listen(Key.Up, ButtonState.Down, Movement, null, new Vector(2000, 0));
53        Keyboard.Listen(Key.Left, ButtonState.Down, Angle, null, 10.0);
54        Keyboard.Listen(Key.Right, ButtonState.Down, Angle, null, -10.0);
55        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
56    }
57    void Movement(Vector movement)
58    {
59        tires.Push(movement);
60    }
61    void Angle(double ammount)
62    {
63        tires.AngularVelocity = ammount;
64    }
65    IntMeter pointCounter;
66    void Points()
67    {
68        pointCounter = new IntMeter(0);
69        Label pointLabel = new Label();
70        pointLabel.X = Screen.Left + 100;
71        pointLabel.Y = Screen.Top - 100;
72        pointLabel.TextColor = Color.Black;
73        pointLabel.Color = Color.White;
74        pointLabel.BindTo(pointCounter);
75        Add(pointLabel);
76    }
77
78}
Note: See TracBrowser for help on using the repository browser.