source: 2016/24/ArttuH/anythin/anythin/anythin/anythin.cs @ 7290

Revision 7290, 2.3 KB checked in by armahiek, 5 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 anythin : PhysicsGame
10{
11    PhysicsObject Player1;
12    LaserGun Zapper;
13    Image playerim = LoadImage("Rocket");
14
15    public override void Begin()
16    {
17       
18        Assets(); //enemies
19        Things(); //Players n stuff
20        Controll(); //Controls
21        IsFullScreen = false;
22
23       
24    }
25    void Things()
26    {
27        //Creating Player
28        Player1 = new PhysicsObject(50.0, 50.0);
29        Player1.Mass = 0.10;
30        Player1.LinearDamping = 0.95;
31        Player1.MomentOfInertia = 50;
32        Player1.MaxAngularVelocity = 15;
33        Player1.Image = playerim; 
34        Add(Player1);
35
36        //Creating Gun
37        Zapper = new LaserGun(0,0);
38        Zapper.InfiniteAmmo = true; 
39        Zapper.ProjectileCollision = Hits;
40        Zapper.CanHitOwner = false;
41        Zapper.Image = null;
42        Zapper.FireRate = 1;
43        Player1.Add(Zapper);
44
45    }
46    void Hits(PhysicsObject Laser, PhysicsObject Target)//Laser collicion detection
47    {
48        Laser.Destroy();
49    }
50    void Assets()
51    {
52
53    }
54    void Controll()//Controls
55    {
56        Keyboard.Listen(Key.W, ButtonState.Down, MoveSomewhere, null);
57        Keyboard.Listen(Key.S, ButtonState.Down, MoveSomewhere1, null);
58        Keyboard.Listen(Key.A, ButtonState.Down, RotateSomewhere1, null);
59        Keyboard.Listen(Key.D, ButtonState.Down, RotateSomewhere2, null);
60        Keyboard.Listen(Key.Space, ButtonState.Down, Shoot1, null, Zapper);
61        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
62    }
63    void Shoot1(LaserGun Gun)
64    {
65
66        PhysicsObject Laser = Gun.Shoot();
67
68     
69
70       
71    }
72    void MoveSomewhere()
73    {
74        Vector Forward = Vector.FromLengthAndAngle(100.0, Player1.Angle);
75        Player1.Push(Forward);
76    }
77    void MoveSomewhere1()
78    {
79        Vector Backwards = Vector.FromLengthAndAngle(-100.0, Player1.Angle);
80        Player1.Push(Backwards);
81    }
82    void RotateSomewhere1()
83    {
84        Player1.ApplyTorque(500.0);
85    }
86    void RotateSomewhere2()
87    {
88        Player1.ApplyTorque(-500.0);
89    }
90}   
Note: See TracBrowser for help on using the repository browser.