Computer Science Canada Platform Jumping Help |
Author: | evildaddy911 [ Thu Oct 27, 2011 7:42 am ] | ||||||
Post subject: | Platform Jumping Help | ||||||
What is it you are trying to achieve? simple platform jumping game What is the problem you are having? the character sinks into the platforms and sometimes goes through them Describe what you have tried to solve this problem altering the whatdotcpolor for loops to predict when the character will make contact:
insted of
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1.0 |
Author: | Zren [ Thu Oct 27, 2011 7:38 pm ] | ||
Post subject: | RE:Platform Jumping Help | ||
Your relative coordinate in your for loop seems to be a bit off. for j : y - 3 + yv .. y + 3 y := 5 yv := 10 for j : 5 - 3 + 10 .. 5 + 3 for j : 12 .. 8 I'm also going to assume there is no change in position over the x plane. ~ Also, what happens when the pixel (i, -3) is grey, but (i, -2) isn't grey?
|
Author: | evildaddy911 [ Fri Oct 28, 2011 10:21 am ] | ||||
Post subject: | Re: Platform Jumping Help | ||||
do you mean (i,y-3)? also, i took out the i forloop and just used
then i put in another whatdotcolor forloop for the lateral movement:
|
Author: | Zren [ Fri Oct 28, 2011 11:09 am ] |
Post subject: | RE:Platform Jumping Help |
I purposely put the range from -3 .. 3 in the for loop I copied from you. This was to simplify the thought process. Bascially, -3 would be gray, and thus: move = false vy = 0 but then you keep running though the loop, and since -2 is not gray: move = true. But wait? vy = 0 so nothing should be happening right? Well, at least until you hit your 'gravity code', which does vy -= 1 when move is true. ~ Basically you were doing: y + vy - (width/2) .. y + (width/2) Your right side was missing the displacement of moving that frame (velocity_y). So the upper limit could be skimping on some areas to check. Or in the case I mentioned, not check at all. ~ You were on the right track before. You were (trying to) calculating collision detection on where you'd end up before moving. dx = obj.x + obj.velocity_x dy = obj.y + obj.velocity_y Check collision on (dx,dy). If no collision -> move obj. Your player should never end up in a wall to begin with, thus you shouldn't need to worry about 'pushing' him out of the wall. ~ Also, by removing that for loop (I'm assuming as I don't have your updated code), you're now only checking collision (above? and) below the box's (x,y). Essentially your collision detection is for a line now. So the box will overlay over your walls possibly. |