<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XNALib.Scenes;

namespace SoundScape.GameplaySceneComponents
{
    class Bouncer : Enemy
    {
        public Bouncer(GameplayScene scene, SpriteBatch spriteBatch, Vector2 position, Texture2D texture,
            SoundEffect soundEffect)
            : base(scene, spriteBatch, position, texture, soundEffect)
        {
        }

        public Bouncer(GameplayScene scene, SpriteBatch spriteBatch, Vector2 position, Texture2D texture,
            SoundEffect soundEffect, Color colour)
            : base(scene, spriteBatch, position, texture, soundEffect, colour)
        {
        }

        public override void Update(GameTime gameTime)
        {
            var eastCollisionRect = new Rectangle(
                x: (int)(Position.X + Hitbox.Width),
                y: (int)Position.Y,
                width: (int)Speed.X,
                height: Hitbox.Height);
            var westCollisionRect = new Rectangle(
                x: (int)(Position.X - Speed.X),
                y: (int)Position.Y,
                width: (int)Speed.X,
                height: Hitbox.Height);
            var northCollisionRect = new Rectangle(
                x: (int)Position.X,
                y: (int)(Position.Y - Speed.Y),
                width: (int)Speed.X,
                height: Hitbox.Height);
            var southCollisionRect = new Rectangle(
                x: (int)Position.X,
                y: (int)Position.Y,
                width: Hitbox.X,
                height: (int)Speed.Y);

            foreach (var gameComponent in this.Scene.Components)
            {
                if (gameComponent is GameplaySceneComponent && gameComponent is Player) // Bouncer set only to collide with player for debugging
                { 
                    var component = (GameplaySceneComponent)gameComponent;
                    if (component != this)
                    {
                        bool collissionEastWest =
                            component.Hitbox.Intersects(eastCollisionRect) ||
                            component.Hitbox.Intersects(westCollisionRect);
                        bool collissionNorthSouth =
                            component.Hitbox.Intersects(northCollisionRect) ||
                            component.Hitbox.Intersects(southCollisionRect);<commit_msg>Fixed bouncer collision.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XNALib.Scenes;

namespace SoundScape.GameplaySceneComponents
{
    class Bouncer : Enemy
    {
        public Bouncer(GameplayScene scene, SpriteBatch spriteBatch, Vector2 position, Texture2D texture,
            SoundEffect soundEffect)
            : base(scene, spriteBatch, position, texture, soundEffect)
        {
        }

        public Bouncer(GameplayScene scene, SpriteBatch spriteBatch, Vector2 position, Texture2D texture,
            SoundEffect soundEffect, Color colour)
            : base(scene, spriteBatch, position, texture, soundEffect, colour)
        {
        }

        public override void Update(GameTime gameTime)
        {
            int xSpeed = (int)Math.Abs(Speed.X * 3);
            int ySpeed = (int)Math.Abs(Speed.X * 3);

            var eastCollisionRect = new Rectangle(
                x: (int)(Hitbox.X + Hitbox.Width),
                y: (int)Hitbox.Y,
                width: xSpeed,
                height: Hitbox.Height);
            var westCollisionRect = new Rectangle(
                x: (int)(Hitbox.X - xSpeed),
                y: (int)Hitbox.Y,
                width: xSpeed,
                height: Hitbox.Height);
            var northCollisionRect = new Rectangle(
                x: (int)Hitbox.X,
                y: (int)(Hitbox.Y - ySpeed),
                width: Hitbox.Width,
                height: ySpeed);
            var southCollisionRect = new Rectangle(
                x: (int)Hitbox.X,
                y: (int)Hitbox.Y,
                width: Hitbox.Width,
                height: (int)(Hitbox.Height + ySpeed));

            foreach (var gameComponent in this.Scene.Components)
            {
                if (gameComponent is GameplaySceneComponent && gameComponent is Wall)
                { 
                    var component = (GameplaySceneComponent)gameComponent;
                    if (component != this)
                    {
                        bool collissionEastWest =
                            component.Hitbox.Intersects(eastCollisionRect) ||
                            component.Hitbox.Intersects(westCollisionRect);
                        bool collissionNorthSouth =
                            component.Hitbox.Intersects(northCollisionRect) ||
                            component.Hitbox.Intersects(southCollisionRect);
{'fraction_non_alphanumeric': 0.08302547151468015, 'fraction_numerical': 0.0019443904335990666, 'mean_word_length': 1.7188160676532769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '417191', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1289, 'n_words': 299}