CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2016
    Posts
    1

    Post Simple platform game,player doesnt move properly on the block.

    I have made a simple platfrom game, when i made a simple block on screen, the character had proper movements around, but when i add some background and a little more in game, the character doesn't move properly when it is on the block and it keep in viberating.

    following is the code for a block.

    #region Block1
    /////1. side collision
    if (player.Right > Block1.Left && player.Left < Block1.Right - player.Width && player.Bottom<Block1.Bottom && player.Bottom > Block1.Top)
    right = false;
    if (player.Left < Block1.Right && player.Right > Block1.Left + player.Width && player.Bottom < Block1.Bottom && player.Bottom > Block1.Top)
    left = false;


    /////2. top collisions
    if (player.Left + player.Width > Block1.Left && player.Left + player.Width < Block1.Left + Block1.Width + player.Width && player.Top + player.Height >= Block1.Top && player.Top < Block1.Top)
    {
    jump = false;
    force = 0;
    player.Top = Block1.Location.Y - player.Height;

    }


    ///3. head collisions
    if (player.Left + player.Width > Block1.Left && player.Left + player.Width < Block1.Left + Block1.Width + player.Width && player.Top-Block1.Bottom<=10 && player.Top-Block1.Top>-10)
    {
    force = -1;
    }
    #endregion

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Simple platform game,player doesnt move properly on the block.

    Why don't you add some Debug.WriteLine statements to try to figure out where things are going wrong?

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Simple platform game,player doesnt move properly on the block.

    Make sure you are double buffering your graphics. Another good option may be to use the BitBlt API.

    https://msdn.microsoft.com/en-us/lib...or=-2147217396

    http://www.codeproject.com/Articles/...Paste-Graphics

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured