Esempio n. 1
0
        public void postProcess(Level level)
        {
            for (int i = 0; i < width * height; i++)
            {
                double zl = zBuffer[i];
                if (zl < 0)
                {
                    int xx = ((int)Math.Floor((i % width) - rot * 512 / (Math.PI * 2))) & 511;
                    int yy = i / width;
                    pixels[i] = Art.sky.pixels[xx + yy * 512] * 0x444455;
                }
                else
                {
                    int xp = (i % width);
                    int yp = (i / width) * 14;

                    double xx = ((i % width - width / 2.0) / width);
                    int col = pixels[i];
                    int brightness = (int)(300 - zl * 6 * (xx * xx * 2 + 1));
                    brightness = (brightness + ((xp + yp) & 3) * 4) >> 4 << 4;
                    if (brightness < 0) brightness = 0;
                    if (brightness > 255) brightness = 255;

                    int r = (col >> 16) & 0xff;
                    int g = (col >> 8) & 0xff;
                    int b = (col) & 0xff;

                    r = r * brightness / 255;
                    g = g * brightness / 255;
                    b = b * brightness / 255;

                    pixels[i] = r << 16 | g << 8 | b;
                }
            }
        }
Esempio n. 2
0
 public override void decorate(Level level, int x, int y)
 {
     Random random = new Random((x + y * 1000) * 341871231);
     double r = 0.4;
     for (int i = 0; i < 1000; i++)
     {
         int face = random.Next(4);
         if (face == 0 && level.getBlock(x - 1, y).solidRender)
         {
             torchSprite.x -= r;
             break;
         }
         if (face == 1 && level.getBlock(x, y - 1).solidRender)
         {
             torchSprite.z -= r;
             break;
         }
         if (face == 2 && level.getBlock(x + 1, y).solidRender)
         {
             torchSprite.x += r;
             break;
         }
         if (face == 3 && level.getBlock(x, y + 1).solidRender)
         {
             torchSprite.z += r;
             break;
         }
     }
 }
Esempio n. 3
0
 public override bool use(Level level, Item item)
 {
     open = !open;
     if (open)
         Sound.click1.play();
     else
         Sound.click2.play();
     return true;
 }
Esempio n. 4
0
 public void switchLevel(LevelEnum levelEnum, int id)
 {
     pauseTime = 30;
     level.removeEntityImmediately(player);
     level = Level.LoadLevel(this, levelEnum);
     level.findSpawn(id);
     player.x = level.xSpawn;
     player.z = level.ySpawn;
     ((LadderBlock) level.getBlock(level.xSpawn, level.ySpawn)).wait = true;
     player.x += Math.Sin(player.rot) * 0.2;
     player.z += Math.Cos(player.rot) * 0.2;
     level.addEntity(player);
 }
Esempio n. 5
0
        public void newGame()
        {
            Level.clear();
            level = Level.LoadLevel(this, LevelEnum.Start);

            player = new Player();
            player.level = level;
            level.player = player;
            player.x = level.xSpawn;
            player.z = level.ySpawn;
            level.addEntity(player);
            player.rot = Math.PI + 0.4;
        }
Esempio n. 6
0
        public override bool use(Level level, Item item)
        {
            pressed = !pressed;
            if (pressed) tex = 3;
            else tex = 2;

            level.trigger(id, pressed);
            if (pressed)
                Sound.click1.play();
            else
                Sound.click2.play();

            return true;
        }
Esempio n. 7
0
 public override bool use(Level level, Item item)
 {
     return false;
 }
Esempio n. 8
0
 public virtual bool use(Level level, Item item)
 {
     return false;
 }
Esempio n. 9
0
 public virtual void decorate(Level level, int x, int y)
 {
 }
Esempio n. 10
0
        private void renderFloor(Level level)
        {
            for (int y = 0; y < height; y++)
            {
                double yd = ((y + 0.5) - yCenter) / fov;

                bool floor = true;
                double zd = (4 - zCam * 8) / yd;
                if (yd < 0)
                {
                    floor = false;
                    zd = (4 + zCam * 8) / -yd;
                }

                for (int x = 0; x < width; x++)
                {
                    if (zBuffer[x + y * width] <= zd) continue;

                    double xd = (xCenter - x) / fov;
                    xd *= zd;

                    double xx = xd * rCos + zd * rSin + (xCam + 0.5) * 8;
                    double yy = zd * rCos - xd * rSin + (yCam + 0.5) * 8;

                    int xPix = (int)(xx * 2);
                    int yPix = (int)(yy * 2);
                    int xTile = xPix >> 4;
                    int yTile = yPix >> 4;

                    Block block = level.getBlock(xTile, yTile);
                    int col = block.floorCol;
                    int tex = block.floorTex;
                    if (!floor)
                    {
                        col = block.ceilCol;
                        tex = block.ceilTex;
                    }

                    if (tex < 0)
                    {
                        zBuffer[x + y * width] = -1;
                    }
                    else
                    {
                        zBuffer[x + y * width] = zd;
                        pixels[x + y * width] = Art.floors.pixels[((xPix & 15) + (tex % 8) * 16) + ((yPix & 15) + (tex / 8) * 16) * 128] * col;
                    }
                }
            }
        }