1. Post #121
    Gold Member

    March 2005
    3,028 Posts
    How would I move an item along a vector. I have a starting vector and a destination vector. I know how to move it in the direction, but I'm not sure how to move it directly onto the other vector, or to check when it's close (to check for overlap).
    Do you mean interpolation?

    Linear interpolation between two vectors, v₀ and v₁:
    v(x) = x*v₁ + (1-x)v₀, 0<=x<=1
    Reply With Quote Edit / Delete Windows 7 Show Events Informative Informative x 1Agree Agree x 1 (list)

  2. Post #122
    I love Lemon Punch
    Sakarias88's Avatar
    January 2006
    1,262 Posts
    Tried to compile my game project in release (which didn't throw any errors).
    It works just fine since I have all the SDKs that I need.
    I did link and add all the dll files that I would need so it should work on all computers (also added the dll's to the release version).
    Also uninstalled all the SDKs (DirectX 10 sdk and FMOD sdk), restarted my computer and tried to run the application just to be sure and it worked just fine.

    I gave two other people the application so they could try it out but they both experienced the same problem, "The procedure entry point __CxxFrameHandler3 could not be located in the dynamic link library msvcrt.dll.".

    Have anyone else experienced a similar problem?
    What's missing?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  3. Post #123
    Gold Member
    Kondor58's Avatar
    April 2006
    14,096 Posts
    I am looking to make a 2D graphical sidescroller just for experience, I'm learning C++ at the moment and would like to know which API I should be using and why? I've read that XNA is good for beginners but it's for C# or so I've heard. I'm learning C++ just fine, got pointers and object-oriented programming down just fine without any hitches so I'd prefer not to get any "learn C# first" replies unless there is a better reason.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  4. Post #124
    I love Lemon Punch
    Sakarias88's Avatar
    January 2006
    1,262 Posts
    I am looking to make a 2D graphical sidescroller just for experience, I'm learning C++ at the moment and would like to know which API I should be using and why? I've read that XNA is good for beginners but it's for C# or so I've heard. I'm learning C++ just fine, got pointers and object-oriented programming down just fine without any hitches so I'd prefer not to get any "learn C# first" replies unless there is a better reason.
    You could use HGE. It's easy to start with.
    If you know pointers you know how to use HGE.
    Link: http://hge.relishgames.com/

    If you want to get a bit more experience I recommend you start with DirectX directly.
    The DirectX sprites aren't really hard to work with as long as you know what a SRT matrix is (would recommend HGE for starters though).
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Useful Useful x 1 (list)

  5. Post #125
    Gold Member
    Kondor58's Avatar
    April 2006
    14,096 Posts
    You could use HGE. It's easy to start with.
    If you know pointers you know how to use HGE.
    Link: http://hge.relishgames.com/

    If you want to get a bit more experience I recommend you start with DirectX directly.
    The DirectX sprites aren't really hard to work with as long as you know what a SRT matrix is (would recommend HGE for starters though).
    Thanks, this is really useful. By the way is there a generally recommended site for DirectX tutorials if I decide to use that?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  6. Post #126
    Gold Member
    esalaka's Avatar
    July 2007
    10,064 Posts
    Have anyone else experienced a similar problem?
    What's missing?
    They probably don't have the latest C++ runtime
    Reply With Quote Edit / Delete Linux Finland Show Events Useful Useful x 1 (list)

  7. Post #127
    Richy19's Avatar
    May 2010
    5,368 Posts
    Anyone know the actual code that would be used for limiting the FPS?
    I remember reading somewhere that it was something like

    if(frame time < desired frame time) thread.sleep(100);

    Or something like that
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  8. Post #128
    Gold Member
    Z_guy's Avatar
    July 2005
    561 Posts
    Anyone know the actual code that would be used for limiting the FPS?
    I remember reading somewhere that it was something like

    if(frame time < desired frame time) thread.sleep(100);

    Or something like that
    Should probably put (desired frame time - frame time) in sleep instead.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Agree Agree x 3 (list)

  9. Post #129
    Strong Member
    thelinx's Avatar
    January 2007
    8,019 Posts
    Hey, I can't think at the moment, so I've got an issue.

    I'm converting code that depends on a capped framerate at 25 to delta-based code.
    So, for example, you would convert
    player_x = player_x + 10
    -- to
    player_x = player_x + 250 * dt
    
    Here's my issue:

    There's a value that's multiplied by 0.8 each frame. Like this:
    velocity_x = velocity_x * 0.8
    
    How would I convert that to delta-based code?
    Reply With Quote Edit / Delete Linux Sweden Show Events

  10. Post #130
    ColdFusion's Avatar
    December 2009
    2,227 Posts
    Hey, I can't think at the moment, so I've got an issue.

    I'm converting code that depends on a capped framerate at 25 to delta-based code.
    So, for example, you would convert
    player_x = player_x + 10
    -- to
    player_x = player_x + 250 * dt
    
    Here's my issue:

    There's a value that's multiplied by 0.8 each frame. Like this:
    velocity_x = velocity_x * 0.8
    
    How would I convert that to delta-based code?
    velocity_x = velocity_x - (velocity_x * (1 - 0.8) * dt)
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Disagree Disagree x 1 (list)

  11. Post #131
    Strong Member
    thelinx's Avatar
    January 2007
    8,019 Posts
    Thanks.
    Reply With Quote Edit / Delete Linux Sweden Show Events

  12. Post #132
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    I was using http://www.opentk.com/project/TexLib to load textures for my openTK project, but after I had set everything up, I noticed that there were errors on every single line refrencing things that had to do with textures. What did I do wrong?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  13. Post #133
    amazer97's Avatar
    October 2009
    853 Posts
    For starters that should be spritestouch() == true :P

    As for collision detection, how precise do you need it? If your sprites are generally circular, or rectangular, or any other primitive shape, you can use some very simple collision checks. If you need pixel precision, you can do that as well but it IS slower.
    So, what do you need. Precise and slow? Or vague and fast.
    Either one, but I want someone to explain to me how it would work so I would actually learn something out of it, not just "here is some code go put it in."
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #134
    Gold Member
    dvondrake's Avatar
    August 2006
    2,329 Posts
    I'm having some trouble iterating through a list of objects to render. I keep getting an "Access violation reading location" error. Unfortunately it doesn't seem to get any more specific than that. If I break, it seems to be a problem at renderList.begin() somehow.

    The piece of code in question:
    Code:
    list<struct Node*>::iterator itNode = this->renderList.begin();
    
    while(itNode != this->renderList.end()) {
    	(*itNode)->object->Render();
    
    	itNode++;
    }
    Where I declare the list:
    Code:
    list<struct Node*> renderList;
    Basically I want to have a list (renderList) of Nodes, which contain a position and an object to be rendered, then loop through it and render each node's object. Maybe I'm not going about this the right way at all. It's also entirely possible that I'm just doing something incredibly stupid, especially when it comes to pointers. I'm a bit new to C++, most of my experience is in C# where we're lazy and don't touch any memory-related stuff at all.

    I tried adding this before where I iterate through the list, assuming it was a problem with me not adding anything to the list thus far, but the only thing that changes is what piece of code I'm directed towards when I break debugging. With this code, the error seems to be in empty() rather than begin().

    Code:
    if (this->renderList.empty())
    	return;
    Any help would be appreciated. I've tried everything and I just can't get it to work, it's driving me insane.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  15. Post #135
    Gold Member
    Darwin226's Avatar
    January 2009
    4,031 Posts
    velocity_x = velocity_x - (velocity_x * (1 - 0.8) * dt)
    Pretty sure that's not correct.
    It should be velocity_x = velocity_x * 0.8 ^ dt
    Reply With Quote Edit / Delete Windows 7 Croatia Show Events

  16. Post #136
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,333 Posts
    Either one, but I want someone to explain to me how it would work so I would actually learn something out of it, not just "here is some code go put it in."
    Well, I'll teach you two vague methods first, and you can see if they're good enough.

    The first method is circle->circle collision detection. This is arguably the easiest method of collision detection there is. Naturally, this is suited to vaguely circular objects.
    I'm not very good with words, so I drew you a picture...


    Square-square collision is coming next, watch this space!

    Edited:

    Square-square collision is ever so slightly more complex than circle-circle, but it's still extremely simple. Also note that this method can be applied to any two rectangles, they don't have to be square and they do not have to be identical to each other.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Artistic Artistic x 4Useful Useful x 4Friendly Friendly x 2 (list)

  17. Post #137
    Gold Member
    ZeekyHBomb's Avatar
    June 2006
    3,577 Posts
    I'm having some trouble iterating through a list of objects to render. I keep getting an "Access violation reading location" error. Unfortunately it doesn't seem to get any more specific than that. If I break, it seems to be a problem at renderList.begin() somehow.

    The piece of code in question:
    Code:
    list<struct Node*>::iterator itNode = this->renderList.begin();
    
    while(itNode != this->renderList.end()) {
    	(*itNode)->object->Render();
    
    	itNode++;
    }
    Where I declare the list:
    Code:
    list<struct Node*> renderList;
    Basically I want to have a list (renderList) of Nodes, which contain a position and an object to be rendered, then loop through it and render each node's object. Maybe I'm not going about this the right way at all. It's also entirely possible that I'm just doing something incredibly stupid, especially when it comes to pointers. I'm a bit new to C++, most of my experience is in C# where we're lazy and don't touch any memory-related stuff at all.

    I tried adding this before where I iterate through the list, assuming it was a problem with me not adding anything to the list thus far, but the only thing that changes is what piece of code I'm directed towards when I break debugging. With this code, the error seems to be in empty() rather than begin().

    Code:
    if (this->renderList.empty())
    	return;
    Any help would be appreciated. I've tried everything and I just can't get it to work, it's driving me insane.
    It could indicate that the renderList was not constructed properly. Did you compile in debug-mode? What's the exact error-message?
    How do you create the class doing the iteration, how do you initialize renderList and how do you modify it?
    Reply With Quote Edit / Delete Linux Germany Show Events

  18. Post #138
    Gold Member
    Kill coDer's Avatar
    April 2006
    956 Posts
    How can I download the latest windows snapshots from http://www.metamodsource.net/mmsdrop/1.8/ and http://www.sourcemod.net/smdrop/1.3/ and save them in a folder somewhere? I'm essentially wanting to create an out of game autoupdate.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  19. Post #139
    amazer97's Avatar
    October 2009
    853 Posts
    Well, I'll teach you two vague methods first, and you can see if they're good enough.

    The first method is circle->circle collision detection. This is arguably the easiest method of collision detection there is. Naturally, this is suited to vaguely circular objects.
    I'm not very good with words, so I drew you a picture...


    Square-square collision is coming next, watch this space!

    Edited:

    Square-square collision is ever so slightly more complex than circle-circle, but it's still extremely simple. Also note that this method can be applied to any two rectangles, they don't have to be square and they do not have to be identical to each other.
    Wow thanks, that makes a lot more sense than another explanation I read, this helps me greatly! Thanks so much!
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  20. Post #140
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,044 Posts
    I need some way to limit my framerate for my game to 60. Because I have 850 FPS atm, and my game is running like speedy gonzalez.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Disagree Disagree x 1 (list)

  21. Post #141
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,333 Posts
    Wow thanks, that makes a lot more sense than another explanation I read, this helps me greatly! Thanks so much!
    No problem :)
    If you want to know about any other collision methods (if those two aren't what you're looking for), just ask and I'll see what I can do.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Friendly Friendly x 1 (list)

  22. Post #142
    Gold Member
    Jookia's Avatar
    July 2007
    6,768 Posts
    Isn't it a joke towards the Linux versioning?
    Reply With Quote Edit / Delete Windows 7 Australia Show Events Disagree Disagree x 1 (list)

  23. Post #143
    Gold Member
    dvondrake's Avatar
    August 2006
    2,329 Posts
    It could indicate that the renderList was not constructed properly. Did you compile in debug-mode? What's the exact error-message?
    How do you create the class doing the iteration, how do you initialize renderList and how do you modify it?
    Oops, I didn't initialize the class doing the iteration. Wow, I feel silly. Thanks for pointing me in the right direction.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #144
    Gold Member
    Smashmaster's Avatar
    April 2005
    1,504 Posts
    Quick Java question:

    Does the number of functions a non-static class has affect its performance?
    Reply With Quote Edit / Delete Windows XP United States Show Events

  25. Post #145
    slashsnemesis's Avatar
    July 2009
    5,386 Posts
    There was this guide on collision detection with 2d shapes I read a while back, something to do with N or something. Could someone post it if you know what I'm talking about?
    Reply With Quote Edit / Delete Windows XP United States Show Events

  26. Post #146
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    I was using http://www.opentk.com/project/TexLib to load textures for my openTK project, but after I had set everything up, I noticed that there were errors on every single line refrencing things that had to do with textures. What did I do wrong?
    Retoast. I really want to get this working. I can't really do anything untill I figure out the problem.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  27. Post #147
    Gold Member
    Darwin226's Avatar
    January 2009
    4,031 Posts
    Probably didn't add the System.Drawing reference to your project.
    Although, I don't remember it being necessary.
    Reply With Quote Edit / Delete Windows 7 Croatia Show Events

  28. Post #148
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    Here's the class for the textureloader;
    Code:
    using OpenTK.Graphics;
    using System.Diagnostics;
    using System.Drawing;
    using Img = System.Drawing.Imaging;
    
    
    /* Example code:
    
          // Setup GL state for ordinary texturing.
          TexUtil.InitTexturing();
    
          // Load a bitmap from disc, and put it in a GL texture.
          int tex = TexUtil.CreateTextureFromFile("mybitmapfont.png");
    
          // Create a TextureFont object from the loaded texture.
          TextureFont texFont = new TextureFont(tex);
    
          // Write something centered in the viewport.
          texFont.WriteStringAt("Center", 10, 50, 50, 0);
    
    */
    
    namespace TexLib
    {
      /// <summary>
      /// The TexUtil class is released under the MIT-license.
      /// /Olof Bjarnason
      /// </summary>
      public static class TexUtil
      {
        #region Public
    
        /// <summary>
        /// Initialize OpenGL state to enable alpha-blended texturing.
        /// Disable again with GL.Disable(EnableCap.Texture2D).
        /// Call this before drawing any texture, when you boot your
        /// application, eg. in OnLoad() of GameWindow or Form_Load()
        /// if you're building a WinForm app.
        /// </summary>
        public static void InitTexturing()
        {
          GL.Disable(EnableCap.CullFace);
          GL.Enable(EnableCap.Texture2D);
          GL.Enable(EnableCap.Blend);
          GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
          GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
        }
    
        /// <summary>
        /// Create an opaque OpenGL texture object from a given byte-array of r,g,b-triplets.
        /// Make sure width and height is 1, 2, .., 32, 64, 128, 256 and so on in size since all
        /// 3d graphics cards support those dimensions. Not necessarily square. Don't forget
        /// to call GL.DeleteTexture(int) when you don't need the texture anymore (eg. when switching
        /// levels in your game).
        /// </summary>
        public static int CreateRGBTexture(int width, int height, byte[] rgb)
        {
          return CreateTexture(width, height, false, rgb);
        }
    
        /// <summary>
        /// Create a translucent OpenGL texture object from given byte-array of r,g,b,a-triplets.
        /// See CreateRGBTexture for more info.
        /// </summary>
        public static int CreateRGBATexture(int width, int height, byte[] rgba)
        {
          return CreateTexture(width, height, true, rgba);
        }
    
        /// <summary>
        /// Create an OpenGL texture (translucent or opaque) from a given Bitmap.
        /// 24- and 32-bit bitmaps supported.
        /// </summary>
        public static int CreateTextureFromBitmap(Bitmap bitmap)
        {
          Img.BitmapData data = bitmap.LockBits(
            new Rectangle(0, 0, bitmap.Width, bitmap.Height),
            Img.ImageLockMode.ReadOnly,
            Img.PixelFormat.Format32bppArgb);
          var tex = GiveMeATexture();
          GL.BindTexture(TextureTarget.Texture2D, tex);
          GL.TexImage2D(
            TextureTarget.Texture2D,
            0,
            PixelInternalFormat.Rgba,
            data.Width, data.Height,
            0,
            PixelFormat.Bgra,
            PixelType.UnsignedByte,
            data.Scan0);
          bitmap.UnlockBits(data);
          SetParameters();
          return tex;
        }
    
        /// <summary>
        /// Create an OpenGL texture (translucent or opaque) by loading a bitmap
        /// from file. 24- and 32-bit bitmaps supported.
        /// </summary>
        public static int CreateTextureFromFile(string path)
        {
          return CreateTextureFromBitmap(new Bitmap(Bitmap.FromFile(path)));
        }
    
        #endregion
    
        private static int CreateTexture(int width, int height, bool alpha, byte[] bytes)
        {
          int expectedBytes = width * height * (alpha ? 4 : 3);
          Debug.Assert(expectedBytes == bytes.Length);
          int tex = GiveMeATexture();
          Upload(width, height, alpha, bytes);
          SetParameters();
          return tex;
        }
    
        private static int GiveMeATexture()
        {
          int tex = GL.GenTexture();
          GL.BindTexture(TextureTarget.Texture2D, tex);
          return tex;
        }
    
        private static void SetParameters()
        {
          GL.TexParameter(
            TextureTarget.Texture2D,
            TextureParameterName.TextureMinFilter,
            (int)TextureMinFilter.Linear);
          GL.TexParameter(TextureTarget.Texture2D,
            TextureParameterName.TextureMagFilter,
            (int)TextureMagFilter.Linear);
        }
    
        private static void Upload(int width, int height, bool alpha, byte[] bytes)
        {
          var internalFormat = alpha ? PixelInternalFormat.Rgba : PixelInternalFormat.Rgb;
          var format = alpha ? PixelFormat.Rgba : PixelFormat.Rgb;
          GL.TexImage2D<byte>(
            TextureTarget.Texture2D,
            0,
            internalFormat,
            width, height,
            0,
            format,
            PixelType.UnsignedByte,
            bytes);
        }
      }
    
      public class TextureFont
      {
        /// <summary>
        /// Create a TextureFont object. The sent-in textureId should refer to a
        /// texture bitmap containing a 16x16 grid of fixed-width characters,
        /// representing the ASCII table. A 32 bit texture is assumed, aswell as
        /// all GL state necessary to turn on texturing. The dimension of the
        /// texture bitmap may be anything from 128x128 to 512x256 or any other
        /// order-by-two-squared-dimensions.
        /// </summary>
        public TextureFont(int textureId)
        {
          this.textureId = textureId;
        }
    
        /// <summary>
        /// Draw an ASCII string around coordinate (0,0,0) in the XY-plane of the
        /// model space coordinate system. The height of the text is 1.0.
        /// The width may be computed by calling ComputeWidth(string).
        /// This call modifies the currently bound
        /// 2D-texture, but no other GL state.
        /// </summary>
        public void WriteString(string text)
        {
          GL.BindTexture(TextureTarget.Texture2D, textureId);
          GL.PushMatrix();
          double width = ComputeWidth(text);
          GL.Translate(-width / 2.0, -0.5, 0);
          GL.Begin(BeginMode.Quads);
          double xpos = 0;
          foreach (var ch in text)
          {
            WriteCharacter(ch, xpos);
            xpos += AdvanceWidth;
          }
          GL.End();
          GL.PopMatrix();
        }
    
        /// <summary>
        /// Determines the distance from character center to adjacent character center, horizontally, in
        /// one written text string. Model space coordinates.
        /// </summary>
        public double AdvanceWidth = 0.75;
    
        /// <summary>
        /// Determines the width of the cut-out to do for each character when rendering. This is necessary
        /// to avoid artefacts stemming from filtering (zooming/rotating). Make sure your font contains some
        /// "white space" around each character so they won't be clipped due to this!
        /// </summary>
        public double CharacterBoundingBoxWidth = 0.8;
    
        /// <summary>
        /// Determines the height of the cut-out to do for each character when rendering. This is necessary
        /// to avoid artefacts stemming from filtering (zooming/rotating). Make sure your font contains some
        /// "white space" around each character so they won't be clipped due to this!
        /// </summary>
        public double CharacterBoundingBoxHeight = 0.8;//{ get { return 1.0 - borderY * 2; } set { borderY = (1.0 - value) / 2.0; } }
    
        /// <summary>
        /// Computes the expected width of text string given. The height is always 1.0.
        /// Model space coordinates.
        /// </summary>
        public double ComputeWidth(string text)
        {
          return text.Length * AdvanceWidth;
        }
    
        /// <summary>
        /// This is a convenience function to write a text string using a simple coordinate system defined to be 0..100 in x and 0..100 in y.
        /// For example, writing the text at 50,50 means it will be centered onscreen. The height is given in percent of the height of the viewport.
        /// No GL state except the currently bound texture is modified. This method is not as flexible nor as fast
        /// as the WriteString() method, but it is easier to use.
        /// </summary>
        public void WriteStringAt(
          string text,
          double heightPercent,
          double xPercent,
          double yPercent,
          double degreesCounterClockwise)
        {
          GL.MatrixMode(MatrixMode.Projection);
          GL.PushMatrix();
          GL.LoadIdentity();
          GL.Ortho(0, 100, 0, 100, -1, 1);
          GL.MatrixMode(MatrixMode.Modelview);
          GL.PushMatrix();
          GL.LoadIdentity();
          GL.Translate(xPercent, yPercent, 0);
          double aspectRatio = ComputeAspectRatio();
          GL.Scale(aspectRatio * heightPercent, heightPercent, heightPercent);
          GL.Rotate(degreesCounterClockwise, 0, 0, 1);
          WriteString(text);
          GL.PopMatrix();
          GL.MatrixMode(MatrixMode.Projection);
          GL.PopMatrix();
          GL.MatrixMode(MatrixMode.Modelview);
        }
    
        private static double ComputeAspectRatio()
        {
          int[] viewport = new int[4];
          GL.GetInteger(GetPName.Viewport, viewport);
          int w = viewport[2];
          int h = viewport[3];
          double aspectRatio = (float)h / (float)w;
          return aspectRatio;
        }
    
        private void WriteCharacter(char ch, double xpos)
        {
          byte ascii;
          unchecked { ascii = (byte)ch; }
    
          int row = ascii >> 4;
          int col = ascii & 0x0F;
    
          double centerx = (col + 0.5) * Sixteenth;
          double centery = (row + 0.5) * Sixteenth;
          double halfHeight = CharacterBoundingBoxHeight * Sixteenth / 2.0;
          double halfWidth = CharacterBoundingBoxWidth * Sixteenth / 2.0;
          double left = centerx - halfWidth;
          double right = centerx + halfWidth;
          double top = centery - halfHeight;
          double bottom = centery + halfHeight;
    
          GL.TexCoord2(left, top); GL.Vertex2(xpos, 1);
          GL.TexCoord2(right, top); GL.Vertex2(xpos + 1, 1);
          GL.TexCoord2(right, bottom); GL.Vertex2(xpos + 1, 0);
          GL.TexCoord2(left, bottom); GL.Vertex2(xpos, 0);
        }
    
        private int textureId;
        private const double Sixteenth = 1.0 / 16.0;
      }
    
    }
    Edited:

    Every single line beginning with GL.something or anything that has to do with texture loading throws errors. The thing is, in my main program class, It doesn't throw any errors at all, and works perfectly.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  29. Post #149
    Angry Pineapple's Avatar
    March 2010
    1,502 Posts
    EDIT: Nevermind
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 1 (list)

  30. Post #150
    Gold Member
    Kondor58's Avatar
    April 2006
    14,096 Posts
    How do you drill a hole in 1/8 thick glass without breaking it?
    You do realize this is the programming section right
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 2 (list)

  31. Post #151
    Angry Pineapple's Avatar
    March 2010
    1,502 Posts
    You do realize this is the programming section right
    Shit, leaving now
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 3 (list)

  32. Post #152
    Gold Member
    Metroid48's Avatar
    February 2007
    1,020 Posts
    There was this guide on collision detection with 2d shapes I read a while back, something to do with N or something. Could someone post it if you know what I'm talking about?
    This?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Friendly Friendly x 1 (list)

  33. Post #153
    slashsnemesis's Avatar
    July 2009
    5,386 Posts
    Yes, thank you.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  34. Post #154
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,044 Posts
    How do I generate a number between 3 and 4? It's something like generator.nextInt(3) + 4, but I have forgotten.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  35. Post #155
    ColdFusion's Avatar
    December 2009
    2,227 Posts
    I need some way to limit my framerate for my game to 60. Because I have 850 FPS atm, and my game is running like speedy gonzalez.
    You multiply with The DeltaFrameTime.

    I think you where using love so for example

    function love.update( dt ) -- dt = DeltaFrameTime
    myobject.x = myobject.x + 3 * dt -- 3 is the speed of the object we multiply this with deltaframetime. here we go from moving 3 pixels a frame to moving 3 pixels a second.
    end

    DeltaFrameTime is the time it took the frame to render/run completely.
    For example if we run at 10 frames a second delta frame time will be 1/10 = 0.1
    if we for example say we move the pad down when the 'down' key is down we move the object 3 pixels down.
    When you are not multiplying with delta frame time you will move the object 3 pixels every frame on a slow pc this might be with 10 frames a second, on a fast pc this might be with a 100 frames a second.

    So if we multiply with dt instead of moving 3 pixels that frame it will move 3 * 0.1 = 0.3 pixels. and that way make sure we always move at the same speed a second

    FPS goes up, DT goes down.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  36. Post #156
    Gold Member
    ZeekyHBomb's Avatar
    June 2006
    3,577 Posts
    Quick Java question:

    Does the number of functions a non-static class has affect its performance?
    On initialization-time, yes, a negligible cost. On run-time - nothing, a little bit when debugging perhaps; again negligible.

    Edited:

    How do I generate a number between 3 and 4? It's something like generator.nextInt(3) + 4, but I have forgotten.
    generator.nextInt(1)+3, assuming that nextInt(1) outputs a number within [0..1].
    Not really rocket science o.O
    Reply With Quote Edit / Delete Linux Germany Show Events

  37. Post #157
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,044 Posts
    On initialization-time, yes, a negligible cost. On run-time - nothing, a little bit when debugging perhaps; again negligible.

    Edited:



    generator.nextInt(1)+3, assuming that nextInt(1) outputs a number within [0..1].
    Not really rocket science o.O
    Yeah, sorry, i'm just really tired, and I can't think straight.

    Edited:

    Wait. This IS rocket science, your solution didn't work for me, it only generates 3 atm. Also, my way of generating them is:
    	Random generator = new Random();
    	
    	int random1 = generator.nextInt(1) + 3;

    This always gives me 3.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  38. Post #158
    Gold Member
    ZeekyHBomb's Avatar
    June 2006
    3,577 Posts
    Yeah, sorry, i'm just really tired, and I can't think straight.

    Edited:

    Wait. This IS rocket science, your solution didn't work for me, it only generates 3 atm. Also, my way of generating them is:
    	Random generator = new Random();
    	
    	int random1 = generator.nextInt(1) + 3;

    This always gives me 3.
    assuming that nextInt(1) outputs a number within [0..1].
    It probably outputs [0..1[. Or just bad luck .. you never know.
    int random2 = generator.nextInt(2) + 3;
    Reply With Quote Edit / Delete Linux Germany Show Events

  39. Post #159
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,044 Posts
    This worked, thanks.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  40. Post #160
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    How would I move an item along a vector. I have a starting vector and a destination vector. I know how to move it in the direction, but I'm not sure how to move it directly onto the other vector, or to check when it's close (to check for overlap).
    By vector... do you mean coordinate? If you know how to move it in the direction (linear interpolation (lerp?)) then you must be able to just set the item's position to the destination vector, no?
    Reply With Quote Edit / Delete Windows 7 United States Show Events