示例#1
0
 internal static void OnTick(TickEventArgs e)
 {
     if (Tick != null)
     {
         Tick(instance, e);
     }
 }
示例#2
0
		void Events_Tick(object sender, TickEventArgs e)
		{

			//There should be an easier way to get the video data to SDL
            
			timeElapsed += (e.SecondsElapsed);
			while (timeElapsed > 1.0 / file.Header.Fps && frameQueue.Count > 0)
			{
				timeElapsed -= (float)(1.0f / file.Header.Fps);
				byte[] rgbData = frameQueue.Dequeue();

				if (surf == null) {
					surf = GuiUtil.CreateSurface (rgbData, (ushort)file.Header.Width, (ushort)file.Header.Height,
								      32, (int)file.Header.Width * 4,
								      (int)0x00ff0000,
								      (int)0x0000ff00,
								      (int)0x000000ff,
								      unchecked ((int)0xff000000));
				}
				else {
					surf.Lock();
					Marshal.Copy(rgbData, 0, surf.Pixels, rgbData.Length);
					surf.Unlock();
					surf.Update();
				}

				EmitFrameReady ();

				if (frameQueue.Count < (buffered_frames / 2) + 1)
					waitEvent.Set ();
			}
		}
 void Events_Tick(object sender, TickEventArgs e)
 {
     s.Z = rand.Next(100);
     s2.Z = rand.Next(100);
     screen.Fill(Color.Black);
     screen.Update(screen.Blit(manager));
 }
示例#4
0
        // This procedure is called (invoked) for each window refresh
        static void onTick(object sender, TickEventArgs args) {


            if (ship.forward) {
                ship.moveForward();
            }
            // STEP
            // Update the automagic elements and enforce the rules of the game here.

            if (ship.rotation!= 0) { 
                ship.direction +=  ship.rotation % 360;
            }

            // DRAW
            // Draw the new view of the game based on the state of the elements here.

            drawBackground();

            drawSprite(ship.sprite,ship.x,ship.y,ship.direction);

            // ANIMATE 
            // Step the animation frames ready for the next tick
            // ...

            // REFRESH
            // Tranfer the new view to the screen for the user to see.
            video.Update();

        }
示例#5
0
        private void Events_Tick(object sender, TickEventArgs e)
        {
            // Update location of the ball
            ball.X += ballSpeedX;
            ball.Y += ballSpeedY;

            // Bounce the ball
            if (ball.Right > Video.Screen.Width)
            {
                ballSpeedX *= -1;
            }
            if (ball.Left < 0)
            {
                ballSpeedX *= -1;
            }
            if (ball.Top < 0)
            {
                ballSpeedY *= -1;
            }
            if (ball.Bottom > Video.Screen.Height)
            {
                ballSpeedY *= -1;
            }

            // Clear the screen
            Video.Screen.Fill(Color.Black);

            // Draw the ball
            Video.Screen.Blit(ball);
            
            // Update the screen
            Video.Screen.Update();
        }
示例#6
0
 private static void EventsOnTick(object sender, TickEventArgs tickEventArgs)
 {
     for (int i = 0; i < 1; i++)
     {
         p.Render(buff[i]);
         screen.Blit(buff[i]);
         screen.Update();
     }
 }
示例#7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            float change = delta * speed;

            this.Y += (int)change;
            this.X += (int)Math.Ceiling(change * wind);

            if (this.Y > 480)
            {
                Reset();
            }
        }
示例#8
0
		void LoadingFlasher (object sender, TickEventArgs e)
		{
			totalElapsed += e.TicksElapsed;

			if ((Elements[LOADING_ELEMENT_INDEX].Visible && (totalElapsed < FLASH_ON_DURATION)) ||
			    (!Elements[LOADING_ELEMENT_INDEX].Visible && (totalElapsed < FLASH_OFF_DURATION)) )
				return;

			Console.WriteLine ("Flashing");

			Elements[LOADING_ELEMENT_INDEX].Visible = !Elements[LOADING_ELEMENT_INDEX].Visible;

			totalElapsed = 0;
		}
示例#9
0
        private void Events_Tick(object sender, TickEventArgs e)
        {
            // Clear Screen, Draw, Output
            Video.Screen.Fill(Color.Black);
            Player.Draw(Video.Screen, Color.Wheat, false, true);
            Video.Screen.Update();

            // Handle Movement
            KeyboardState KeyState = new KeyboardState(true);
            if (KeyState.IsKeyPressed(Key.A)) { Player.XPosition1 -= 2; Player.XPosition2 -= 2; }
            else if (KeyState.IsKeyPressed(Key.D)) { Player.XPosition1 += 2; Player.XPosition2 += 2; }
            if (KeyState.IsKeyPressed(Key.W)) { Player.YPosition1 -= 2; Player.YPosition2 -= 2; }
            else if (KeyState.IsKeyPressed(Key.S)) { Player.YPosition1 += 2; Player.YPosition2 += 2; }
        }
示例#10
0
        /// <summary>
        /// If the bullet goes off the screen, 
        /// it is removed from the collection.
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            this.X -= (int)(args.SecondsElapsed * this.speedX);
            this.Y -= (int)(args.SecondsElapsed * this.speedY);

            if (this.X + this.Surface.Size.Width < 0 ||
                this.X > Video.Screen.Width ||
                this.Y + this.Surface.Size.Height < 0 ||
                this.Y > Video.Screen.Height)
            {
                this.Dispose();
            }
        }
示例#11
0
 public override void Update(TickEventArgs args)
 {
     if (Tick % 2 == 0)
     {
         if (SurfaceIndex == Surfaces.Count)
         {
             Visible = false;
             Kill();
         }
         else
         {
             Surface = Surfaces[SurfaceIndex];
             SurfaceIndex++;
         }
     }
     Tick++;
 }
        public override void Update(TickEventArgs args)
        {
            //base.Update(args);
            if (right)
            {
                xCoord+=4;

                if (xShow >= 192)
                    xShow = 0;
                xShow += 64;
            }

            if (left)
                xCoord-=4;

               // p.UpdateEnemy(xCoord);

            Draw();
        }
示例#13
0
        /// <summary>
        /// Every tick will update the animation frame
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            //Call the base method
            base.Update(args);

            //Change the sprite coordinates if the sprite is not being dragged
            if (!this.BeingDragged)
            {
                this.X += dx;
                this.Y += dy;

                // Bounce off the left
                if (this.X < bounds.Left)
                {
                    dx = (Math.Abs(this.dx));
                    this.X = bounds.Left;
                }

                // Bounce off the top
                if (this.Y < bounds.Top)
                {
                    dy = (Math.Abs(this.dy));
                    this.Y = bounds.Top;
                }

                // Bounce off the bottom
                if ((this.Y + this.Height) > bounds.Bottom)
                {
                    dy = -1 * (Math.Abs(this.dy));
                    this.Y = bounds.Bottom - this.Height;
                }
                // Bounce off the right
                if (this.X + this.Width > bounds.Right)
                {
                    dx = -1 * (Math.Abs(this.dx));
                    this.X = bounds.Right - this.Width;
                }
            }
        }
示例#14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            this.Y += (int)(args.SecondsElapsed * speed);
            //Console.WriteLine(args.SecondsElapsed);

            if (this.Y > Video.Screen.Height)
            {
                Reset();
            }

            if (BombRun.BombSpeed > maxspeed)
            {
                BombRun.BombSpeed = maxspeed / 2;
                maxspeed = maxspeed * 2;
            }
        }
示例#15
0
        private void Events_Tick(object sender, TickEventArgs e)
        {
            //Clear
            mVideo.Fill(Color.Cyan);
            //Update
            hero.Update();
            hero2.Update();
            vijand.Update();

            if (vijand.colRectangle.IntersectsWith(hero.colRectangle)) {
                Console.WriteLine("RAAK!!!");
            }

             //Draw
            hero.Draw();
            hero2.Draw();
            vijand.Draw();

            activeLevel.DrawWorld();

            mVideo.Update();
        }
示例#16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            this.X += (int)(args.SecondsElapsed * 10 * dx);
            this.Y += (int)(args.SecondsElapsed * 10 * dy);

            // Adjust our entropy
            dx += SpriteRandomizer.Next(-5, 6);
            dy += SpriteRandomizer.Next(-5, 6);

            // Call the base which also normalizes the bounds
            base.Update(args);

            // Normalize the directions
            if (this.X == SpriteBounds.Left)
            {
                dx = SpriteRandomizer.Next(1, 11);
            }

            if (this.X == SpriteBounds.Right)
            {
                dx = ((-1) * SpriteRandomizer.Next(1, 11));
            }

            if (this.Y == SpriteBounds.Top)
            {
                dy = SpriteRandomizer.Next(1, 11);
            }

            if (this.Y == SpriteBounds.Bottom)
            {
                dy = ((-1) * SpriteRandomizer.Next(1, 11));
            }
        }
示例#17
0
        void Events_Tick(object sender, TickEventArgs e)
        {
            // randomly start "animations"
            if (--next < 0)
            {
                var flash = new Flash { Surface = next_surface(), Point = next_point(), Tick = random.Next(100, 1000) };
                flash.Surface.Alpha = (byte)random.Next(100, 255);
                flash.Surface.AlphaBlending = true;
                flash.Surface.Fill(next_color());

                flashes.Add(flash);
                next = next_gen();
            }

            screen.Blit(background);

            var keep = new List<Flash>();
            foreach (var flash in flashes)
            {
                if (--flash.Tick > 0)
                {
                    keep.Add(flash);
                }
                else
                {
                    var snd = new Sound("resources/cow4.wav");
                    snd.Volume = 40;
                    snd.Play();
                }
                screen.Blit(flash.Surface, flash.Point);
                flash.Tick--;
            }
            flashes = keep;

            screen.Update();
            tick++;
        }
示例#18
0
        /// <summary>
        /// An update tick
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tick(object sender, TickEventArgs e)
        {
            // Update all particles
            particles.Update();
            //emit.Target.Update();

            // Draw scene
            Video.Screen.Fill(Color.Black);
            particles.Render(Video.Screen);
            //emit.Target.Render(Video.Screen);    

            Video.Screen.Update();
            Video.WindowCaption = "SDL.NET - ParticlesExample - Particles: " + particles.Particles.Count;
        }
示例#19
0
 private void Tick(object sender, TickEventArgs e)
 {
     screen.Fill(Color.Black);
     screen.Blit(cursor, new Rectangle(position, screen.Size));
     screen.Update();
 }
示例#20
0
        public override void Tick(object sender, TickEventArgs args)
        {
            CleanGarbage();

            foreach (GuiItem item in Container)
            {
                Surface Buff = RenderItem(item);

                Screen.Blit(Buff, item.GetRect());
            }

            Screen.Blit(TitleLabelLine1, pLine1);
            Screen.Blit(TitleLabelLine2, pLine2);

            Screen.Update();
        }
示例#21
0
		static void Events_Tick(object sender, TickEventArgs e) {
			Rectangle enemy_rect, item_rect;
			
			
			
			if (GameStarted) {				
				if (LastFishCreation + 1000 < Timer.TicksElapsed && !isTimeStopped) {
					CreateFish();
					CreatePowerUp();
				}
			
				
				if (Keyboard.IsKeyPressed(Key.UpArrow)) {
					playerFish.Pos.Y -= 10;
				} else if (Keyboard.IsKeyPressed(Key.DownArrow)) {
					playerFish.Pos.Y += 10;
				}

				if (Keyboard.IsKeyPressed(Key.LeftArrow)) {
					playerFish.Pos.X -= 10;
					playerFish.RightFaced = false;
				} else if (Keyboard.IsKeyPressed(Key.RightArrow)) {
					playerFish.Pos.X += 10;
					playerFish.RightFaced = true;
				}
			
				sfcMain.Blit(sfcBackground);
				sfcMain.Blit(sfcScoreHeader, new Point(0,708));
				DoScore();												// calculates score
				DoHeaderBar();											// show power ups on top.
				
				// check if player's fish is alive?
				if (playerFish.IsAlive) {
					if (playerFish.RightFaced) {		// draw based if player is right 
														// or left faced
						if (playerFish.GrowthSize > 1) sfcMain.Blit(sfcFishR[4], playerFish.Pos);
						else sfcMain.Blit(sfcFishR[playerFish.Type], playerFish.Pos);
					} else {
						if (playerFish.GrowthSize > 1) sfcMain.Blit(sfcFishL[5], playerFish.Pos);
						else sfcMain.Blit(sfcFishL[playerFish.Type], playerFish.Pos);
					}
				}
				else 
				{
					sfcMain.Blit(sfcFishL[4], DeathFloat(playerFish.Pos));	
				}
				
				
				
				Rectangle player_rect = new Rectangle(playerFish.Pos.X, playerFish.Pos.Y, 
				                                      sfcFishR[playerFish.Type].Width, 
				                                      sfcFishR[playerFish.Type].Height);
				
				// add power ups to main surface.
				for(int i = 0; i < PowerUps.Count; i++) {
					sfcMain.Blit(sfcPowerUps[(int)PowerUps[i].Type], PowerUps[i].Pos);
					item_rect = new Rectangle(PowerUps[i].Pos.X, PowerUps[i].Pos.Y, 
						                           sfcPowerUps[(int)PowerUps[i].Type].Width, 
						                           sfcPowerUps[(int)PowerUps[i].Type].Height);
					if (item_rect.IntersectsWith(player_rect)) {
						
						// add power up to player
						Console.WriteLine(PowerUps[i].Type + " : power up added!");
						playerFish.powerUps[PowerUps[i].Type] += 1;
						PowerUps.RemoveAt(i);
					} else {
						if (!isTimeStopped) {
							PowerUps[i].Pos.Y += 2;
							if (PowerUps[i].Pos.Y > 800) {
								PowerUps.RemoveAt(i);
							}
						}
					}
				}
				
				
				for (int i = AIFish.Count - 1; i >= 0; --i) {
					Fish computerfish = AIFish[i];
					
					if (computerfish.RightFaced == true) 
					{
						if (!isTimeStopped) computerfish.Pos.X += computerfish.Speed;
						enemy_rect = new Rectangle(computerfish.Pos.X, computerfish.Pos.Y, 
						                           sfcFishR[computerfish.Type].Width, 
						                           sfcFishR[computerfish.Type].Height);
					} else
					{
						if (!isTimeStopped) computerfish.Pos.X -= computerfish.Speed;
						enemy_rect = new Rectangle(computerfish.Pos.X, computerfish.Pos.Y, 
						                           sfcFishL[computerfish.Type].Width, 
						                           sfcFishL[computerfish.Type].Height);
					}
					if (enemy_rect.IntersectsWith(player_rect)) {
						if (computerfish.Size < (int)playerFish.GrowthSize) {
							AIFish.RemoveAt(i);
							playerFish.addScore((int)computerfish.Size + 1);
						} else if (computerfish.Size > (int)playerFish.GrowthSize) {
							playerFish.IsAlive = false;
							
						}
					}
					if (computerfish.RightFaced == true) sfcMain.Blit(sfcFishR[computerfish.Type], 
					                                                  computerfish.Pos);
					else sfcMain.Blit(sfcFishL[computerfish.Type], computerfish.Pos);
				}

				if (timeStopCounter + 4500 < Timer.TicksElapsed) {
					isTimeStopped = false;
				}
				
				if (powerUpTimer + 4500 < Timer.TicksElapsed) {
					playerFish.GrowthSize = 1;
					
				}
				
				if (!playerFish.IsAlive) {
					sfcMain.Blit(sfcOpps, new Point(280, 200));
					sfcMain.Blit(sfcInfo, new Point(254, 400));
				}
				
			} else {
				sfcMain.Blit(sfcBackground);
				sfcMain.Blit(sfcLogo, new Point(254, 236));
				sfcMain.Blit(sfcInfo, new Point(254, 400));
			}
			
			sfcMain.Update();
		}
示例#22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            float change = 5f;
            float jumpspeed = 10f;

            if (jump || falling)
            {
                change = change / 2;
            }

            if (left)
            {
                this.X -= (int)change;
            }
            if (right)
            {
                this.X += (int)change;
            }

            if (jump)
            {
                if (this.Y < jumpstart - Video.Screen.Height / 3)
                {
                    jump = false;
                    falling = true;
                }
                else
                {
                    this.Y -= (int)(jumpspeed * 1.5f);
                }
            }
            else if (falling)
            {
                this.Y += (int)jumpspeed;

                if (this.Y > jumpstart)
                {
                    this.Y = jumpstart;
                    falling = false;
                }
            }

            if (this.X < 0)
            {
                this.X = 0;
            }

            if (this.X + this.Surface.Size.Width > Video.Screen.Width)
            {
                this.X = Video.Screen.Width - this.Surface.Width;
            }

            // fire if needed. the 250 stands for the delay between two shots
            if (fire && lastfire + 250 < Timer.TicksElapsed)
            {
                if (WeaponFired != null)
                {
                    WeaponFired(this, new FireEventArgs(this.Position));
                }

                // dont forget this
                lastfire = Timer.TicksElapsed;
            }
        }
示例#23
0
        // Tick !
        private void OnTick(object sender, SdlDotNet.Core.TickEventArgs e)
        {
            if (!canRender)
            {
                return;
            }
            if (!initialized)
            {
                return;
            }
            if (isRendering)
            {
                return;
            }

            if (!NesEmu.EmulationON)
            {
                isRendering = true;

                // Make a snow buffer !!

                for (int i = 0; i < screenBufferSize; i++)
                {
                    c = (byte)r.Next(0, 255);
                    screen_pointer[i] = c | (c << 8) | (c << 16) | (255 << 24);
                }

                screen.Lock();
                screen.Fill(Color.Black);
                screen.Blit(screen_back.CreateStretchedSurface(destinationRect.Size), destinationRect.Location);
                screen.Unlock();

                // Draw texts ...

                fpsTextSprite.Color = Color.Lime;
                fpsTextSprite.Text  = "NO SIGNAL";
                screen.Blit(fpsTextSprite);

                if (showNotifications)
                {
                    if (textAppearanceFrames > 0)
                    {
                        textAppearanceFrames--;
                        screen.Blit(notTextSprite);
                    }
                }
                // Menu page !
                if (Program.PausedShowMenu)
                {
                    Program.Rooms[Program.RoomIndex].Draw(screen);
                }
                //screen.Update();
                Video.Update();

                isRendering = false;
            }
            else if (NesEmu.EmulationPaused)
            {
                isRendering = true;
                screen.Lock();
                screen.Fill(Color.Black);
                screen.Blit(screen_back.CreateStretchedSurface(destinationRect.Size), destinationRect.Location);
                screen.Unlock();
                //fpsTextSprite.Text = "PAUSED";
                //
                switch (NesEmu.EmuStatus)
                {
                case NesEmu.EmulationStatus.HARDRESET:
                {
                    fpsTextSprite.Text = "HARD RESETING ...";
                    break;
                }

                case NesEmu.EmulationStatus.LOADINGSTATE:
                {
                    fpsTextSprite.Text = "LOADING STATE ...";
                    break;
                }

                case NesEmu.EmulationStatus.PAUSED:
                {
                    fpsTextSprite.Text = "PAUSED";
                    break;
                }

                case NesEmu.EmulationStatus.SAVINGSNAP:
                {
                    fpsTextSprite.Text = "SAVING SNAPSHOT ...";
                    break;
                }

                case NesEmu.EmulationStatus.SAVINGSRAM:
                {
                    fpsTextSprite.Text = "SAVING SRAM ...";
                    break;
                }

                case NesEmu.EmulationStatus.SAVINGSTATE:
                {
                    fpsTextSprite.Text = "SAVING STATE ...";
                    break;
                }

                case NesEmu.EmulationStatus.SOFTRESET:
                {
                    fpsTextSprite.Text = "SOFT RESETTING ...";
                    break;
                }
                }
                screen.Blit(fpsTextSprite);

                if (showNotifications)
                {
                    if (textAppearanceFrames > 0)
                    {
                        textAppearanceFrames--;
                        screen.Blit(notTextSprite);
                    }
                }
                // Menu page !
                if (Program.PausedShowMenu)
                {
                    Program.Rooms[Program.RoomIndex].Draw(screen);
                }
                //screen.Update();
                Video.Update();

                isRendering = false;
            }
        }
示例#24
0
 /// <summary>
 /// Renders the OpenGL context to the screen
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Tick(object sender, TickEventArgs e)
 {
     DrawGLScene();
     Video.GLSwapBuffers();
 }
示例#25
0
 private void Tick(object sender, TickEventArgs e)
 {
     if (screen.Width != width || screen.Height != height)
     {
         Init();
         OnReshape();
     }
     OnDraw();
 }
示例#26
0
 /// <summary>
 /// Main Engine Loop
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTick(object sender, TickEventArgs e)
 {
     ((CGameState)states.Peek()).Update(this);
     ((CGameState)states.Peek()).Draw(this);
     Video.WindowCaption = Events.Fps.ToString() + " fps";
     Video.Screen.Update();
 }
示例#27
0
        /// <summary>
        /// Every tick will update the animation frame
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            //Call the base method
            base.Update(args);

            //Change the sprite coordinates if the sprite is not being dragged
            if (!this.BeingDragged)
            {
                this.X += dx;
                this.Y += dy;
                
                //this.Z += dz;

                // Bounce off the left
                if (this.X < bounds.Left)
                {
                    this.X = bounds.Left;
                    this.Z = rand.Next(0, 41);
                }

                // Bounce off the top
                if (this.Y < bounds.Top)
                {
                    this.Y = bounds.Top;
                    this.Z = rand.Next(0, 41);
                }

                // Bounce off the bottom
                if (this.Y > bounds.Bottom)
                {
                    this.Y = bounds.Bottom;
                    this.Z = rand.Next(0, 41);
                }
                // Bounce off the right
                if (this.X > bounds.Right)
                {
                    this.X = bounds.Right;
                    this.Z = rand.Next(0, 41);
                }
                // Bounce off the left
                if (this.Z < 0)
                {
                    this.Z = 0;
                }
                // Bounce off the bottom
                if (this.Z > 40)
                {
                    this.Z = 40;
                }
                if (this.Z == 0)
                {
                    dz = (Math.Abs(this.dz));
                }

                if (this.Z == 40)
                {
                    dz = -1 * (Math.Abs(this.dz));
                }

                // Reverse the directions when the sprite hits an edge
                if (this.X == bounds.Left)
                {
                    dx = (Math.Abs(this.dx));
                }

                if (this.X == bounds.Right)
                {
                    dx = -1 * (Math.Abs(this.dx));
                }

                if (this.Y == bounds.Top)
                {
                    dy = (Math.Abs(this.dy));
                }

                if (this.Y == bounds.Bottom)
                {
                    dy = -1 * (Math.Abs(this.dy));
                }
                //Console.WriteLine("Z: " + this.Z);
            }
        }
示例#28
0
        private void Events_Tick(object sender, TickEventArgs e)
        {
            //Indien de held niet dood, er op s geduwt is en de held de finish niet bereikt heeft zal het spel gestart worden.
            if (_level.Held.IamDead == false)
            {
                _pressedR = false;
                if (_pressedS)
                {
                    if (_level.Held.Finish)
                    {
                        //Indien de held de finish bereikt heeft, wordt de eindafbeelding en de score op het scherm geblit + nog wat extra informatie.
                        _endscore = _font.Render("Je totale score is : " + (_level1Score + _level.Held.Score), Color.Red);
                        _endfont = _font.Render("Press r to restart. Press q to become invincible. Press esc to close.",Color.Red);
                        _mVideo.Blit(_endscreen);
                        _mVideo.Blit(_endscore, new Point(500, 10));
                        _mVideo.Blit(_endfont, new Point(20, 540));
                    }
                    else
                    {
                        //Indien dit niet het geval is wordt het spel gestart.
                        //Er worden verschillende functie aangeroepen :
                        /*   - CheckCollisionsWithEnemy : om te checken of de held niet geraakt wort door de vijand
                             - Die : om te checken of de held niet dood is.
                             - MoveLevel : om het level indien nodig te bewegen
                             - CheckCollisionsHeldWithBackground : om te checken of er zich geen "botsingen" voor doen tussen held en achtergrond
                             - UpdateBackGroundTiles : om de collision rechthoeken van de verschillende figuren te updaten
                             - TimeCheck : om te checken of de _tijd variabele niet op 0 staat*/

                        CheckCollisionsWithEnemy();

                        _level.Held.Die(_level.GameObjects);
                        _level.MoveLevel(_level.Held);
                        _level.CheckCollisionsHeldWithBackground();
                        UpdateBackGroundTiles();
                        TimeCheck();

                        if (_level.Held.Level2 == false)
                        {
                            //Verder wordt de juiste achtergrond getekend en wordt de variabele _level1Score gebruikt om de score van level1 in te bewaren
                            _mVideo.Blit(_achtergrond);
                            _level1Score = _level.Held.Score;
                        }
                        else if (_level.Held.Level2)
                        {
                            //Alle lijsten die uit level 1 komen worden gecleard
                            _level.Vijanden.Clear();
                            _level.LifeObjects.Clear();
                            _level.NextLevelObjects.Clear();
                            _level.MetalObjects.Clear();
                            _level.EmptyBlocks.Clear();
                            _mVideo.Blit(_achtergrond2); //achtergrond van level 2
                            //De tijd wordt terug naar 60 gezet
                            _tijd = 60;
                            //Optimalisatie van de code. Anders zou er elke tick een nieuw level gecreeërd worden.
                            if (_teller == 1)
                            {
                                //Hier wordt weer polymorfisme toe gepast. Hierdoor krijgt het _level object nu alle specifities van de level2 klasse.
                                //Hierdoor kunnen we veel dubbele code vermijden.
                                _level = new Level2();
                                _teller++;
                            }
                        }
                        //Het level, aantal levens, score en de nog resterende tijd worden op het scherm geblit
                        _level.Draw(_mVideo);
                        _aantalLevens.Draw(_mVideo, _level.Held);
                        _fontScore = _font.Render("Score : " + _level.Held.Score, Color.Red);
                        _fonttimer = _font.Render("Time left :" + _tijd, Color.Red);
                        _mVideo.Blit(_fonttimer, new Point(600, 0));
                        _mVideo.Blit(_scoreimage, new Point(1050, 0));
                        _mVideo.Blit(_fontScore, new Point(1100, 0));
                    }
                }
                else
                {
                    //Indien er niet op s geduwt is, wordt het startscherm getoon.
                    _mVideo.Blit(_start);
                    _mVideo.Blit(_fontStart, new Point(900, 0));
                }
            }
            else if (_level.Held.IamDead)
            {
                //Als de held dood is, wordt het gameover scherm getoond.
                _mVideo.Blit(_gameOver);
                _mVideo.Blit(_fontGameOver, new Point(500, 500));

                if (_pressedR)
                {
                    //Indien er op r geduwt is, wordt de functie ReInitialize aan geroepen.
                    ReInitialize();
                }
            }
            //De hele sdl app wordt ge-updatet. Indien dit niet gebruikt wordt, zal de applicatie niet werken.
            _mVideo.Update();
        }
示例#29
0
		private void Tick(object sender, TickEventArgs e)
		{
			Display();
			Video.GLSwapBuffers();
		}
示例#30
0
        private void Events_Tick(object sender, TickEventArgs e)
        {
            algorithm.Epoch();
            this.worldObjects.RemoveRange(1, this.worldObjects.Count - 1);
            var ground = (Box)this.worldObjects[0];
            var decode = this.algorithm.Best.Decode();
            for (int i = 0; i < this.algorithm.Cargo.Count; i++)
            {
                var pos = decode[i];
                var box = this.algorithm.Cargo[i];
                var newBox = new Box(box.Width, box.Height);

                newBox.X = pos.X - (ground.Width / 2) + (newBox.Width / 2);
                newBox.Y = -1 * pos.Y + (ground.Height / 2) - (newBox.Height / 2);
                newBox.Color = box.Color;
                this.worldObjects.Add(newBox);
            }

            this.DrawScene();
            Video.GLSwapBuffers();
        }
示例#31
0
文件: Sprite.cs 项目: Blizz9/FanCut
 /// <summary>
 /// All sprites are tickable, regardless if they actual do
 /// anything. This ensures that the functionality is there, to be
 /// overridden as needed.
 /// </summary>
 /// <param name="args">Event args</param>
 public virtual void Update(TickEventArgs args)
 {
 }
示例#32
0
        void Events_Tick(object sender, TickEventArgs e)
        {
            muziek = new Music("Commander Keen 4.mp3");

            mVideo.Blit(achtergrond); //achtergrond

            //CheckCollisionsWithBackground();
            //CheckCollisionsWithEnemy();
            //EnemyMovement();
            //MoveLevel();
            CheckCollisions();
            //AantalLevens.Draw(mVideo, held);

            foreach (GameObject g in Gameobjecten)
            {
                g.Update();
                g.Draw(mVideo);
            }
            level1.Draw(mVideo);

            mVideo.Update();
        }