public ResultNumber (int newX, int newY, bool chan) { sprite = new Sprite ("../../Assets/text.png"); x = newX; y = newY; indexY = 4; indexX = 2; change = chan; }
/// <summary> /// Calculates if rectangles describing two sprites /// are overlapping on screen. /// </summary> /// <param name="s1">First sprite</param> /// <param name="s2">Second sprite</param> /// <returns>Returns true if overlapping</returns> public static bool Overlaps(Sprite s1, Sprite s2) { float x1 = s1.Position.X; float y1 = s1.Position.Y; float h1 = s1.Size.Height; float w1 = s1.Size.Width; float x2 = s2.Position.X; float y2 = s2.Position.Y; float h2 = s2.Size.Height; float w2 = s2.Size.Width; if (x1 < x2 + w2 && x1 + w1 > x2 && y1 < y2 + h2 && h1 + y1 > y2) return true; return false; }
/// <summary> /// Calculates if rectangles describing two sprites /// are overlapping on screen. /// </summary> /// <param name="s1">First sprite</param> /// <param name="s2">Second sprite</param> /// <returns>Returns true if overlapping</returns> public static bool Overlaps(Sprite s1, Sprite s2) { if(s1.Position.Y > s2.Position.Y) { Sprite tmp = s1; s1 = s2; s2 = tmp; } float left1 = s1.Position.X; float right1 = s1.Position.X + s1.Size.Width; float bottom1 = s1.Position.Y + s1.Size.Height; float left2 = s2.Position.X; float right2 = s2.Position.X + s2.Size.Width; float top2 = s2.Position.Y; if(bottom1 < top2 || right1 < left2 || right2 < left1) { return false; } return true; }
public static void DrawSprite(Window window, Sprite sprite, int xpos, int ypos, int xoffset, int yoffset, int width, int height) { for (int y = yoffset; y < yoffset + height; y++) { for (int x = xoffset; x < xoffset + width; x++) { int position = (y * sprite.width * 4) + (x * 4); byte r = sprite.bitmap[position]; byte g = sprite.bitmap[position + 1]; byte b = sprite.bitmap[position + 2]; byte a = sprite.bitmap[position + 3]; if (a == 255) PutPixel(window, xpos + x - xoffset, ypos + y - yoffset, r, g, b); } } }
public Wall(Sprite sprite, Vector2 startPosition, Vector2 direction, float speed, ContentManager contMan, Rectangle collision, SoundEffect soundEffect) : base(sprite, startPosition, direction, speed, contMan, collision, soundEffect) { }