News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Simple My Butt

Started by ScottieBro1, September 19, 2024, 01:36:06 PM

Previous topic - Next topic

ScottieBro1

Can someone please help me workout this small code fragment.
First it clings against walls when I try to move player around while jumping.

Is there a better way to do collision detection maybe one pass not two like mine
first platforms down and up then walls side to side.

Keep this short as I want to be able to follow code.
Thanks scott B

Flushkeys stops stickykeys but what about the rest.

kevin


  Collision in games can be a lot more intricate than it appears.. It's often a recursive process of working out where the next allowable position is going to be.   So give it our next position from the current position.


  To de-clutter our brains let's just solve for X. 

   -- Compute NEW_X_POSITION

          NEW_X_POSITION = Current_X_Position + X_Speed



   -- Check for limits
   
         if character is moving right say, then we find any limits (walls) that are directly on the right of us. 

            -  So if we're working from a map, we could Scan from the Players Map Position to the right looking for the first blockage.. Do this for the number of vertical rows required (players height). 


            - Check if players right hand edge is beyond the blockage limits.

                  - If there's an overlap, then we could set NEW_X_POSITION = Limit_X - Players_WIDTH

               
    Repeat the process for each layer required or height of the character.   

    once there's no more impacts on the New position, that becomes our current position