I'm testing out my skills on creating a really basic platformer game, but I'm stuck on a certain part. What I have are just some basic platforms, a ground base at the bottom of the screen, and just 1 pixel that you can move around, along with boundaries at the left and right edges. However, I'm stuck at trying to make your player pixel stop falling if it encounters a new platform below it - instead, it just falls through the platform to the ground base as if it wasn't even there (leaving a hole in the platform). I've tried several different things but for some reason it just keeps falling through. Maybe I'm just tired :P
CONTROLS: Arrows to Move (Left, Right, and Up). You can also move right or left in mid-air.
Heres my code:
:ClrDraw
:AxesOff
:CoordOff
:LabelOff
:PlotsOff
:0->Xmin:94->Xmax
:0->Ymin:62->Ymax
:Line(0,2,94,2
:Line(40,12,45,12
:Line(50,22,55,22
:Line(60,32,65,32
:Line(70,42,75,42
:Line(80,52,94,52
:3->X:3->Y:3->B
:While 1
:If X>=40 and X<=45:Then
:7->P //P is jump height, which prevents you from jumping up through a platform.
:Else
:13->P
:End
:Pt-On(X,Y
:X->A
:B->Y
:getKey->K
:X-(K=24 and X>=1)+(K=26 and X<=93)->X
:If K=25:Then
:For(Y,B+1,B+P)
:Pt-On(X,Y
:Pt-Off(X,Y-1
:Y->T
:End
:For(I,1,2) //beginning of mid-air movement
:getKey->K
:X+2(K=26 and X<=93)-2(K=24 and X>=1)->X
:For(I,-5,5)
:Pt-Off(X+I,T
:End:End //end of mid-air movement. Disadvantage is that you can move left and right only at the height of your jump.
:For(Y,B+P,B+1,-1
:Pt-On(X,Y
:Pt-Off(X,Y+1
:If pxl-Test(X,Y-1)=1:Then //trying to test if a platform is beneath you, but not working... I think I know why, but I don't know how to fix
:Y->B
:End:End:End
:Pt-Off(A,B
:Pt-Off(A,B+1
:End
Also, feel free to comment on other parts of my code if you see something else :) I've only been working on this for a little bit, so it's probably not the best.