# Rectangle collision, with gravity and tiles...

This topic is 4705 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Quote:
 %Jumping input(y axis)if JoyButton1 = true and count < limit then %If the character is jumping and can still go highervel := (power - grav) %Upwards velocity is = to power of jump - gravity of the levelcount += 1 %when count is > than limit the character can't go anyhigher and starts to fallelsif JoyButton1 = true and count >= limit then %If the character is jumping but reached his limit%Upwards velocity is = to current velocity - gravity, eventually this will be a negative and pull you downvel := (vel - grav)if vel < -15 then %this is the limit of the speed at which you can fallvel := -15end ifelsif collision = 4 and JoyButton1 = false then %lets you jump again if you have landed and let go of jumpcount := 0%if you land you will stop falling, but if your still holding jump you wont jump until you let it go, then press itelsif collision = 4 thenvel := 0elsif JoyButton1 = false then %if you let go of jump you will begin to fallvel := (vel - grav)count := limitif vel < -15 then %This is the limit of the speed that you can fallvel := -15end ifend if

All of these elseif's in your code might be your problem, look through them and see if they any of the elseif's are triggered before you reach the last gravity applying statement. Beucase in this code.

Quote:
 %Checks if Left is the smallest, then aplies displacement, also tells the side it collided onif penetrationLeft < penetrationRight and penetrationLeft < penetrationUp and penetrationLeft < penetrationDown thenx (1) -= penetrationLeftcollision := 1%Checks if right is the smallest, then aplies displacement, also tells the side it collided onelsif penetrationRight < penetrationLeft and penetrationRight < penetrationUp and penetrationRight < penetrationDown thenx (1) += penetrationRightcollision := 2%Checks if top is the smallest, then aplies displacement, also tells the side it collided onelsif penetrationUp < penetrationRight and penetrationUp < penetrationLeft and penetrationUp < penetrationDown theny (1) -= penetrationUpcollision := 3%Checks if bottom is the smallest, then aplies displacement, also tells the side it collided onelsif penetrationDown < penetrationRight and penetrationDown < penetrationUp and penetrationDown < penetrationLeft theny (1) += penetrationDowncollision := 4end if

collision may always be set to 4 for some reason.

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013197
×