コード例 #1
0
ファイル: Player.cs プロジェクト: endert/Intro2D
        /// <summary>
        /// Calls the Move methode
        /// </summary>
        public override void Update(GameTime gTime)
        {
            float div = sprite.Position.Y - maxheight;

            touchedGround = !InGame.map.CheckDownWards(this);

            if(touchedGround && isFalling)
            {
                InGame.SpawnParticles(sprite.Position + new Vector2f((sprite.Texture.Size.X * sprite.Scale.X) /2, sprite.Texture.Size.Y*sprite.Scale.Y));
            }

            if (touchedGround && !isJumping)
                maxheight = sprite.Position.Y;

            if(!isJumping && InGame.map.CheckDownWards(this))
            {
                sprite.Position += new Vector2f(0, (div + 3f) / 200);
            }
            if (isJumping)
            {
                sprite.Position -= new Vector2f(0, (div + 3f) / 200);
                if (Math.Abs(div) < 1f)
                {
                    isJumping = false;
                }
            }

            movementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds;
            KeyboardInput();
            Move();

            isFalling = !touchedGround && !isJumping;
        }
コード例 #2
0
ファイル: Particle.cs プロジェクト: endert/Intro2D
        public void Update(GameTime t)
        {
            if (LifeTime < 0)
                IsAlive = false;

            S.Position += D * Speed * (1 + t.Ellapsed.Milliseconds);
            LifeTime -= (1 + (float)t.Ellapsed.TotalMilliseconds);
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: endert/Intro2D
 public Game()
 {
     uint x = 85;
     win = new RenderWindow(new VideoMode(16*x, 9*x), "Intro2D-04-Beispiel-Player-Enemy");
     WindowSize = win.Size;
     win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
     gTime = new GameTime();
 }
コード例 #4
0
ファイル: TitleScreen.cs プロジェクト: endert/Intro2D
        public EGameState Update(GameTime t)
        {
            if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                return EGameState.None;

            for(int i = 0; i<(int)Keyboard.Key.KeyCount; ++i)
            {
                if (Keyboard.IsKeyPressed((Keyboard.Key)i))
                {
                    return EGameState.InGame;
                }
            }

            return EGameState.TitleScreen;
        }
コード例 #5
0
ファイル: InGame.cs プロジェクト: endert/Intro2D
        public void Initialize()
        {
            gTime = new GameTime();
            BackgroundMusic = new Sound(new SoundBuffer("Sound/asia_1.ogg"));
            BackgroundMusic.Loop = true;
            BackgroundMusic.Volume = 30;
            BackgroundMusic.Play();
            pHandler = new List<ParticleHandler>();

            JumpSound = new Sound(new SoundBuffer("Sound/jumpSound.wav"));
            JumpSound.Volume = 100;

            map = new Map(new System.Drawing.Bitmap("Pictures/Map.bmp"));
            Player = new Player(new Vector2f(map.TileSize + 30, map.TileSize + 30));
            enemy1 = new Enemy("Pictures/EnemyGreen.png", new Vector2f(800, 100), "Pictures/EnemyGreenMove.png");
            enemy2 = new Enemy("Pictures/EnemyRed.png", new Vector2f(100, 600), "Pictures/EnemyGreenMove.png");

            Camera = new View(new FloatRect(0, 0, 1200, 1000));
        }
コード例 #6
0
ファイル: ParticleHandler.cs プロジェクト: endert/Intro2D
        public void Update(GameTime t)
        {
            if (SpawnTime < 0 && Particles.Count <= 0)
                IsAlive = false;

            if (SpawnTime > 0)
                Particles.Add(new Particle(Pos, new Vector2f(2 * (float)R.NextDouble() - 1, 2 * (float)R.NextDouble() - 1), new CircleShape(1), Color.Black, (float)R.NextDouble() * 4, (float)R.NextDouble() / 4, R.Next(200)));

            for (int i = 0; i < Particles.Count; ++i)
            {
                if (!Particles[i].IsAlive)
                {
                    Particles.RemoveAt(i);
                    i--;
                    continue;
                }

                Particles[i].Update(t);
            }

            SpawnTime -= 1 + (float)t.Ellapsed.TotalMilliseconds;
        }
コード例 #7
0
ファイル: InGame.cs プロジェクト: endert/Intro2D
        public EGameState Update(GameTime t)
        {
            gTime.Update();
            Player.Update(gTime);
            enemy1.Update(gTime);
            enemy2.Update(gTime);
            Camera.Move(VectorToMoveView());
            for(int i = 0; i<pHandler.Count; ++i)
            {
                if (!pHandler[i].IsAlive)
                {
                    pHandler.RemoveAt(i);
                    i--;
                    continue;
                }
                pHandler[i].Update(t);
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                return EGameState.None;

            return EGameState.InGame;
        }
コード例 #8
0
ファイル: GameObject.cs プロジェクト: endert/Intro2D
 /// <summary>
 /// abstract Methode, must be implemented by all subclasses which are not abstract
 /// <para>shall Update this instance by calling all needed Methods</para>
 /// </summary>
 public abstract void Update(GameTime gTime);