Exemple #1
0
        public bool CollidingWithTrans(double xVal, double yVal, double characterWidth, double characterHeight)
        {
            //Console.WriteLine("window sizes " + BasicSprite.GetBoundaries().Width + " " + BasicSprite.GetBoundaries().Height);
            //Console.WriteLine("texture sizes " + trans.GetWidth() + " " + trans.GetHeight());
            double width_factor  = (double)BasicSprite.GetBoundaries().Width / trans.GetWidth();
            double height_factor = (double)BasicSprite.GetBoundaries().Height / trans.GetHeight();

            //Console.WriteLine("orig vals: " + xVal + " " + yVal); Console.WriteLine("orig vals: " + xVal + " " + yVal);
            xVal /= width_factor;
            yVal /= height_factor;
            //Console.WriteLine("new vals: " + xVal + " " + yVal);
            //Console.WriteLine("orig sizes: " + characterWidth + " " + characterHeight);
            characterWidth  /= width_factor;
            characterHeight /= height_factor;
            //Console.WriteLine("new sizes: " + characterWidth + " " + characterHeight);
            Color col1, col2, col3, col4, col5, col6, col7, col8;
            int   xTex, yTex;

            ///left point
            xTex = (int)xVal;
            yTex = (int)yVal;
            col1 = overData[yTex * trans.GetWidth() + xTex];
            ///right point
            xTex = (int)(xVal + characterWidth);
            yTex = (int)yVal;
            col2 = overData[yTex * trans.GetWidth() + xTex];
            ///down left point
            xTex = (int)xVal;
            yTex = (int)(yVal + characterHeight);
            col3 = overData[yTex * trans.GetWidth() + xTex];
            ///down right point
            xTex = (int)(xVal + characterWidth);
            yTex = (int)(yVal + characterHeight);
            col4 = overData[yTex * trans.GetWidth() + xTex];
            ///up center
            xTex = (int)(xVal + characterWidth / 2);
            yTex = (int)yVal;
            col5 = overData[yTex * trans.GetWidth() + xTex];
            //left center
            xTex = (int)xVal;
            yTex = (int)(yVal + characterHeight / 2);
            col6 = overData[yTex * trans.GetWidth() + xTex];
            ///down center
            xTex = (int)(xVal + characterWidth / 2);
            yTex = (int)(yVal + characterHeight);
            col7 = overData[yTex * trans.GetWidth() + xTex];
            ///right center
            xTex = (int)(xVal + characterWidth);
            yTex = (int)(yVal + characterHeight / 2);
            col8 = overData[yTex * trans.GetWidth() + xTex];
            //Console.WriteLine("cols " + col1+" "+col2+" "+col3+" "+col4+" "+col5+" "+col6+" "+col7+" "+col8);
            return(col1.A != 0 && col2.A != 0 && col3.A != 0 && col4.A != 0 && col5.A != 0 && col6.A != 0 && col7.A != 0 && col8.A != 0); /// alpha in trans is differente from zero
        }
Exemple #2
0
 public bool InsideRightLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: "+pos+" basic sprite right limit " + BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X+" bool " + (pos.X + pos.Width < BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X));
     return(pos.X + pos.Width < BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X);
 }
Exemple #3
0
 public bool InsideLeftLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: " + pos + " basic sprite left limit " + BasicSprite.GetBoundaries().X+" bool " + (pos.X > BasicSprite.GetBoundaries().Y));
     return(pos.X > BasicSprite.GetBoundaries().X);
 }
Exemple #4
0
 public bool InsideUpLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: " + pos + " basic sprite up limit " + BasicSprite.GetBoundaries().Y+" bool "+ (pos.Y > BasicSprite.GetBoundaries().Y));
     return(pos.Y > BasicSprite.GetBoundaries().Y);
 }
Exemple #5
0
 public bool InsideDownLimit(Rectangle pos)
 {
     return(pos.Y + pos.Height < BasicSprite.GetBoundaries().Height + BasicSprite.GetBoundaries().Y);
 }