forked from jwmcglynn/TeamQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GymEnvironment.cs
74 lines (63 loc) · 2.9 KB
/
GymEnvironment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Collision.Shapes;
namespace Sputnik
{
class GymEnvironment : GameEnvironment
{
BulletEmitter emit;
Random r = new Random();
public GymEnvironment(Controller ctrl)
: base(ctrl)
{
SpecialAbility special = new SpecialAbility();
special.LoadTexture(contentManager, "bullet");
special.Position = new Vector2(300.0f, 100.0f);
special.DesiredVelocity = new Vector2(0.0f, 0.0f);
AddChild(special);
// emit = new BulletEmitter(this, BulletEmitter.BulletStrength.Weak, true);
// emit = new BulletEmitter(this, BulletEmitter.BulletStrength.Medium, true);
emit = new BulletEmitter(this, BulletEmitter.BulletStrength.Strong, true);
emit.Position = new Vector2(210.0f, 300.0f);
emit.Rotation = (float)3.14 * 3 / 2;
AddChild(emit);
for (int i = 0; i < 20; i++)
{
/*AddChild(new TestShip((float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
0, 0,
(float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
(float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
this));*/
Ship s = new Ship(null, this);
s.TestShip((float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
0, 0,
(float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
(float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Width, (float)r.NextDouble() * ctrl.Graphics.GraphicsDevice.Viewport.Height,
this);
AddChild(s);
}
Ship s2 = new Ship(null, this);
s2.TestShip(150, 150, 0, 0, this);
AddChild(s2);
//AddChild(new TestShip(150, 150, 0, 0, this));
AddChild(new Crosshair(this));
LoadMap("gym.tmx");
}
public override void Update(float elapsedTime)
{
KeyboardState kb = Keyboard.GetState();
emit.IsShooting = kb.IsKeyDown(Keys.Space);
const float k_cameraVel = 150.0f;
if (kb.IsKeyDown(Keys.Up)) m_viewportPosition.Y -= k_cameraVel * elapsedTime;
if (kb.IsKeyDown(Keys.Left)) m_viewportPosition.X -= k_cameraVel * elapsedTime;
if (kb.IsKeyDown(Keys.Down)) m_viewportPosition.Y += k_cameraVel * elapsedTime;
if (kb.IsKeyDown(Keys.Right)) m_viewportPosition.X += k_cameraVel * elapsedTime;
base.Update(elapsedTime);
}
}
}