Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - StormWingDelta

Pages: 1 [2] 3 4
16
DotNet / Infinite Size Map Collision Detection
« on: April 27, 2014, 06:44:39 pm »
Just wondering how to do this fast enough to where I won't kill over and die before the frame ends when detecting collisions.


The map I'm working with is so dang big that the usual collision detection of two loops won't work fast enough.  Is there anything that works for a map regardless of size and can handle a map with no size limits other than the Max/Min Values of the datatype being used?  With my current system I start lagging at a few dozen sprites so anything that could both handle a worst case of a sprite being at each end of the map and several thousand sprites in small clusters would help.  Also would have to be dynamic since I know most sprites that aren't controlled by the players aren't going to be any further out than the furthest player is.

17
DotNet / Sprite Sheets in SFML
« on: April 24, 2014, 10:18:56 pm »
Been hunting the forums for this and I know it has been done but can't find it.  I know it is similar to what is done with tile mapping but not sure what to use for the sheet and selecting the part of the animation.  :(

18
DotNet / Strange bug with SFML when rendering sprites close together.
« on: April 15, 2014, 05:41:51 am »
Noticed that after a while they simply vanish and never reappear again for some odd reason.  I've been working on an AI using vectors and the sprites currently after some time line up on top of their target but after a while they just vanish for some strange reason when they stay close long enough but also never reappear.    Don't know what's going on here and no clue if it is my code of SFML. ??? ??? ???




Will post code if needed later but right now checking if anyone else has had this issue.

19
DotNet / FPS Count issues
« on: April 14, 2014, 09:59:55 pm »
Been trying to remember how to setup a game loop with an FPS limiter but so far I've been getting over 600fps without a limiter and as you can tell that's way too fast. :(  I know my counter is working fine but now I just need to figure out how to slow things down to 60FPS or lower. ???


Currently I'm using C#'s Thread.Sleep to slow the game down but I know there are other ways to pull this off and don't want to sleep the thread if I don't have to. :(

20
Someone missed the +, -, +=, and -= operators. ???  Not sure if bug, forgotten about, or oops. XD

These are missing on adding numbers to vectors. 

21
 ???

Here's the code that created the shape.

CircleShape mapcircle2 = new CircleShape(550);
mapcircle2.Position = new Vector2f(0,0);
mapcircle2.OutlineColor = new Color(0,255,0);
mapcircle2.Origin = new Vector2f(mapcircle2.Radius,mapcircle2.Radius);
 

For some reason the fill color is drawing and not the outline color so I don't know what's going on. ???

22
SFML website / Off topic Coding Board?
« on: April 09, 2014, 06:27:52 pm »
Would help keep the general board clear of non-SFML related things to say the least and give us a place to put things that normally don't fit 100% with SFML.


This would cool off a few hot heads when it comes to certain things and their locations as well. :)

23
General / Space Shooter AI Questions
« on: April 09, 2014, 04:46:25 am »
Been working on this and I know some of what I need but my issue is finding the logic and equations I need. >.>


I'm trying to get a ship AI working for my space shooter and one of my main snags is I keep finding things that use the window size, length, and width to tell the AI things but my issue is I'm using a borderless map that doesn't stop at the window's edge and any time I try to change these to not use the window and just go for open space they fall apart like toothpick houses.  :'(

I know I'm going to need to tell the AI if it should, attack, guard, follow, build something, mine some resources, etc so that kills part of my issue of knowing what it should do.  Also I got things to get the direction something is in and other things an AI would need I just need help finding something that works in open space rather than a map no bigger than the window it is in. >.>

Mainly needing help finding AI Examples and tutorials that deal with borderless maps for shooters like the one I'm working on.   Mainly interested in the logic and equations of these AI's but as for the code I can figure that out myself if I have enough information.

That aside my SFML game should be turning up in the projects section when I finally work out this annoying snag. :)

24
Didn't see any extending of C#'s forms class in window or renderwindow and was curious how to make it so I could use both together without a headache. ???


Currently my idea would be to do this number and extend both.
public class MyWindow : RenderWindow, Form
 
Or just pop open small forms outside the main window and pass events to it from them, but I'm wanting to use some of the form functionality with SFML and not get blown to kingdomcome while doing so.   ??? :-\

25
DotNet / An interesting Dilemma with coordinates
« on: April 06, 2014, 09:36:16 pm »
I'm puzzled as to what would happen and how to get around a few things to do with hitting the float max when using the view to show what the player is up to and were.


Say the ship approaches float max but we all know the view is going to hit is sooner due to its coordinates being further ahead on that side the player is moving.  I've got a Sector Counter that I should just have to up/lower by one on the respective axis and just set the view's coordinates to what would normally be used to cause a wrap around effect on size limited maps.
The Green is what I want to happen to the ship.
Purple is what I know happens when you do wrapping maps.
Red is where the ships is now.
Keep in mind I also want to do this with bullets, beams, and shockwaves when interacting with the sector borders so that might end up with some creative partial drawing of being on both sides of the line.



Want to not just jump into but be able to see and shoot into other sectors without ending up on the opposite side of the one I'm in. >.>  Any ideas?  Meantime I'll try and get a working example up and running to show off and see if anyone can help then.

26
Ran into this issue little bit ago and seems it is a big pain to get byte[] conversion to work right and also got no clue how to extract the pixel color array of the image.  Yes Image to Byte[] is working but it would be nice if there was a straight conversion saving us a step or two. :)

27
Not sure if it is the code I'm using or SFML but whatever the case something has imploded.  Managed to get it to a point that the only issue left is color not wanting to play nice and stay the same.  Worst case though is the image doesn't show or is turned into a line.  :( ???


Here's the current coding from the SFML images up above.
Image image = new Image((uint)TestImages.TestShip.Width,
                    (uint)TestImages.TestShip.Height,
                    GetRGBValues(new System.Drawing.Bitmap(TestImages.TestShip)));
                Image image2 = new Image((uint)TestImages.ClosedGridHall.Width,
                    (uint)TestImages.ClosedGridHall.Height,
                    GetRGBValues(new System.Drawing.Bitmap(TestImages.ClosedGridHall)));
                Image image3 = new Image((uint)TestImages.TestShip.Width,
                    (uint)TestImages.TestShip.Height,
                    MarshalImageToByteArray(new System.Drawing.Bitmap(TestImages.TestShip)));

                Sprite exsprite = new Sprite(new Texture(image));
                Sprite exsprite2 = new Sprite(new Texture(image2));
                Sprite exsprite3 = new Sprite(new Texture(image3));
 
Commented out the one that doesn't work for what I'm doing.  Now I'm down to 3 the commented out one doesn't work with images stored as resource files.
//http://stackoverflow.com/questions/7350679/convert-a-bitmap-into-a-byte-array-in-c
        private static byte[] ImageToByteArray(System.Drawing.Image resourceimage)
        {
            System.Drawing.ImageConverter imgcon = new System.Drawing.ImageConverter();
            return (byte[])imgcon.ConvertTo(resourceimage, typeof(byte[]));
        }

        // Yes Straight up C&P from here:
        //http://social.msdn.microsoft.com/Forums/vstudio/en-US/47c5a003-1d26-4213-9370-fba3aa170c21/fastest-method-to-convert-bitmap-object-to-byte-array?forum=csharpgeneral
        // A Case of either use full quantified names for SFML or C#. >.>
        private static byte[] GetRGBValues(System.Drawing.Bitmap bmp)
        {

            // Lock the bitmap's bits.
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
            System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            int bytes = bmpData.Stride * bmp.Height;
            byte[] rgbValues = new byte[bytes];

            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
            bmp.UnlockBits(bmpData);

            return rgbValues;
        }
        //http://www.sitepoint.com/forums/showthread.php?223894-Bitmap-to-byte-array-in-C
        /*private static byte[] StreamImageToByteArray(System.Drawing.Image resourceimage)
        {
            MemoryStream stream = new MemoryStream();
            resourceimage.Save(stream, System.Drawing.Imaging.ImageFormat.Gif);
            //Byte[] bytes =
            if (stream != null)
            {
                stream.Close();
            }
            return stream.ToArray();
        }*/

        //http://stackoverflow.com/questions/13602281/converting-bitmap-pixels-as-byte-array-fails
        private static byte[] MarshalImageToByteArray(System.Drawing.Bitmap bmp)
        {
            // Lock the bitmap's bits.  
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
            System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            int bytes = Math.Abs(bmpData.Stride) * bmp.Height;
            byte[] rgbValues = new byte[bytes];

            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
            bmp.UnlockBits(bmpData);
            return rgbValues;
        }
 

Here's an image of the several errors. >.>

Top two are fine but the image color is off.  The last one on the left is distorted to heck and back.  The one on the right is loaded from file normally.  I Have no idea where I'm messing up.  :(

28
DotNet / View not moving with sprite for some reason
« on: April 04, 2014, 03:45:44 pm »
Not sure what I missed but whatever it is it has to be so simple that it is laughing at me from some dark hole in the universe. >.>




class SFMLMovingViewTest
    {
        RenderWindow window;
        View movingview;
        Font exfont;
        Text extext2, extext3;
        MovingSprite movingspriteplayer;
        public SFMLMovingViewTest()
        {
            exfont = new Font("Fonts/00Starmap/00TT.TTF");
            extext2 = new Text("Key Pressed: ", exfont, 15);
            extext3 = new Text("Key Released: ", exfont, 15);
           
            Image image = new Image((uint)TestImages.TestShip.Width,
                (uint)TestImages.TestShip.Height,
                GetRGBValues(TestImages.TestShip));
            movingspriteplayer = new MovingSprite(new Texture(image));
        }

        public void StartSFMLProgram3()
        {
            VideoMode vm = new VideoMode(800, 600);
            window = new RenderWindow(vm , "SFML C# Example");
            movingview = new View(new FloatRect(0, 0, vm.Width, vm.Height));
            window.SetView(movingview);
            Image image = new Image((uint)TestImages.OpenGridFourWay.Width,
                (uint)TestImages.OpenGridFourWay.Height,
                GetRGBValues(TestImages.OpenGridFourWay));
           
            Sprite exsprite = new Sprite(new Texture(image));
            movingspriteplayer.Position = new Vector2f(vm.Width / 2, vm.Height / 2);
           
           

            Text extext = new Text("My Font!!!", exfont, 15);
           
            extext2.Position = new Vector2f(0,50);
            extext3.Position = new Vector2f(0, 70);
           

            window.Closed += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(KeyEventPressed);
            window.KeyReleased += new EventHandler<KeyEventArgs>(KeyEventReleased);
           

            while (window.IsOpen())
            {
               
               
                window.DispatchEvents();

                movingspriteplayer.MoveSprite(1,1);
                //movingview.Move(movingspriteplayer.Origin);
                movingview.Center = movingspriteplayer.Position;
                window.SetView(window.GetView());
                extext.DisplayedString = "" + movingspriteplayer.Position.ToString();
                window.Clear();
                window.Draw(exsprite);
                window.Draw(movingspriteplayer);
                window.Draw(extext);
                //window.Draw(extext2);
                //window.Draw(extext3);

                window.Display();
            }

        }

        void OnClosed(object sender, EventArgs e)
        {
            window.Close();
        }

        void KeyEventPressed(object sender, KeyEventArgs e)
        {
            extext2.DisplayedString = "Key Pressed: " + e.Code;

        }
        void KeyEventReleased(object sender, KeyEventArgs e)
        {
            extext3.DisplayedString = "Key Released: " + e.Code;

        }
       

        //http://stackoverflow.com/questions/7350679/convert-a-bitmap-into-a-byte-array-in-c
        private static byte[] ImageToByteArray(System.Drawing.Image resourceimage)
        {
            System.Drawing.ImageConverter imgcon = new System.Drawing.ImageConverter();
            return (byte[])imgcon.ConvertTo(resourceimage, typeof(byte[]));
        }

        // Yes Straight up C&P from here:
        //http://social.msdn.microsoft.com/Forums/vstudio/en-US/47c5a003-1d26-4213-9370-fba3aa170c21/fastest-method-to-convert-bitmap-object-to-byte-array?forum=csharpgeneral
        // A Case of either use full quantified names for SFML or C#. >.>
        private static byte[] GetRGBValues(System.Drawing.Bitmap bmp)
        {

            // Lock the bitmap's bits.
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
            System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            int bytes = bmpData.Stride * bmp.Height;
            byte[] rgbValues = new byte[bytes];

            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
            bmp.UnlockBits(bmpData);

            return rgbValues;
        }
    }
   
    public class MovingSprite : Sprite
    {

        public MovingSprite() : base()
        {}
        public MovingSprite(Texture texture)
            : base(texture)
        {

            CenterOrigin();
        }
        public MovingSprite(Texture texture, IntRect intrect)
            : base(texture, intrect)
        {
            CenterOrigin();
        }
        public MovingSprite(MovingSprite copy)
            : base(copy)
        { }

        public void CenterOrigin()
        {
            if(this.Texture != null && !this.TextureRect.Equals(null))
            {
                this.Origin = new Vector2f(this.TextureRect.Width / 2, this.TextureRect.Height / 2);
               
            }
        }

        public void MoveSprite(float xvec, float yvec)
        {
            this.Position += new Vector2f(xvec,yvec);
        }
        public void MoveSpriteByDirection(float angledirection, float speed)
        {
            //MoveSprite();
        }

    }

 

No clue what I'm missing.  Been trying to get the view to move with the sprite in question but this is my latest attempt at it and it isn't working. >.>

29
DotNet / No move method for sprite in SFML.net????
« on: April 04, 2014, 05:18:54 am »
 ???  Rather annoying too but it would help.  Meantime I guess I'll just make my own. >.>  Trust me I looked and checked using intellisense too just to see if I was dreaming or something.  :o

30
DotNet / Resource Images to SFML.net Images?
« on: April 02, 2014, 08:33:13 pm »
Hard to tell if there is an easy way to simply use an image stored as a resource as an SFML.net image.


The resources files in visual studio store as drawing.bitmap  but the needed image is SFML Image. >.>

Pages: 1 [2] 3 4
anything