Results 1 to 4 of 4

Thread: Setting Bounds for the Player Character

  1. #1
    Squire
    Join Date
    Jan 2012
    Posts
    10

    Default Setting Bounds for the Player Character

    Hi!
    I've used the following line of code to restrict the player character with in the top of my window:

    Code:
    if(m_pPos2d->y <= 0) m_pPos2d->y = 1;
    This works fine. But to restrict it with in the bottom of the window, I'm using this:

    Code:
    if(m_pPos2d->y >= GetScreenSizeYf()) m_pPos2d->y = GetScreenSizeYf();
    But this is not working. What else to do to control it with in the bottom of the window?

  2. #2
    Lesser Knight
    Join Date
    Jan 2012
    Location
    Finland
    Posts
    31

    Default

    You need to account for the height of the player too. Something like:

    Code:
    if (m_pPos2d->y >= GetScreenSizeYf() - m_pSize2d.y) m_pPos2d->y = GetScreenSizeYf() - m_pSize2d.y;

  3. #3
    Squire
    Join Date
    Jan 2012
    Posts
    10

    Default

    Quote Originally Posted by Aki Koskinen View Post
    You need to account for the height of the player too. Something like:

    Code:
    if (m_pPos2d->y >= GetScreenSizeYf() - m_pSize2d.y) m_pPos2d->y = GetScreenSizeYf() - m_pSize2d.y;
    Thanks a lot. It's working now. I've one more doubt. Can you tell me the steps to programmatically improve the FPS for a 2D game?
    Last edited by rtr_18; 02-16-2012 at 10:00 AM.

  4. #4
    Lesser Knight
    Join Date
    Jan 2012
    Location
    Finland
    Posts
    31

    Default

    Quote Originally Posted by rtr_18 View Post
    Can you tell me the steps to programmatically improve the FPS for a 2D game?
    There's no simple answer to this. It completely depends on your game and how it's implemented. Use a profiler and see where the time is going. Then optimize the parts that's taking the most time. Or choose better algorithms. Or cheat where's it's appropriate

Similar Threads

  1. Player of the day!
    By soccerfu in forum Tanked
    Replies: 13
    Last Post: 12-19-2011, 12:44 AM
  2. CL_ListView, Scrollbar Ranges out of Bounds
    By ByteKiller in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 05-27-2010, 01:52 PM
  3. A lot of game ready character models are on sale (50% off)
    By biabia in forum Novashell Game Creation System
    Replies: 2
    Last Post: 05-18-2008, 01:06 PM
  4. A lot of game ready character models are on sale (50% off)
    By biabia in forum Dink Smallwood HD
    Replies: 1
    Last Post: 12-17-2007, 04:18 AM
  5. Feature request - character based conversation dialogs
    By whisperstorm in forum Novashell Game Creation System
    Replies: 0
    Last Post: 11-24-2006, 06:53 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •