Simple wrapper for Window that allows easy 2D rendering
Inheritance: Window.Window, RenderTarget
Example #1
0
        public void Draw(SFML.Graphics.RenderWindow rw)
        {
            _tileShape.Position = TileSizeInPixels * new Vector2f(_positionInTiles.X, _positionInTiles.Y) - JamUtilities.Camera.CameraPosition;
            if (_tileShape.Position.X >= -10 && _tileShape.Position.X <= 810)
            {
                if (_tileShape.Position.Y >= -10 && _tileShape.Position.Y <= 610)
                {
                    rw.Draw(_tileShape);

                    if (GetTileType() == eTileType.TILETYPE_WATER)
                    {
                        float heightDifference = GetWorldProperties().MountainHeight - GetTileProperties().HeightInMeters;

                        //if (heightDifferenceToMountainHight >= 20)
                        //{
                        //}
                    }

                    if (_world.GetDrawOverlay(cWorld.eWorldDrawOverlay.WORLDDRAWOVERLAY_DAYNIGHT))
                    {
                        _dayNightShape.Position = TileSizeInPixels * new Vector2f(_positionInTiles.X, _positionInTiles.Y) - JamUtilities.Camera.CameraPosition;
                        byte a = (byte)(0.0f + 150.0f * _dayNightTime);

                        _dayNightShape.FillColor = new Color(0, 0, 0, a);

                        rw.Draw(_dayNightShape);
                    }
                }
            }
        }
Example #2
0
 public void Draw(RenderWindow win)
 {
     foreach (Enemy enemy in Enemies)
     {
         enemy.Draw(win);
     }
 }
Example #3
0
 protected override void DoDraw(SFML.Graphics.RenderWindow rw)
 {
     foreach (var s in _darkenShapeList)
     {
         rw.Draw(s);
     }
 }
Example #4
0
 public Context(RenderWindow window, ResourceHolder<Texture, ResourceID> textures, ResourceHolder<Font, FontID> fonts, Player player) 
 {
     this.window = window;
     this.textures = textures;
     this.fonts = fonts;
     this.player = player;
 }
 public ExitGameButton(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #6
0
        public void update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (orientation == orientation.vertical)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.05f + (_fireRate / 10));
            }
            else if (orientation == orientation.horizontal)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.05f + (_fireRate / 10), _sprite.Position.Y);
            }

            for (var x = 0; x < list.Count; x++)
            {
                if (list[x].isEnemy())
                {
                    if ((orientation == orientation.vertical &&
                         (list[x]._sprite.Position.X <= _sprite.Position.X &&
                          _sprite.Position.X <= list[x]._sprite.Position.X + 32) &&
                         list[x]._sprite.Position.Y > _sprite.Position.Y) ||
                        (orientation == orientation.horizontal &&
                         (list[x]._sprite.Position.Y <= _sprite.Position.Y &&
                          _sprite.Position.Y <= list[x]._sprite.Position.Y + 32) &&
                         list[x]._sprite.Position.X < _sprite.Position.X))
                    {
                        list.RemoveAt(x);
                        list.Remove(this);
                    }
                }
            }
        }
 public NewPartyBackButton(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #8
0
 public void Draw(SFML.Graphics.RenderWindow rw)
 {
     foreach (IGameObject a in _animalList)
     {
         a.Draw(rw);
     }
 }
 public PickPartyNewParty(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #10
0
        public static void Main(string[] args)
        {
            var win = new RenderWindow(new VideoMode(800, 600), "Some Crappy Zombie Thing");
            win.Closed += (sender, e) => win.Close ();
            var curtime = DateTime.Now;
            double dt = 0;
            double frametime;
            win.SetVisible (true);
            EntityManager.Add (new RectangleTestEntity(true));
            EntityManager.Add (new DebugInfo());
            EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", 0, 1));
            EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", "45down", new Vector2f(35, 40), 1));
            Entity ent = new Entity();
            ent.OnDraw += (sender, e) => e.Surface.Draw (new Text("Loooooonnnnggg Teeeexxxttt") {Position = new Vector2f(700, 500)});
            EntityManager.Add (ent);
            EntityManager.InitializeWindow (win);

            while(win.IsOpen ())
            {
                win.DispatchEvents();
                EntityManager.Draw (win);
                win.Display ();
                frametime = (DateTime.Now-curtime).TotalMilliseconds;
                dt += frametime;
                while (dt >= EntityManager.TimeStep)
                {
                    //Console.WriteLine (dt.ToString ());
                    EntityManager.Update (dt, frametime);
                    dt -= EntityManager.TimeStep;
                }
                curtime = DateTime.Now;
            }
        }
        public RightClickGUI(RenderWindow rw, int x, int y, int corX, int corY)
        {
            MyButton = new List<GUIButton>();
            _screen = rw;
            ID = -1;
            CurrentButton = 0;
            X = x;
            Y = y;
            Visibility = true;

            MyButton.Add(new RightClickExamineButton(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));

            if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX] > -1)
            {
                int i = Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX];
                if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[i] is SpawnBuildable)
                {
                    if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[i] is SpawnBuildable)
                    {
                        MyButton.Add(new RightClickLitFireButton(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));
                    }
                }
                else if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[i] is SpawnResource)
                {
                    MyButton.Add(new RightClickWalkHarvest(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));
                }
            }
            if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedLivingThing[corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX].Count > 0)
            {
                MyButton.Add(new RightClickWalkAttack(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));
            }

            MyButton.Add(new RightClickWalk(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));
            MyButton.Add(new RightClickPickButton(rw, 37, X, Y + MyButton.Count * 20, corX + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, corY + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY));
        }
Example #12
0
 /// <summary>
 /// Draws all Tiles (it is not a must)
 /// </summary>
 /// <param name="win"></param>
 public void Draw(RenderWindow win)
 {
     foreach(Tile t in tiles)
     {
         t.Draw(win);
     }
 }
Example #13
0
        public Core(string path)
        {
            // Load Game from file path
            this.Game = ShootEmUpMaker.Serialization.ImportGame(path);

            // Inits
            this.Quit = false;
            this.CurrentSection = ShootEmUp.Enumrations.eSection.MAIN_MENU;

            // Window creation
            var ScreenSizes = new List<Tuple<eOrientation, uint, uint>>();
            ScreenSizes.Add(new Tuple<eOrientation, uint, uint>(eOrientation.HORIZONTAL, 1024, 600));
            ScreenSizes.Add(new Tuple<eOrientation, uint, uint>(eOrientation.VERTICAL, 700, 400));

            uint w = ScreenSizes.Find(a => a.Item1 == this.Game._orientation).Item2;
            uint h = ScreenSizes.Find(a => a.Item1 == this.Game._orientation).Item3;

            this.VideoMode = new VideoMode(w, h, 32);
            this.Window = new RenderWindow(this.VideoMode, this.Game._name);

            // Init events
            this.Window.Closed += new EventHandler(OnClose);
            this.Window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            //_lastTouch = new Stopwatch();
            //_lastTouch.Start();

            //_lastShot = new Stopwatch();
            //_lastShot.Start();

            //_timer = new Stopwatch();
            //_timer.Start();
            //_background = new Sprite();
        }
 public CharacterCreationFace(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
 public PickMoreWorldDown(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
 public PickWorldNewWorld(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #17
0
        public Core(string path)
        {
            // Load Game from file path
            this.Game = ShootEmUpMaker.Serialization.ImportGame(path);

            // Inits
            this.Quit           = false;
            this.CurrentSection = ShootEmUp.Enumrations.eSection.MAIN_MENU;

            // Window creation
            var ScreenSizes = new List <Tuple <eOrientation, uint, uint> >();

            ScreenSizes.Add(new Tuple <eOrientation, uint, uint>(eOrientation.HORIZONTAL, 1024, 600));
            ScreenSizes.Add(new Tuple <eOrientation, uint, uint>(eOrientation.VERTICAL, 700, 400));

            uint w = ScreenSizes.Find(a => a.Item1 == this.Game._orientation).Item2;
            uint h = ScreenSizes.Find(a => a.Item1 == this.Game._orientation).Item3;

            this.VideoMode = new VideoMode(w, h, 32);
            this.Window    = new RenderWindow(this.VideoMode, this.Game._name);

            // Init events
            this.Window.Closed     += new EventHandler(OnClose);
            this.Window.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPressed);

            //_lastTouch = new Stopwatch();
            //_lastTouch.Start();

            //_lastShot = new Stopwatch();
            //_lastShot.Start();

            //_timer = new Stopwatch();
            //_timer.Start();
            //_background = new Sprite();
        }
 public void DrawBot(RenderWindow rw)
 {
     SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Resource)[Program.Data.GetResourceList()[ID].Sprite]);
     s.Position = new Vector2f((X + Program.MyMap.MinX) * Program.Data.TileSizeX, (Y + Program.MyMap.MinY) * Program.Data.TileSizeY);
     s.TextureRect = new IntRect(0, (int)(s.Texture.Size.Y - Program.Data.GetResourceList()[ID].SizeY * 16), (int)(s.Texture.Size.X), Program.Data.GetResourceList()[ID].SizeY * 16);
     rw.Draw(s);
 }
        public GameManager(RenderWindow window, Display startingDisplay)
        {
            this.window = window;

            ActiveDisplay = startingDisplay;
            tex = new RenderTexture(window.Size.X, window.Size.Y);
        }
 public PickWorldDeleteButton(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #21
0
        static void Initialize()
        {
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Environment.CurrentDirectory + "\\libs");
            dtClock = new Stopwatch();
            textFps = new Text("0", new Font(new FileStream("assets\\fonts\\arial.ttf", FileMode.Open, FileAccess.Read)));
            window = new RenderWindow(new VideoMode(1280, 768), "Test", Styles.Default);
            window.SetFramerateLimit(60);
            window.SetTitle("NATE");
            tiles = new TileManager("assets\\tilemaps\\rpgtiles.png", 32);
            iMap = new MapInterface();
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), true); -- for random
            //map = new Map(new Vector2i(32, 32), ((int)tiles.image.Size.X / tiles.tileSize) * ((int)tiles.image.Size.Y / tiles.tileSize), false); -- blank
            map = iMap.ReadMap("map1.ntm");
            
            scaling = new Vector2f(2, 2);
            textureCollection = new Texture[(tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize)];
            camera = new Camera();
            camera.speed = 1000;

            window.Closed += (s, a) => window.Close();
            window.KeyPressed += (s, a) => { if (a.Code == Keyboard.Key.Z) { iMap.WriteMap("map0.ntm", map); } };
            window.MouseWheelMoved += (s, a) => { scaling.X += a.Delta * 0.075f; scaling.Y += a.Delta * 0.075f; };

            dtClock.Start();

            for (int i = 0; i < (tiles.image.Size.X / tiles.tileSize) * (tiles.image.Size.Y / tiles.tileSize); i++)
            {
                textureCollection[i] = tiles.GetTile(i);
                textureCollection[i].Smooth = false;
            }
        }
 public void DrawTop(RenderWindow rw)
 {
     SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Resource)[Program.Data.GetResourceList()[ID].Sprite]);
     s.Position = new Vector2f((X + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX) * Program.Data.TileSizeX, (Y + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY - 1) * Program.Data.TileSizeX);
     s.TextureRect = new IntRect(0, 0, (int)(s.Texture.Size.X), (int)(s.Texture.Size.Y - Program.Data.GetResourceList()[ID].SizeY * 16));
     rw.Draw(s);
 }
Example #23
0
        public Client(RenderWindow window, ImageManager imageManager)
            : base(window, imageManager)
        {
            this.window = window;
            world = new RenderImage(800, 600);

            inputManager = new InputManager(this);

            ticker = new Ticker();

            window.ShowMouseCursor (false);
            window.SetFramerateLimit (60);

            NetPeerConfiguration netConfiguration = new NetPeerConfiguration("2dThing");
            client = new NetClient(netConfiguration);

            uMsgBuffer = new UserMessageBuffer();
            otherClients = new Dictionary<int, NetworkClient>();
            chat = new Chat(this);

            LoadRessources();

            blockTypeDisplay = new Cube(blockType, imageManager);
            blockTypeDisplay.Position = new Vector2f(window.Width - 2*Cube.WIDTH, window.Height - 2* Cube.HEIGHT);
            layerDisplay = new LayerDisplay(imageManager);
            layerDisplay.Position = blockTypeDisplay.Position - new Vector2f(0, 50);

            mouse = new Sprite (imageManager.GetImage("mouse"));
        }
Example #24
0
        //private GameWorld world;

        static SFML.Graphics.RenderWindow InitWindow()
        {
            SFML.Graphics.RenderWindow window = new SFML.Graphics.RenderWindow(VideoMode.DesktopMode, "Top Down", Styles.Fullscreen);
            window.SetVerticalSyncEnabled(true);
            window.SetFramerateLimit(61);
            return(window);
        }
Example #25
0
 public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
 {
     sprite.Position   = position;
     nameText.Position = position;
     renderWindow.Draw(sprite);
     renderWindow.Draw(nameText);
 }
Example #26
0
        public static void Init()
        {
            ContextSettings settings = new ContextSettings (32, 8, 4, 3, 3);
              Styles windowStyle = Styles.Close;

              if (FULLSCREEN) {
            windowStyle = Styles.Fullscreen;
            Game.Width = FULLSCREEN_WIDTH;
            Game.Height = FULLSCREEN_HEIGHT;
            Game.CameraWidth = FULLSCREEN_WIDTH;
            Game.CameraHeight = FULLSCREEN_HEIGHT;
              }

              Context = new RenderWindow (new VideoMode ((uint)Game.Width, (uint)Game.Height), WindowTitleText, windowStyle, settings);

              Context.Closed += OnClose;
              Context.KeyPressed += KeyPressed;
              Context.KeyReleased += KeyReleased;
              Context.SetKeyRepeatEnabled (true);

              Rand = new Random ();
              EventMgr = new EventManager ();
              World = new GameWorld ();

              Camera = new View ();
              Camera.Center = new Vector2f (CameraWidth / 2, CameraHeight / 2);
              Camera.Size = new Vector2f (CameraWidth, CameraHeight); // Half Size
              Context.SetView (Camera);
        }
        public SpriteRendererSubsystem(RenderWindow sb, GameWorld theWorld) : base(theWorld)
        {
            ComponentMask.SetBit(XnaGameComponentType.Sprite);
            ComponentMask.SetBit(XnaGameComponentType.Spatial);

            _renderWindow = sb;
        }
Example #28
0
        public void Run()
        {
            window = new RenderWindow(new VideoMode(800, 480), "sfml-ui Examples", Styles.Default);
            window.Closed += window_OnCloseRequest;
            window.Resized += window_Resized;

            uimanager = new UISceneManager();
            uimanager.Init(window);

            scene1 = new Scene(ScrollInputs.None);
            scene1.Size = new Vector2f(window.Size.X, window.Size.Y);
            scene1.AddComponent(new TextControl(new Font("font.ttf"), 50) { Size = new Vector2f(800, 100), Color = Color.White, Text = "Hello World", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top, BackgroundColor = Colors.SteelBlue });
            scene1.AddComponent(new TextControl(new Font("font.ttf"), 16) { Size = new Vector2f(600, 100), Position = new Vector2f(100, 150), Color = Color.Black, Text = "This is an example of sfml-ui, an ui library for SFML.Net", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top });
            scene1.AddComponent(new PictureControl("example-100.png") { Size = new Vector2f(100, 100), Position = new Vector2f(0, 0), Anchor = AnchorPoints.Left | AnchorPoints.Top });
            scene1.AddComponent(new ButtonControl(new Font("font.ttf"), 16, "button.png", "button_hover.png", "button_pressed.png") { Size = new Vector2f(150, 49), Position = new Vector2f(50, 250), Anchor = AnchorPoints.Left | AnchorPoints.Top, Text = "Press Me :)" });

            uimanager.CurrentScene = scene1;

            while (window.IsOpen())
            {
                window.DispatchEvents();
                window.Clear(Colors.WhiteSmoke);

                uimanager.Render(window);

                window.Display();
            }
        }
Example #29
0
        public MainMenu(RenderWindow window, ImageManager imageManager, Client client, Server server)
            : base(window, imageManager)
        {
            imageManager = new ImageManager();
            p = new Player(null, imageManager);
            mouse = new Sprite(imageManager.GetImage("mouse"));
            pImage = new RenderImage(window.Width, window.Height);
            pImage.DefaultView.Zoom(0.08F);
            pImage.DefaultView.Center = p.Center + new Vector2f(0, -30);
            pImage.SetView(pImage.DefaultView);

            this.window = window;
            this.client = client;
            this.server = server;
            items = new MenuItem[nbrItem];
            items[0] = new MenuItem("Local Game", new Vector2f(0, 100), StartLocal);
            items[1] = new MenuItem("Connect", new Vector2f(0, 130), Connect);
            items[2] = new MenuItem("Options", new Vector2f(0, 160), Option);
            items[3] = new MenuItem("Load map", new Vector2f(0, 190), LoadMap);
            items[4] = new MenuItem("Save map", new Vector2f(0, 220), SaveMap);
            items[5] = new MenuItem("Exit", new Vector2f(0, 280), Exit);

            foreach (MenuItem i in items)
                i.CenterX((int)window.Width);
        }
Example #30
0
        public MainTitleScreen(RenderWindow window)
            : base(window)
        {
            Type = ScreenType.MainTitleScreen;

            base.Init();
               // Gui.AddGameWidget(imb);

            initMenu();

            StraightLineVariableData slvd = new StraightLineVariableData(200F, 100 * 4);
               // slvd.AddKeyData(.25F, 100F);
            slvd.AddKeyData(.5F, 300F);
               // slvd.AddKeyData(.75F, 100F);
            slvd.ComputeData();

            img = new Image(800, 600, new Color(0, 0, 0, 0));
            for (int i = 0; i < slvd.GetCount(); ++i)
            {
               // Log.Cl(slvd.GetData(i));
                img.SetPixel((uint)(100 + i / 4), (uint)slvd.GetData(i), Color.Red);
               // img.SetPixel((uint)(100 + i / 4), (uint)slvd.GetData(i) + 4, Color.Blue);
            }

            tex = new SFML.Graphics.Texture(img);
            spre = new Sprite(tex);

            imb.AddMessage("hoy hoy !");
            imb.OnStopping += new MessageBox.EventHandler(imb_OnStopping);
        }
        //////////////////////___CONSTRUCTORS___//////////////////////

        #region Constructors

        public Camera(Vec2f FieldNum, SFML.Graphics.RenderWindow window)
        {
            m_window = window;
            updateWindow();
            m_minimapFieldSize = (m_minimapSize / FieldNum);
            m_LayerSprite      = Helper.UI;
        }
        public InventoryGUI(RenderWindow rw, int id)
        {
            MyButton = new List<GUIButton>();
            _screen = rw;
            ID = id;
            CurrentButton = 0;
            X = 500;
            Y = 500;
            Visibility = false;

            for (int r = 0; r < 4; r++)
            {
                for (int c = 0; c < 4; c++)
                {
                    MyButton.Add(new InventorySlotButton(_screen, 8, c * 32 + c * 6 + X + 6, r * 32 + r * 6 + Y + 26, r * 4 + c));
                }
            }
            PlayerInventorySizeChange();

            MyButton.Add(new GUIClose(rw, 20, X + 158, Y, 1, 1));
            MyButton.Add(new GUIHead(rw, 21, X, Y, 1, 1));
            MyButton.Add(new InventoryQuickCraftButton(rw, 32, X + 155, Y + 29));
            MyButton.Add(new InventoryDropAllButton(rw, 33, X + 155, Y + 128));
            MyButton.Add(new InventoryDestroyButton(rw, 34, X + 155, Y + 151));
        }
Example #33
0
 public void Draw(RenderWindow window, TimeSpan gameTime)
 {
     foreach (Element ele in Elements)
     {
         ele.Draw(window, gameTime);
     }
 }
 public NewPartyNewCharacter(RenderWindow rw, int id, int x, int y)
 {
     _screen = rw;
     ID = id;
     X = x;
     Y = y;
 }
Example #35
0
        private SFMLGraphics2D()
        {
            m_PostOffice = null;
            m_RenderWindow = null;
            m_SpriteManager = null;
            m_GraphicsSettings = null;
            m_ModuleID = Constant.enumModuleID.GRAPHICS;
            m_MsgTypeArray = new Constant.enumMessage[]
            {
                Constant.enumMessage.INITIALISE,
                Constant.enumMessage.UPDATE,
                Constant.enumMessage.DRAW,
                Constant.enumMessage.CLOSING,

                Constant.enumMessage.LOAD_TEXTURES,
                Constant.enumMessage.UPDATE_GRAPHICS_SETTINGS,
                Constant.enumMessage.SWITCH_SPRITES_DRAW_STATUS,

                Constant.enumMessage.GET_GRAPHICS_SETTINGS,
                Constant.enumMessage.SEND_GAMEOBJECT,

                Constant.enumMessage.SEND_SPRITE_COMPONENTS,
                Constant.enumMessage.SEND_POSITION_COMPONENTS,
                Constant.enumMessage.SEND_TEXTURE_IDS,
                Constant.enumMessage.SEND_COMPONENTS,
                Constant.enumMessage.SEND_GAMEOBJECT,
                Constant.enumMessage.SEND_KEYBOARD_EVENT_HANDLER,
                Constant.enumMessage.SEND_MOUSE_BUTTON_EVENT_HANDLER,
                Constant.enumMessage.SEND_MOUSE_MOVE_EVENT_HANDLER,
                Constant.enumMessage.SEND_MOUSE_WHEEL_EVENT_HANDLER,
                Constant.enumMessage.SEND_GAMEOBJECTCOMPONENTS
            };
        }
Example #36
0
        static void Main(string[] args)
        {
            Files.log("Game started.");

            Console.Title = "Asialaide";

            new Character("Player", 1, 200, 300);

            Drawing.initialise();
            window = Drawing.window; // A local reference.

            // Create events.
            window.Closed += new EventHandler(Program.OnClose);
            window.KeyPressed += new EventHandler<KeyEventArgs>(Input.OnKeyPressed);

            // Load files.
            Files.load("data\\graphics\\crf_char.png");

            // The game loop.
            while (window.IsOpen())
            {
                // Process events.
                window.DispatchEvents();

                // Draw everything.
                Drawing.drawWindow();
            }
        }
 public MainMenuState(RenderWindow rw)
 {
     GameGUI = new List<GUI>();
     _screen = rw;
     GameGUI.Add(new MainMenuGUI(_screen, 0));
     CurrentGUI = 0;
 }
 public void Draw(RenderWindow rw)
 {
     for (int i = Animating.Count - 1; i >= 0; i--)
     {
         Animating[i].Draw(rw);
     }
 }
Example #39
0
 public GameWorld(RenderWindow window)
 {
     this.window = window;
     Tmb         = new TileMapBuilder();
     gameover    = new GameOver();
     initLevel();
     lightcone = new Lightcone(window);
 }
Example #40
0
 public Lightcone(RenderWindow window)
 {
     this.window = window;
     SetupDarkSprite();
     SetupLightSprite();
     darkTex.Draw(lightSprite, new RenderStates(BlendMode.Multiply));
     darkTex.Display();
 }
Example #41
0
 public override void DrawState(SFML.Graphics.RenderWindow objRenderTarget)
 {
     //foreach (var currButton in Buttons)
     //{
     //    objRenderTarget.Draw(currButton.recBody);
     //    objRenderTarget.Draw(currButton.Button_ObsoleteText);
     //    Engine.Instance.GameWindow.SetView(View);
     //}
 }
Example #42
0
        public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
        {
            renderWindow.Draw(backgroundSprite);


            foreach (Entity entity in entities)
            {
                entity.draw(gameTime, renderWindow);
            }

            player.draw(gameTime, renderWindow);
            if (inGameButton)
            {
                renderWindow.Draw(sprite_ingame_over);
            }
            else
            {
                renderWindow.Draw(sprite_ingame);
            }
            if (creditsButton)
            {
                renderWindow.Draw(sprite_credits_over);
            }
            else
            {
                renderWindow.Draw(sprite_credits);
            }
            if (exitButton)
            {
                renderWindow.Draw(sprite_exit_over);
            }
            else
            {
                renderWindow.Draw(sprite_exit);
            }
            if (highscore)
            {
                renderWindow.Draw(sprite_highscore);
            }
            else
            {
                renderWindow.Draw(sprite_highscore_over);
            }

            nameBar.Position = new Vec2f(450, 3 * button_height + 4 * button_y_distance);
            renderWindow.Draw(nameBar);
            Text playerName = new Text("name: " + Game.playerName, Game.smaraFont);

            playerName.Scale    = new Vector2f(0.5f, 0.5f);
            playerName.Position = new Vec2f(450 + 10, 3 * button_height + 4 * button_y_distance + 15);

            gameSprite.Position = new Vector2f(300, 20);
            gameSprite.Scale    = new Vec2f(0.7f, 0.7f);

            renderWindow.Draw(playerName);
            renderWindow.Draw(gameSprite);
        }
Example #43
0
        public EditorScene(SFML.Graphics.RenderWindow drawingWindow, SFML.Graphics.View drawingView)
        {
            w = drawingWindow;
            v = drawingView;

            //Debug, add new sprites here
            spriteBatch  = new Sprite[0];
            sceneObjects = new PixelEngineProj.System.PixelObject[0];
        }
        protected override void DoDraw(SFML.Graphics.RenderWindow rw)
        {
            Color oldColor = _screenFlashSprite.Color;
            Color col      = _color;

            col.A = (byte)(_initialAlpha * Math.Pow(((EffectTotalTime - EffectRemainingTime) / EffectTotalTime), _power));
            _screenFlashSprite.Color = col;

            rw.Draw(_screenFlashSprite);
        }
Example #45
0
        public void draw(GameTime gameTime, SFML.Graphics.RenderWindow window)
        {
            sprite.Position = position;
            sprite.Scale    = new Vec2f((float)Math.Sqrt(lifeTime / startLifeTime), (float)Math.Sqrt(lifeTime / startLifeTime));

            sprite.Color = new Color(sprite.Color.R, sprite.Color.G, sprite.Color.B, (byte)((Math.Sqrt(lifeTime / startLifeTime)) * 255));

            sprite.Color = Lerp(new Color(218, 165, 0), new Color(255, 0, 0), ((float)Math.Pow(1 - lifeTime / startLifeTime, 2)));

            window.Draw(sprite);
        }
Example #46
0
        public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
        {
            renderWindow.Draw(backgroundSprite);

            renderWindow.Draw(gerd);
            renderWindow.Draw(tuan);
            renderWindow.Draw(yorick);
            renderWindow.Draw(logoSprite);
            renderWindow.Draw(logo2Name);
            renderWindow.Draw(gameSprite);
        }
Example #47
0
 public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow window)
 {
     window.Clear(new Color(100, 149, 237));
     if (backedUpGameStateObject != null)
     {
         backedUpGameStateObject.draw(gameTime, window);
     }
     currentGameStateObject.draw(gameTime, window);
     cursor.Position = mouseInput.getMousePos();
     window.Draw(cursor);
     //throw new NotImplementedException();
 }
Example #48
0
        public void Run()
        {
            //var mode = new SFML.Window.VideoMode(800, 600);
            var window = new SFML.Graphics.RenderWindow(SFML.Window.VideoMode.FullscreenModes[0], "Repair Project", SFML.Window.Styles.Fullscreen);

            window.KeyPressed += Window_KeyPressed;

            window.MouseButtonPressed  += OnMouseButtonPressed;
            window.MouseButtonReleased += OnMouseButtonReleased;
            window.MouseMoved          += OnMouseMoved;

            //this.object2DManager.SizeScreen = window.GetView().Size;


            SFML.Graphics.View view = window.GetView();
            this.resolutionScreen = new Vector2f(view.Size.X, view.Size.Y);
            view.Center           = new Vector2f(0, 0);
            window.SetView(view);

            window.SetVerticalSyncEnabled(true);

            Clock clock = new Clock();

            this.officeWorld.StartLevel();

            // Start the game loop
            while (window.IsOpen)
            {
                Time deltaTime = clock.Restart();

                // Game logic update
                this.officeWorld.UpdateLogic(deltaTime);

                window.Clear();

                this.object2DManager.DrawIn(window);

                // Process events
                window.DispatchEvents();


                AObject2D.UpdateZoomAnimationManager(deltaTime);

                // Finally, display the rendered frame on screen
                window.Display();
            }

            this.object2DManager.Dispose(this.officeWorld);

            AObject2D.StopAnimationManager();
        }
Example #49
0
        public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
        {
            Text  pauseText = new Text("pause", Game.smaraFont);
            Vec2f textSize  = new Vector2f(pauseText.GetLocalBounds().Width, pauseText.GetLocalBounds().Height);

            pauseText.Position = (Game.WINDOWSIZE - textSize) / 2 + new Vec2f(0, -170);
            renderWindow.Draw(pauseText);
            pauseText          = new Text("press space to continue", Game.smaraFont);
            textSize           = new Vector2f(pauseText.GetLocalBounds().Width, pauseText.GetLocalBounds().Height);
            pauseText.Position = (Game.WINDOWSIZE - textSize) / 2 + new Vec2f(0, -120);
            renderWindow.Draw(pauseText);
            pauseText          = new Text("press escape to quit", Game.smaraFont);
            textSize           = new Vector2f(pauseText.GetLocalBounds().Width, pauseText.GetLocalBounds().Height);
            pauseText.Position = (Game.WINDOWSIZE - textSize) / 2 + new Vec2f(0, 130);
            renderWindow.Draw(pauseText);
        }
Example #50
0
        public Game()
        {
            Resolution = new Sfs.Vector2u(1280, 720);
#if DEBUG
            _window = new Sfg.RenderWindow(new Sfw.VideoMode(Resolution.X, Resolution.Y), new string(Strings.GameName));
#else
            _window = new Sfg.RenderWindow(new Sfw.VideoMode(1280, 720), new string(Strings.GameName), Sfw.Styles.Fullscreen);
#endif
            var cameraView = _window.DefaultView;
            cameraView.Center = new Sfs.Vector2f(300f, 200f);
            _window.SetView(cameraView);

            var gameplayState = new GameplayState();
            _userInputController = new UserInputController {
                ActualState = gameplayState, ActualViewContainer = new GameplayStateView(gameplayState)
            };
        }
Example #51
0
 public Engine(SFML.Graphics.RenderWindow window)
 {
     _window = window;
     _menu   = new Menu(window);
     if (_musicMenu == null)
     {
         _musicMenu = new Music("..\\..\\..\\..\\Music\\Daft_Punk_-_Veridis_Quo_Cyberdesign_Remix.ogg");
         _musicMenu.Play();
     }
     _settings   = new Settings(this, window);
     _gui        = new GUI(this, window);
     _globalFont = new Font(@"..\..\..\..\Assets\Fonts\Blanka-Regular.ttf");
     _timer      = new Stopwatch();
     _timer.Start();
     _verifHeal2     = new List <Position2>();
     _oldOrientation = "null";
 }
Example #52
0
        private void CreateWindow()
        {
            Window?.Close();

            var videoMode = new SFML.Window.VideoMode((uint)this.Dimensions.X, (uint)this.Dimensions.Y);

            Window          = new SFML.Graphics.RenderWindow(videoMode, this.Title, this.Fullscreen ? SFML.Window.Styles.Fullscreen : SFML.Window.Styles.None);
            Window.Position = this.Location == null ? this.Location : new Vector2i((int)Math.Floor(((double)SFML.Window.VideoMode.DesktopMode.Width / 2) - (videoMode.Width / 2)), (int)Math.Floor(((double)SFML.Window.VideoMode.DesktopMode.Height / 2) - (videoMode.Height / 2)));

            if (FPS > 0)
            {
                Window.SetFramerateLimit(FPS);
            }

            WindowCreated?.Invoke(videoMode.Width, videoMode.Height);
            Window.Display();
        }
Example #53
0
        static void Main(string[] args)
        {
            SFML.Graphics.RenderWindow window = InitWindow();
            GameWorld          world          = new GameWorld(window);
            AbstractNavigation menu           = new MainMenu();
            AbstractNavigation dialog         = new Dialog("1");
            InputHandlerMenu   inputMenu      = new InputHandlerMenu();
            List <MenuCommand> _temp;

            world.Update();
            ManageSound.Instance.StartPlayingMusic();
            while (window.IsOpen)
            {
                window.Clear();

                //INPUT HANDLING AGAIN!
                _temp = inputMenu.HandleInput();
                foreach (MenuCommand m in _temp)
                {
                    m.Execute(menu);
                    m.Execute(dialog);
                }

                window.Draw(world);

                inputMenu.Flush();
                if (menu.Active)
                {
                    window.Draw(menu);
                }
                else
                {
                    if (dialog.Active)
                    {
                        dialog.Update();
                        window.Draw(dialog);
                    }
                    else
                    {
                        world.Update();
                    }
                }
                window.Display();
            }
        }
Example #54
0
        public void draw(GameTime gameTime, SFML.Graphics.RenderWindow window)
        {
            window.Draw(backgroundSprite);

            foreach (Entity ent in entities)
            {
                ent.draw(gameTime, window);
            }
            foreach (PSpawner spawner in particleSpawner)
            {
                spawner.draw(gameTime, window);
            }
            window.Draw(buttonBar);
            window.Draw(pointBar);
            points.DisplayedString       = "points: " + player.Points;
            upgradeCosts.DisplayedString = "upgradecosts: " + player.UpgradeCosts;
            window.Draw(points);
            window.Draw(upgradeCosts);
            window.Draw(upgradeBar);
            string[] s = { "A", "B", "X", "Y", "LB", "RB" };
            for (int i = 0; i < upgradeIcons.Length; ++i)
            {
                window.Draw(upgradeIcons[i]);
                Text t = new Text((i + 1) + " | " + s[i], Game.smaraFont);
                t.Color    = Color.White;
                t.Position = new Vec2f(upgradeIcons[i].Position) + new Vec2f(30.0f, 5.0f);
                t.Scale    = new Vec2f(0.5f, 0.5f);
                window.Draw(t);
            }
            int[] upgrades = player.Upgrades;
            for (int i = 0; i < upgradeButtons.Length; ++i)
            {
                window.Draw(upgradeButtons[i]);
                Text t = new Text("" + upgrades[i], Game.smaraFont);
                t.Color    = Color.White;
                t.Position = new Vec2f(upgradeButtons[i].Position) + new Vec2f(22.0f, 44.0f);
                t.Scale    = new Vec2f(0.5f, 0.5f);
                window.Draw(t);
            }
            Text bombNum = new Text("bombs: " + player.BombNum, Game.smaraFont);

            bombNum.Position = new Vector2f(700, 8);
            bombNum.Scale    = new Vector2f(0.5f, 0.5f);
            window.Draw(bombNum);
        }
Example #55
0
        public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
        {
            //sprite.Rotation = rotation;
            sprite.Position = position;
            sprite.Rotation = rotation;
            renderWindow.Draw(sprite);

            //set weapon Positionsd
            const uint weaponRadiusOffset = 15;

            weaponsPosition = getWeaponPosition(weapons.Count, radius + weaponRadiusOffset, Position, -weaponRotation);
            for (int weaponID = 0; weaponID < weapons.Count; weaponID++)
            {
                weapons.ElementAt(weaponID).Sprite.Rotation = weaponRotation - ((float)weaponID / weapons.Count * 360.0f);
                weapons.ElementAt(weaponID).Position        = weaponsPosition.ElementAt(weaponID);
                weapons.ElementAt(weaponID).draw(gameTime, renderWindow);
            }

            lifebar.draw(gameTime, renderWindow);
        }
Example #56
0
        public override void draw(GameTime gameTime, SFML.Graphics.RenderWindow renderWindow)
        {
            renderWindow.Draw(backgroundSprite);


            for (int i = 0; i < entries.Count; i++)
            {
                text.Position        = new Vec2f(text.Position.X, text.Position.Y + 30);
                text.DisplayedString = entries.ElementAt(i).Name;
                renderWindow.Draw(text);
            }
            text.Position = new Vec2f(600, 60);
            for (int i = 0; i < entries.Count; i++)
            {
                text.Position        = new Vec2f(text.Position.X, text.Position.Y + 30);
                text.DisplayedString = "" + entries.ElementAt(i).Score;
                renderWindow.Draw(text);
            }
            text.Position = new Vec2f(200, 60);
        }
Example #57
0
        static void Main(string[] args)
        {
            var mode   = new SFML.Window.VideoMode(800, 600);
            var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
            //window.KeyPressed += Window_KeyPressed;

            var circle = new SFML.Graphics.CircleShape(100f)
            {
                FillColor = SFML.Graphics.Color.Blue
            };

            // Start the game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();
                window.Draw(circle);

                // Finally, display the rendered frame on screen
                window.Display();
            }
        }
Example #58
0
 protected override void DoDraw(SFML.Graphics.RenderWindow rw)
 {
     rw.Draw(_fadeRadialSprite);
 }
Example #59
0
        static void Main()
        {
            //Get the splash screen graphic
            System.Windows.SplashScreen EngineSplashScreen = new System.Windows.SplashScreen("Resources/SplashScreen.jpg");
            EngineSplashScreen.Show(true);//Show splash screen

            // initialize the main engine form
            EngineMessage("Intializing Pixel Engine", eEngineMessageType.NONE);
            form = new Form1();
            form.Show(); // show our form

            LoadCfg();   //Load config files

            DrawingSurface rendersurface = new DrawingSurface();

            rendersurface.Size     = new System.Drawing.Size(form.Width, form.Height);
            rendersurface.Location = new System.Drawing.Point(0, 0);
            form.Controls.Add(rendersurface);

            EngineMessage("Pixel Engine Ready!", eEngineMessageType.CONFIRM);

            // initialize sfml
            SFML.Graphics.RenderWindow renderwindow = new SFML.Graphics.RenderWindow(rendersurface.Handle);
            //Main cam
            SFML.Graphics.View mainRenderView = new SFML.Graphics.View(new FloatRect(0, 0, 1920, 1080));
            renderwindow.SetView(mainRenderView);
            //UI Cam
            SFML.Graphics.View uiRenderView = new SFML.Graphics.View(new FloatRect(0, 0, 1920, 1080));

            _scene = new EditorScene(renderwindow, mainRenderView);

            //Initialize the resources form
            resourcesForm          = new ResourcesForm();
            resourcesForm.Size     = new System.Drawing.Size(800, 600);
            resourcesForm.Location = new System.Drawing.Point(form.Location.X + form.Width, form.Location.Y);
            resourcesForm.Show();
            resourcesForm.Disposed += new EventHandler(DisposedResourceForm);

            //Debug: create sprite
            PixelEngineProj.Gameplay.PixelSprite newSprite = new PixelEngineProj.Gameplay.PixelSprite("Resources/SpriteIcon.png", new IntRect(0, 0, 128, 128), new Vector2f(0, 0));
            newSprite.Position = new Vector2f(0, 0);

            Text t = new Text("Testing", new Font("Resources/pixelmix.ttf"));

            // drawing loop
            while (form.Visible)
            {
                System.Windows.Forms.Application.DoEvents();
                renderwindow.DispatchEvents();
                renderwindow.Clear(new SFML.Graphics.Color(40, 40, 40));

                //Draw main scene
                renderwindow.SetView(mainRenderView);
                _scene.Draw(renderwindow);

                renderwindow.SetView(uiRenderView);

                //Draw engine text
                renderwindow.SetView(uiRenderView);
                t.Position = new Vector2f(1700, 100);
                t.Draw(renderwindow, RenderStates.Default);

                renderwindow.Display();
                rendersurface.Size = new System.Drawing.Size(form.Width - 300, form.Height);
            }
        }
 protected override void DoDraw(SFML.Graphics.RenderWindow rw)
 {
     rw.Draw(_scanLinesSprite);
 }