]> git.r.bdr.sh - rbdr/super-polarity/blame - SuperPolarity/Player.cs
Update project to work on VS Code mac
[rbdr/super-polarity] / SuperPolarity / Player.cs
CommitLineData
9ad526c0 1using System;
74c15570
BB
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
b587e9d8
BB
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
74c15570
BB
7
8namespace SuperPolarity
9{
10 public class Player
11 {
12 public int Score;
13 public int Multiplier;
14 public int Lives;
15
b587e9d8
BB
16
17 SpriteFont DebugFont;
18 SuperPolarity Game;
19
20 Texture2D LifeSprite;
21
22 public Player(SuperPolarity game)
74c15570
BB
23 {
24 Score = 0;
25 Multiplier = 1;
26 Lives = 3;
b587e9d8
BB
27 Game = game;
28 DebugFont = Game.Content.Load<SpriteFont>("Fonts\\bigfont");
29 LifeSprite = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
74c15570
BB
30 }
31
32 public void AddScore(int value)
33 {
34 Score = Score + (value * Multiplier);
35 }
36
37 public void AddMultiplier(int value)
38 {
39 Multiplier = Multiplier + 1;
40 }
41
42 public void ResetMultiplier()
43 {
44 Multiplier = 1;
45 }
46
b587e9d8 47 public void Draw(SpriteBatch spriteBatch)
74c15570 48 {
b587e9d8
BB
49 var UiColor = new Color(0, 0, 0, 200);
50 var lightColor = new Color(0, 0, 0, 128);
bca44639
BB
51 spriteBatch.DrawString(DebugFont, Score.ToString(), new Vector2(40, 30), UiColor);
52 spriteBatch.DrawString(DebugFont, "x" + Multiplier.ToString(), new Vector2(40, 50), lightColor);
74c15570 53
bca44639 54 var lifePosition = new Vector2(Game.GraphicsDevice.Viewport.Width - 140, 30);
b587e9d8
BB
55 if (Lives > 4)
56 {
57 spriteBatch.Draw(LifeSprite, lifePosition, null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
58 spriteBatch.DrawString(DebugFont, "x " + Lives.ToString(), new Vector2(lifePosition.X + 8, lifePosition.Y + 5), UiColor);
59 }
60 else
61 {
62 for (var i = 0; i < Lives; i++)
63 {
64 spriteBatch.Draw(LifeSprite, new Vector2(lifePosition.X + (i * 28), lifePosition.Y), null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
65 }
66 }
74c15570
BB
67 }
68
69 public void Update()
70 {
71
72 }
b587e9d8
BB
73
74 public void Reset()
75 {
76 Score = 0;
77 Multiplier = 1;
78 Lives = 3;
79 }
74c15570
BB
80 }
81}