]> git.r.bdr.sh - rbdr/super-polarity/blob - Super Polarity/MainShip.cs
92ccab798fff4d3b6206e8f0e43d7bc8e2c7f583
[rbdr/super-polarity] / Super Polarity / MainShip.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8
9 namespace SuperPolarity
10 {
11 class MainShip : Ship
12 {
13
14 uint Multiplier;
15 uint Lives;
16 uint Score;
17 ParticleEngine particleEngine;
18
19 public override void Initialize(ContentManager Content, Texture2D texture, Vector2 position)
20 {
21 base.Initialize(Content, texture, position);
22
23 Multiplier = 1;
24 Lives = 3;
25 Score = 0;
26
27 List<Texture2D> texturesList = new List<Texture2D>();
28 texturesList.Add(Content.Load<Texture2D>("Graphics\\circle"));
29 texturesList.Add(Content.Load<Texture2D>("Graphics\\diamond"));
30 texturesList.Add(Content.Load<Texture2D>("Graphics\\star"));
31
32 particleEngine = new ParticleEngine(texturesList, Position);
33
34 BindInput();
35 }
36
37 void BindInput()
38 {
39 InputController.Bind("moveX", HandleHorizontalMovement);
40 InputController.Bind("moveY", HandleVerticalMovement);
41 }
42
43 public void HandleHorizontalMovement(float value)
44 {
45 Acceleration.X = value * AccelerationRate;
46 }
47
48 public void HandleVerticalMovement(float value)
49 {
50 Acceleration.Y = value * AccelerationRate;
51 }
52
53 public override void Update(GameTime gameTime)
54 {
55 base.Update(gameTime);
56 particleEngine.EmitterLocation = Position;
57 particleEngine.Update();
58 }
59
60 public override void Draw(SpriteBatch spriteBatch)
61 {
62 particleEngine.Draw(spriteBatch);
63 base.Draw(spriteBatch);
64 }
65 }
66 }