Beispiel #1
0
        public override void render()
        {
            SpriteBatch batch = engine.sbatch;

            int spy = Math.Abs(BatchUtil.getYScroll()) >> 4;
            int spx = Math.Abs(BatchUtil.getXScroll()) >> 4;
            int tpy = (Math.Abs(BatchUtil.getYScroll()) >> 4) + (PokeEngine.HEIGHT >> 4) + 1;
            int tpx = (Math.Abs(BatchUtil.getXScroll()) >> 4) + (PokeEngine.WIDTH >> 4) + 1;

            if (spy < 0)
            {
                spy = 0;
            }
            if (spx < 0)
            {
                spx = 0;
            }
            if (tpy >= w)
            {
                tpy = h - 1;
            }
            if (tpx >= h)
            {
                tpx = w - 1;
            }
            if (BatchUtil.getYScroll() >> 4 > 0)
            {
                spy = 0;
            }
            if (BatchUtil.getXScroll() >> 4 > 0)
            {
                spx = 0;
            }

            int vx, vy, sx, sy, tx, ty;

            vx = vy = sx = sy = tx = ty = 0;

            //not the best idea i had here, but it'll do!

            if (direction == ConnectionDirection.LEFT)
            {
                vx -= w << 4;
                vy += offset << 4;

                ty = h;
                sx = w - 16;
                tx = w;
            }
            else if (direction == ConnectionDirection.UP)
            {
                vx += offset << 4;
                vy -= h << 4;

                sy = h - 16;
                ty = h;
                tx = w;
            }
            else if (direction == ConnectionDirection.RIGHT)
            {
                vx += parent.w << 4;
                vy += offset << 4;

                ty = h;
                tx = 16;
            }
            else if (direction == ConnectionDirection.DOWN)
            {
                vx += offset << 4;
                vy += parent.h << 4;

                ty = 16;
                tx = w;
            }

            for (int y = sy; y <= ty; y++)
            {
                for (int x = sx; x <= tx; x++)
                {
                    if (getTile(x, y) != null)                       //just in case ...
                    {
                        tilerendered++;
                        getTile(x, y).render(engine, vx, vy);
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void render()
        {
            SpriteBatch batch = engine.sbatch;

            {             //START OF SCROLL OFFSET VALUES
                int xs = 0, ys = 0;
                if (player != null)
                {
                    int xx = (int)player.x;
                    int yy = (int)player.y;

                    xs = (int)-(xx - (PokeEngine.WIDTH >> 1));
                    ys = (int)-(yy - (PokeEngine.HEIGHT >> 1));

                    int xMax = (Tile.WIDTH * w) - PokeEngine.WIDTH;
                    int yMax = (Tile.WIDTH * h) - PokeEngine.HEIGHT;

                    /*if (xs > 0 && connectionLeft == null) xs = 0;
                     * if (ys > 0 && connectionUp == null) ys = 0;
                     * if (-xs > xMax && connectionRight == null) xs = -xMax;
                     * if (-ys > yMax && connectionDown == null) ys = -yMax;*/
                }
                BatchUtil.setScroll(xs, ys);
            }             //END OF SCROLL OFFSET VALUES

            int spy = Math.Abs(BatchUtil.getYScroll()) >> 4;
            int spx = Math.Abs(BatchUtil.getXScroll()) >> 4;
            int tpy = (Math.Abs(BatchUtil.getYScroll()) >> 4) + (PokeEngine.HEIGHT >> 4) + 1;
            int tpx = (Math.Abs(BatchUtil.getXScroll()) >> 4) + (PokeEngine.WIDTH >> 4) + 1;

            if (spy < 0)
            {
                spy = 0;
            }
            if (spx < 0)
            {
                spx = 0;
            }
            if (tpy >= w)
            {
                tpy = h - 1;
            }
            if (tpx >= h)
            {
                tpx = w - 1;
            }
            if (BatchUtil.getYScroll() >> 4 > 0)
            {
                spy = 0;
            }
            if (BatchUtil.getXScroll() >> 4 > 0)
            {
                spx = 0;
            }

            //Console.WriteLine("tpx:" + tpx + ", " + (w << 4));

            if (connectionLeft != null && spx < 1)
            {
                connectionLeft.render();
            }
            if (connectionUp != null && spy < 1)
            {
                connectionUp.render();
            }
            if (connectionRight != null && tpx <= w << 4)
            {
                connectionRight.render();
            }
            if (connectionDown != null && tpy <= h << 4)
            {
                connectionDown.render();
            }



            for (int y = spy; y <= tpy; y++)
            {
                for (int x = spx; x <= tpx; x++)
                {
                    //Console.WriteLine(x + " + " + y + " * " + w + " = " + index + " (length: " + tiles.Length));

                    if (getTile(x, y) != null)                       //just in case ...
                    {
                        tilerendered++;
                        getTile(x, y).render(engine, 0, 0);
                    }
                }
            }

            //Console.WriteLine("rendered: " + tilerendered);
            tilerendered = 0;

            player.render();
            foreach (Entity e in entities)
            {
                if (e != null)
                {
                    e.render();
                }
            }
        }