Exemplo n.º 1
0
 public override void tick(Game game, bool up, bool down, bool left, bool right, bool use)
 {
     if (firstTick)
     {
         firstTick = false;
         Sound.altar.play();
     }
     if (up || down) Sound.click2.play();
     if (up) selected--;
     if (down) selected++;
     if (selected < 0) selected = 0;
     if (selected >= options.Length) selected = options.Length - 1;
     if (use)
     {
         Sound.click1.play();
         if (selected == 0)
         {
             game.setMenu(null);
             game.newGame();
         }
         if (selected == 1)
         {
             game.setMenu(new InstructionsMenu());
         }
         if (selected == 2)
         {
             game.setMenu(new AboutMenu());
         }
     }
 }
Exemplo n.º 2
0
 public override void tick(Game game, bool up, bool down, bool left, bool right, bool use)
 {
     if (tickDelay > 0) tickDelay--;
     else if (use)
     {
         game.setMenu(null);
     }
 }
Exemplo n.º 3
0
 public override void tick(Game game, bool up, bool down, bool left, bool right, bool use)
 {
     if (tickDelay > 0) tickDelay--;
     else if (use)
     {
         Sound.click1.play();
         game.setMenu(new TitleMenu());
     }
 }
Exemplo n.º 4
0
        public static Level LoadLevel(Game game, LevelEnum levelEnum)
        {
            Level level;
            if (!loaded.TryGetValue(levelEnum, out level))
            {
                System.Drawing.Bitmap levelMap = null;
                Type levelType = null;
                switch (levelEnum)
                {
                    case LevelEnum.Crypt:
                        levelMap = global::com.mojang.escape.Properties.Resources.crypt;
                        levelType = typeof(CryptLevel);
                        break;
                    case LevelEnum.Dungeon:
                        levelMap = global::com.mojang.escape.Properties.Resources.dungeon;
                        levelType = typeof(DungeonLevel);
                        break;
                    case LevelEnum.Ice:
                        levelMap = global::com.mojang.escape.Properties.Resources.ice;
                        levelType = typeof(IceLevel);
                        break;
                    case LevelEnum.Overworld:
                        levelMap = global::com.mojang.escape.Properties.Resources.overworld;
                        levelType = typeof(OverworldLevel);
                        break;
                    case LevelEnum.Start:
                        levelMap = global::com.mojang.escape.Properties.Resources.start;
                        levelType = typeof(StartLevel);
                        break;
                    case LevelEnum.Temple:
                        levelMap = global::com.mojang.escape.Properties.Resources.temple;
                        levelType = typeof(TempleLevel);
                        break;
                }

                int w = levelMap.Width;
                int h = levelMap.Height;
                int[] pixels = new int[w * h];
                for (int y = 0; y < h; ++y)
                {
                    for (int x = 0; x < w; ++x)
                    {
                        pixels[x + y * w] = levelMap.GetPixel(x, y).ToArgb();
                    }
                }
                level = levelType.GetConstructor(new Type[] { }).Invoke(new object[] { }) as Level;
                level.init(game, w, h, pixels);
                loaded.Add(levelEnum, level);
            }
            return level;
        }
Exemplo n.º 5
0
        public EscapeComponent()
        {
            System.Drawing.Size size = new System.Drawing.Size(WIDTH * SCALE, HEIGHT * SCALE);
            this.DoubleBuffered = true;
            this.Size = size;
            this.MaximumSize = size;
            this.MinimumSize = size;

            this.game = new Game();
            this.screen = new Screen(WIDTH, HEIGHT);

            this.img = new System.Drawing.Bitmap(WIDTH, HEIGHT);

            this.m_timer.Interval = 1000 / 60;
            this.m_timer.Tick += new System.EventHandler(timer_Tick);
        }
Exemplo n.º 6
0
 public virtual void tick(Game game, bool up, bool down, bool left, bool right, bool use)
 {
 }
Exemplo n.º 7
0
        public virtual void init(Game game, int w, int h, int[] pixels)
        {
            this.game = game;

            player = game.player;

            solidWall.col = Art.GetColor(wallCol);
            solidWall.tex = Art.GetColor(wallTex);
            this.width = w;
            this.height = h;
            blocks = new Block[width * height];

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    int col = pixels[x + y * w] & 0xffffff;
                    int id = 255 - ((pixels[x + y * w] >> 24) & 0xff);

                    Block block = getBlock(x, y, col);
                    block.id = id;

                    if (block.tex == -1) block.tex = wallTex;
                    if (block.floorTex == -1) block.floorTex = floorTex;
                    if (block.ceilTex == -1) block.ceilTex = ceilTex;
                    if (block.col == -1) block.col = Art.GetColor(wallCol);
                    if (block.floorCol == -1) block.floorCol = Art.GetColor(floorCol);
                    if (block.ceilCol == -1) block.ceilCol = Art.GetColor(ceilCol);

                    blocks[x + y * w] = block;
                    block.level = this;
                    block.x = x;
                    block.y = y;
                }
            }

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    int col = pixels[x + y * w] & 0xffffff;
                    decorateBlock(x, y, blocks[x + y * w], col);
                }
            }
        }
Exemplo n.º 8
0
 public override void init(Game game, int w, int h, int[] pixels)
 {
     base.init(game, w, h, pixels);
     base.trigger(6, true);
     base.trigger(7, true);
 }
Exemplo n.º 9
0
        public void render(Game game)
        {
            for (int x = 0; x < width; x++) {
                zBufferWall[x] = 0;
            }
            for (int i = 0; i < width * height; i++) {
                zBuffer[i] = 10000;
            }
            rot = game.player.rot;
            xCam = game.player.x - Math.Sin(rot) * 0.3;
            yCam = game.player.z - Math.Cos(rot) * 0.3;
            zCam = -0.2 + Math.Sin(game.player.bobPhase * 0.4) * 0.01 * game.player.bob - game.player.y;

            this.xCenter = width / 2.0;
            this.yCenter = height / 3.0;

            rCos = Math.Cos(rot);
            rSin = Math.Sin(rot);

            fov = height;

            Level level = game.level;
            int r = 6;

            int xCenter = (int)(Math.Floor(xCam));
            int zCenter = (int)(Math.Floor(yCam));
            for (int zb = zCenter - r; zb <= zCenter + r; zb++) {
                for (int xb = xCenter - r; xb <= xCenter + r; xb++) {
                    Block c = level.getBlock(xb, zb);
                    Block e = level.getBlock(xb + 1, zb);
                    Block s = level.getBlock(xb, zb + 1);

                    DoorBlock doorBlock = c as DoorBlock;
                    if (null != doorBlock)
                    {
                        double rr = 1 / 8.0;
                        double openness = 1 - doorBlock.openness * 7 / 8;
                        if (e.solidRender) {
                            renderWall(xb + openness, zb + 0.5 - rr, xb, zb + 0.5 - rr, c.tex, (c.col & 0xfefefe) >> 1, 0, openness);
                            renderWall(xb, zb + 0.5 + rr, xb + openness, zb + 0.5 + rr, c.tex, (c.col & 0xfefefe) >> 1, openness, 0);
                            renderWall(xb + openness, zb + 0.5 + rr, xb + openness, zb + 0.5 - rr, c.tex, c.col, 0.5 - rr, 0.5 + rr);
                        } else {
                            renderWall(xb + 0.5 - rr, zb, xb + 0.5 - rr, zb + openness, c.tex, c.col, openness, 0);
                            renderWall(xb + 0.5 + rr, zb + openness, xb + 0.5 + rr, zb, c.tex, c.col, 0, openness);
                            renderWall(xb + 0.5 - rr, zb + openness, xb + 0.5 + rr, zb + openness, c.tex, (c.col & 0xfefefe) >> 1, 0.5 - rr, 0.5 + rr);
                        }

                    }

                    if (c.solidRender) {
                        if (!e.solidRender) {
                            renderWall(xb + 1, zb + 1, xb + 1, zb, c.tex, c.col);
                        }
                        if (!s.solidRender) {
                            renderWall(xb, zb + 1, xb + 1, zb + 1, c.tex, (c.col & 0xfefefe) >> 1);
                        }
                    } else {
                        if (e.solidRender) {
                            renderWall(xb + 1, zb, xb + 1, zb + 1, e.tex, e.col);
                        }
                        if (s.solidRender) {
                            renderWall(xb + 1, zb + 1, xb, zb + 1, s.tex, (s.col & 0xfefefe) >> 1);
                        }
                    }
                }
            }
            for (int zb = zCenter - r; zb <= zCenter + r; zb++) {
                for (int xb = xCenter - r; xb <= xCenter + r; xb++) {
                    Block c = level.getBlock(xb, zb);

                    for (int j = 0; j < c.entities.Count; j++) {
                        Entity e = c.entities[j];
                        for (int i = 0; i < e.sprites.Count; i++) {
                            Sprite sprite = e.sprites[i];
                            renderSprite(e.x + sprite.x, 0 - sprite.y, e.z + sprite.z, sprite.tex, sprite.col);
                        }
                    }

                    for (int i = 0; i < c.sprites.Count; i++) {
                        Sprite sprite = c.sprites[i];
                        renderSprite(xb + sprite.x, 0 - sprite.y, zb + sprite.z, sprite.tex, sprite.col);
                    }
                }
            }

            renderFloor(level);
        }