Results 1 to 7 of 7

Thread: Question about movement in 2D games

  1. #1
    Member Contributor Bluebomber357's Avatar
    Join Date
    Oct 2008
    Posts
    92

    Question about movement in 2D games

    If I was to make a 2D game, and I wanted to move something says two pixels to the left when I hit the left arrow key, that will move the object a different distance on the screen depending on the resolution of the program. Is it naive to move objects by pixel lengths? Should I be creating units of length based on the height and width of the resolution?
    The Blue Guy Always Wins

  2. #2
    Member Contributor
    Join Date
    Jan 2001
    Posts
    82

    Re: Question about movement in 2D games

    Look into time-based animation. It is far superior to a strictly pixel-based movement algorithm.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: Question about movement in 2D games

    Quote Originally Posted by Bluebomber357
    Should I be creating units of length based on the height and width of the resolution?
    no, you set up the projection matrix so that it is exactly the same no matter the resolution.

  4. #4
    Member Contributor Bluebomber357's Avatar
    Join Date
    Oct 2008
    Posts
    92

    Re: Question about movement in 2D games

    If I use a projection matrix, does it have to be as high as my highest resolution? Like say 1080p?
    The Blue Guy Always Wins

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: Question about movement in 2D games

    no it could be anything like 100x100

  6. #6
    Member Contributor Bluebomber357's Avatar
    Join Date
    Oct 2008
    Posts
    92

    Re: Question about movement in 2D games

    Yeah but if I use 100x100, then won't my movement be really jerky if I run the game at fullscreen on a 1080p monitor. For every 10.8 pixels I move in the drawing area, I'll only move once in the viewport, and I can only move to 100 locations in the y-direction on the viewport right?
    The Blue Guy Always Wins

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: Question about movement in 2D games

    no it's float values so you can use 45.835735f if you like

Similar Threads

  1. Mouse Movement Question
    By Richard145 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-20-2007, 05:47 AM
  2. question about pausing movement of object
    By godhand in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-28-2004, 09:13 AM
  3. the games freez, stops when I playing games
    By Hardcore in forum OpenGL: User Software
    Replies: 4
    Last Post: 01-15-2002, 09:16 PM
  4. Games and Bussiness Question (PLZ help)
    By Luke1_1 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-23-2001, 05:18 PM
  5. Smooth camera movement question...
    By Ace_Man in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-29-2000, 02:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean