public void Draw(SpriteBatch spriteBatch, int destX, int destY) { int srcX = x + (currentFrame * width % image.Width); int srcY = y + (currentFrame * width / image.Width); spriteBatch.Draw(image, new Rectangle(OpenFE.guiScale(destX, destY, 1, guiAnim), OpenFE.guiScale(width, height, 1, guiAnim)), new Rectangle(srcX, srcY, width, height), Color.White); }
public void DrawNumbers(string text, int x, int y, SpriteBatch spriteBatch) { if (text.ToCharArray().Min() < '0' || text.ToCharArray().Max() > '9') { throw new ArgumentException("Non-number character in text"); } for (int i = 0; i < text.Length; i++) { spriteBatch.Draw(numbers, new Rectangle(OpenFE.guiScale(x + 7 * i, y), OpenFE.guiScale(8, 8)), new Rectangle(8 * (text[i] - '0'), 0, 8, 8), Color.White); } }
public void DrawText(string text, int x, int y, SpriteBatch spriteBatch, Color?color = null) { if (color == null) { color = Color.White; } int offset = 0; foreach (char c in text) { if (!textLoc.ContainsKey(c)) { break; } if (c == 'j') { offset -= 1; //j has an underhang(? don't know what to call it) } spriteBatch.Draw(font, new Rectangle(OpenFE.guiScale(x + offset, y), OpenFE.guiScale(size)), new Rectangle(textLoc[c].Item1, size), color.Value); offset += textLoc[c].Item2; } }
void DrawHP(int hp, int max, int num, SpriteBatch spriteBatch) { if (max > 40) { if (hp > 40) { for (int i = 0; i < 40; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 150), OpenFE.guiScale(2, 7)), new Rectangle(0, 7, 2, 7), Color.White); } for (int i = 0; i < hp - 40; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 143), OpenFE.guiScale(2, 7)), new Rectangle(0, 7, 2, 7), Color.White); } for (int i = hp - 40; i < max - 40; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 143), OpenFE.guiScale(2, 7)), new Rectangle(0, 0, 2, 7), Color.White); } } else { for (int i = 0; i < hp; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 150), OpenFE.guiScale(2, 7)), new Rectangle(0, 7, 2, 7), Color.White); } for (int i = hp; i < 40; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 150), OpenFE.guiScale(2, 7)), new Rectangle(0, 0, 2, 7), Color.White); } for (int i = 0; i < max - 40; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 143), OpenFE.guiScale(2, 7)), new Rectangle(0, 0, 2, 7), Color.White); } } spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(109 + 120 * (num - 1), 150), OpenFE.guiScale(1, 7)), new Rectangle(2, 0, 1, 7), Color.White); spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * (max - 40), 143), OpenFE.guiScale(1, 7)), new Rectangle(2, 0, 1, 7), Color.White); } else { for (int i = 0; i < hp; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 146), OpenFE.guiScale(2, 7)), new Rectangle(0, 7, 2, 7), Color.White); } for (int i = hp; i < max; i++) { spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * i, 146), OpenFE.guiScale(2, 7)), new Rectangle(0, 0, 2, 7), Color.White); } spriteBatch.Draw(hpBar, new Rectangle(OpenFE.guiScale(29 + 120 * (num - 1) + 2 * max, 146), OpenFE.guiScale(1, 7)), new Rectangle(2, 0, 1, 7), Color.White); } }