Example #1
0
        public void Draw(SdlDotNet.Graphics.Surface video)
        {
            foreach (Hero h in GameObjects)
            {
                h.Draw(video);
            }

            foreach (Enemy v in Vijanden)
            {
                v.Draw(video);
            }
            foreach (Grass g in GrassObjects)
            {
                g.Draw(video);
            }
            foreach (LifeItem l in LifeObjects)
            {
                l.Draw(video);
            }
            foreach (MetalBlock m in MetalObjects)
            {
                m.Draw(video);
            }
            foreach (NextLevelDoor n in NextLevelObjects)
            {
                n.Draw(video);
            }
        }
Example #2
0
 /// <summary>
 /// Creates a new TextSprite given the text, font, color and anti-aliasing flag.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="color">Color of Text</param>
 /// <param name="antiAlias">A flag determining if it's to 
 /// use anti-aliasing when rendering. Defaults to true.</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color color, bool antiAlias)
     : this(textItem, font, color, antiAlias, new Point(0, 0))
 {
 }
Example #3
0
 /// <summary>
 /// Creates a new TextSprite given the text, font and color.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="color">color of Text</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color color)
     : this(textItem, font, color, true)
 {
 }
Example #4
0
 /// <summary>
 /// Combines two surfaces together.
 /// </summary>
 /// <param name="bottomImage">The surface that will be used as the background.</param>
 /// <param name="topImage">The surface that will be used as the foreground.</param>
 /// <returns>The combined surface.</returns>
 public static SdlDotNet.Graphics.Surface CombineImage(SdlDotNet.Graphics.Surface bottomImage, SdlDotNet.Graphics.Surface topImage)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(new System.Drawing.Size(System.Math.Max(bottomImage.Width, topImage.Width), System.Math.Max(bottomImage.Height, topImage.Height)));
     returnSurf.Blit(bottomImage, new System.Drawing.Point(0, 0));
     returnSurf.Blit(topImage, new System.Drawing.Point(0, 0));
     return returnSurf;
 }
Example #5
0
        // this procedure is called when a key is pressed or released
        static void onKeyboard(object sender, SdlDotNet.Input.KeyboardEventArgs args) {

            if (args.Down) { 

                switch (args.Key) {
                    case SdlDotNet.Input.Key.W:
                        ship.forward = !ship.forward;
                        break;
                    case SdlDotNet.Input.Key.D :
                        ship.rotation-= ship.TURNING_SPEED;
                        break;
                    case SdlDotNet.Input.Key.A :
                        ship.rotation+= ship.TURNING_SPEED;
                        break;
                    case SdlDotNet.Input.Key.Escape :
                        Events.QuitApplication();
                        break;
                }

            } else {

                switch (args.Key) {
                    case SdlDotNet.Input.Key.W:
                        ship.forward = !ship.forward;
                        break;
                    case SdlDotNet.Input.Key.D:
                    case SdlDotNet.Input.Key.A:
                        ship.rotation = 0;
                        break;
                }

            }

        }
Example #6
0
 private void Events_KeyboardDown(object sender, SdlDotNet.Input.KeyboardEventArgs e)
 {
     if (e.Key == links)
         left = true;
     if (e.Key == rechts)
         right = true;
 }
Example #7
0
        public static void SdlDotNet_Core_Events_Tick(object sender, SdlDotNet.Core.TickEventArgs e)
        {
            // Only redraw the window if it isn't minimized
            //if (SdlDotNet.Graphics.Video.IsActive) {
            try {
                if (Skins.SkinManager.ScreenBackground != null && Globals.InGame == false) {
                    SdlDotNet.Graphics.Video.Screen.Blit(Skins.SkinManager.ScreenBackground, new Point(0, 0));
                } else {
                    if (Skins.SkinManager.ActiveSkin.IngameBackground != null) {
                        SdlDotNet.Graphics.Video.Screen.Blit(Skins.SkinManager.ActiveSkin.IngameBackground, new Point(0, 0));
                    } else {
                        SdlDotNet.Graphics.Video.Screen.Fill(Color.SteelBlue);
                    }
                }
            } catch {
                SdlDotNet.Graphics.Video.Screen.Fill(Color.SteelBlue);
            }

            //try {
            // Check if the FPS isn't something absurd
            //if (!(SdlDotNet.Core.Events.Fps < 10 || SdlDotNet.Core.Events.Fps > Constants.FRAME_RATE + 10)) {
            SdlDotNet.Widgets.WindowManager.DrawWindows(e);
            //} catch { }
            //}

            //if (Graphics.FontManager.GameFont != null) {
            //    SdlDotNet.Graphics.Video.Screen.Blit(Graphics.FontManager.GameFont.Render("FPS: " + SdlDotNet.Core.Events.Fps.ToString(), Color.Black), new Point(0, 0));
            //}

            SdlDotNet.Graphics.Video.Update();
            //} else {
            //    // Game window isn't active
            //}
        }
Example #8
0
 void Events_KeyboardDown(object sender, SdlDotNet.Input.KeyboardEventArgs e)
 {
     if (e.Key == Key.Escape || e.Key == Key.Q)
     {
         Events.QuitApplication();
     }
 }
Example #9
0
 public TextboxLine(int maxWidth, SdlDotNet.Graphics.Font font, Color defaultForeColor)
 {
     mMaxWidth = maxWidth;
     mChars = new List<TextBoxChar>();
     mFont = font;
     mDefaultForeColor = defaultForeColor;
 }
Example #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="font"></param>
 /// <param name="positionY"></param>
 /// <param name="phrase"></param>
 /// <param name="startTime"></param>
 public TextItem(string phrase, SdlDotNet.Graphics.Font font, int positionY, float startTime)
     : base(phrase, font, false, new Point(25, positionY))
 {
     base.Surface.Alpha = 0;
     base.Surface.AlphaBlending = true;
     this.startTime = startTime;
 }
Example #11
0
        private string View; // View = XY, ZY or ZX (Front,Left or Top)

        #endregion Fields

        #region Constructors

        public View2D(SdlDotNet.Windows.SurfaceControl Control, string View, object _blocks, object _items, int _gridsize, object _layers)
        {
            this.View = View;
            this.Control = Control;
            this.layerStatus = (bool[])_layers;

            this.Surf = new Surface(this.Control.Width, this.Control.Height);

            this.GridSurf = new Surface(this.Control.Width, this.Control.Height);
            this.BlockSurf = new Surface(this.Control.Width, this.Control.Height);
            this.TempSurf = new Surface(this.Control.Width, this.Control.Height);

            this.GridSize = _gridsize;

            this.blocks = _blocks;
            this.items = _items;

            SdlDotNet.Core.Events.Tick +=  new EventHandler<TickEventArgs>(OnTick);

            this.levelSize = 256;

            this.scrollLocalX = this.levelSize*this.GridSize/2;
            this.scrollLocalY = this.levelSize*this.GridSize/ 2;

            this.UpdateGrid();
            this.UpdateBlocks();
            this.UpdateTemp();
        }
        public override void power(SdlDotNet.Input.KeyboardEventArgs args)
        {
            if (args.Key == SdlDotNet.Input.Key.Space)
                Console.WriteLine("Pang, pang ...");

            theHero.power(args);
        }
Example #13
0
 void Events_MouseButtonDown(object sender, SdlDotNet.Input.MouseButtonEventArgs e)
 {
     if (e.ButtonPressed)
     {                
         shoot = true;             
     }
 }
Example #14
0
        public override void Draw(SdlDotNet.Graphics.Surface screen)
        {
            // Draw the title
            titleTextSprite.X = 20;
            titleTextSprite.Y = _BaseY;
            titleTextSprite.Color = Color.Yellow;
            titleTextSprite.Text = this.Name;
            screen.Blit(titleTextSprite);

            int item_y = _BaseY + _SpaceBetweenItems + 20;
            // Draw the lines
            for (int i = 0; i < Lines.Length; i++)
            {
                lineTextSprite.X = 20;
                lineTextSprite.Y = item_y;
                lineTextSprite.Color = Color.White; 
                lineTextSprite.Text = Lines[i];
                screen.Blit(lineTextSprite);

                item_y += 15;
            }

            // Draw the item
            itemTextSprite.X = 20;
            itemTextSprite.Y = screen.Height - 40;
            itemTextSprite.Color = Color.LightYellow;
            itemTextSprite.Text = Items[0].Text;
            screen.Blit(itemTextSprite);
        }
Example #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="textItem"></param>
 /// <param name="font"></param>
 /// <param name="size"></param>
 /// <param name="coordinates"></param>
 public BoundedTextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Point coordinates)
     : base(textItem, font, coordinates)
 {
 }
 void KeyFilterSdlConfigMappings_MouseDown(object sender, SdlDotNet.MouseButtonEventArgs e)
 {
     string mousebuttonname = MouseEventToKeyName(e);
     if (mousebuttonname != "")
     {
         HandleKeyDown(mousebuttonname);
     }
 }
Example #17
0
 protected override int procKeyEvent(SdlDotNet.Input.Key key)
 {
     if (key == SdlDotNet.Input.Key.Return)
     {
         return 0;
     }
     return -1;
 }
Example #18
0
 public override void Update(SdlDotNet.Graphics.Surface dstSrf, SdlDotNet.Core.TickEventArgs e)
 {
     if (e.Tick > lastTick + 35) {
         mGameLoop.DrawScreen(mGameSurface, e);
         lastTick = e.Tick;
     }
     dstSrf.Blit(mGameSurface, this.Location);
 }
 void renderer_KeyUp(object sender, SdlDotNet.KeyboardEventArgs e)
 {
     //Test.WriteOut("KeyFilterFormsKeyCache._KeyUp(" + e.KeyCode.ToString() + ")" );
     Keys[(int)e.Key] = false;
     if( KeyUp != null )
     {
         KeyUp(sender, e);
     }
 }
Example #20
0
 /// <summary>
 /// Crops a surface from the specified surface.
 /// </summary>
 /// <param name="surfaceToCrop">The surface to crop.</param>
 /// <param name="cropRectangle">The rectangle bounds to crop.</param>
 /// <returns>The cropped surface.</returns>
 public static SdlDotNet.Graphics.Surface CropImage(SdlDotNet.Graphics.Surface surfaceToCrop, System.Drawing.Rectangle cropRectangle)
 {
     SdlDotNet.Graphics.Surface returnSurf = new SdlDotNet.Graphics.Surface(cropRectangle.Size);
     returnSurf.Transparent = surfaceToCrop.Transparent;
     //returnSurf.Fill(System.Drawing.Color.Transparent);
     //returnSurf.TransparentColor = surfaceToCrop.TransparentColor;
     returnSurf.Blit(surfaceToCrop, new System.Drawing.Point(0, 0), cropRectangle);
     return returnSurf;
 }
Example #21
0
        /// <summary>
        /// Retrieve a Tile from it's tilemap, given its coordinates and its size
        /// </summary>
        /// <param name="toFill">Surface which will reprensent the tile</param>
        /// <param name="fileName">Filename of the tilemap</param>
        /// <param name="offsetX">Horizontal offset of the tile in the tile map</param>
        /// <param name="offsetY">Vertical offset of the tile in the tile map</param>
        public static void FromTilemap(SdlDotNet.Graphics.Surface toFill, string fileName, int offsetX, int offsetY)
        {
            if (!tilemap.ContainsKey(fileName))
            {
                tilemap.Add(fileName, new Surface(System.IO.Path.Combine(Path, fileName)));
            }

            toFill.Blit(tilemap[fileName], new Point(0, 0), new Rectangle(offsetX, offsetY, toFill.Width, toFill.Height));
        }
 void renderer_KeyDown(object sender, SdlDotNet.KeyboardEventArgs e)
 {
     Keys[ (int)e.Key ] = true;
     //Test.WriteOut("KeyFilterFormsKeyCache._KeyDown(" + e.KeyCode.ToString() + ")" );
     if( KeyDown != null )
     {
         //Test.WriteOut("KeyFilterFormsKeyCache Sending keydown(" + e.KeyCode.ToString() + ")" );
         KeyDown(sender, e);
     }
 }
Example #23
0
        void Events_KeyboardDown(object sender, SdlDotNet.Input.KeyboardEventArgs e)
        {
            if (e.Key == SdlDotNet.Input.Key.Q || e.Key == SdlDotNet.Input.Key.Escape)
            {
                Events.QuitApplication();
                SdlDotNet.Input.Mouse.ShowCursor = true;
            }

            if (e.Key == SdlDotNet.Input.Key.Space)
                NextPreset();
        }
Example #24
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="textItem"></param>
 /// <param name="font"></param>
 /// <param name="size"></param>
 /// <param name="horizontal"></param>
 /// <param name="vertical"></param>
 /// <param name="coordinates"></param>
 public BoundedTextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     double horizontal,
     double vertical,
     Point coordinates)
     : base(textItem, font, coordinates)
 {
     this.horizontal = horizontal;
     this.vertical = vertical;
 }
Example #25
0
 public static void Keyboard_Down(SdlDotNet.Input.KeyboardEventArgs e)
 {
     if (mOpenWindows.Count > 0) {
         for (int i = mOpenWindows.Count - 1; i >= 0; i--) {
             if (mOpenWindows[i].WindowState != WindowState.Minimized) {
                 mOpenWindows[i].Keyboard_Down(e);
                 break;
             }
         }
         //GetTopMostWindow().Mouse_Down(e);
     }
 }
Example #26
0
        public override void DoKeyDown(SdlDotNet.Input.KeyboardEventArgs e)
        {
            base.DoKeyDown(e);
            if (SelectedMenuIndex == 4)
            {
                if (Items[4].Options[Items[4].SelectedOptionIndex] == "N/A")
                    return;
                if (Items[4].SelectedOptionIndex < Items[4].Options.Count)
                    inputString = Items[4].Options[Items[4].SelectedOptionIndex];
                else
                    inputString = "";
                switch (e.Key)
                {
                    case SdlDotNet.Input.Key.A:
                    case SdlDotNet.Input.Key.P:
                    case SdlDotNet.Input.Key.Z:
                    case SdlDotNet.Input.Key.L:
                    case SdlDotNet.Input.Key.G:
                    case SdlDotNet.Input.Key.I:
                    case SdlDotNet.Input.Key.T:
                    case SdlDotNet.Input.Key.Y:
                    case SdlDotNet.Input.Key.E:
                    case SdlDotNet.Input.Key.O:
                    case SdlDotNet.Input.Key.X:
                    case SdlDotNet.Input.Key.U:
                    case SdlDotNet.Input.Key.K:
                    case SdlDotNet.Input.Key.S:
                    case SdlDotNet.Input.Key.V:
                    case SdlDotNet.Input.Key.N:
                        {
                            if (inputString.Length < 8)
                            {
                                inputString += e.Key.ToString();

                                Items[4].Options[Items[4].SelectedOptionIndex] = inputString;
                                UpdateValues(inputString);
                            }
                            break;
                        }
                    case Key.Backspace:
                        {
                            if (inputString.Length > 0)
                            {
                                inputString = inputString.Substring(0, inputString.Length - 1);

                                Items[4].Options[Items[4].SelectedOptionIndex] = inputString;
                                UpdateValues(inputString);
                            }
                            break;
                        }
                }
            }
        }
Example #27
0
 public static bool CanUpdate(SdlDotNet.Core.TickEventArgs e)
 {
     float val = 1.0f / 1000 * e.TicksElapsed * Constants.FRAME_RATE;
     val += lastVal;
     if (val > 1) {
         lastVal = 0;
         return true;
     } else {
         lastVal = val;
         return false;
     }
 }
Example #28
0
 public override void Draw(SdlDotNet.Graphics.Surface video)
 {
     base.Draw(video);
     foreach (Stone s in StoneObjects)
     {
         s.Draw(video);
     }
     foreach (FinishDoor f in FinishDoors)
     {
         f.Draw(video);
     }
 }
        void Events_KeyboardDown(object sender, SdlDotNet.Input.KeyboardEventArgs e)
        {
            if (e.Key == SdlDotNet.Input.Key.RightArrow)
                right = true;

            if (e.Key == SdlDotNet.Input.Key.LeftArrow)
                left = true;

            if (e.Key == SdlDotNet.Input.Key.DownArrow)
                down = true;

            if (e.Key == SdlDotNet.Input.Key.UpArrow)
                up = true;
        }
Example #30
0
 private void Events_KeyboardUp(object sender, SdlDotNet.Input.KeyboardEventArgs e)
 {
     if (jump)
     {
         if (e.Key == links)
             left = false;
         if (e.Key == rechts)
             right = false;
     }           
     else
     {
         left = right = false;
     }               
 }