Calculator Community > Grammer

Gravity Jump

(1/3) > >>

Xeda112358:
I am posting this because I figure it might be useful for anybody who wants to design a platformer in Grammer code. It also might serve as a decent example for pseudocode for others writing a similar engine *cough*

It features collision detection, grayscale, and gravity. For this example, use Enter to jump and left/right to move. Press clear to exit :) It draws a border, but otherwise leaves the screen untouched for your own obstacles.

--- Code: ---:.0:
:13→G'
:π9872→W
:Disp oW
:0→B→A
:64→X→Y
:Line(0,0,64,96,3
:Repeat getKey(15
:Y/64→F
:X/64→E
:Line(E,F,5,5,6
:Line(E+1,F+1,3,3,1,W
:DispGraph
:Line(E,F,5,5,4
:Line(E+1,F+1,3,3,0,W
:pxl-Test('E,F+5,1,5,0→C
:If *B=abs(B
:0→A→B
:Y→Z
:If !C:+B≠abs(B
:B+G'→B+Y→Z
:If B
:Then
:If B≠abs(B:*pxl-Test('E,F-1,1,5,0
:0→B
:If B=abs(B
:Then
:Z/64→D
:While D≠F
:F+1→F
:If pxl-Test('E,F+5,1,5,0
:F→D*64→Z
:End
:End
:Z→Y
:End
:If C*getKey(9
:‾63→B
:getKey(3
:-getKey(2→H*64
:→I+X
:/64
:E+2+H*3→H
:For(G,F,F+4
:If pxl-Test(G,H
:0→I
:End
:X+I→X
:End
:Stop

--- End code ---

nxtboy III:
So is it possible to make certain pixels kill you?

Xeda112358:
You can add an enemy if you want, sure :) You can also create another buffer to hold killing pixels and you pixel test those buffers to figure out if you are on a bad space (that actually sounds like a really good idea o.o )

nxtboy III:
Yeah, that works. Thanks! :)
Yeah, you could use that in one of your games.

Stefan Bauwens:
The screenshot looks already very nice indeed. Well done. I'm pretty sure someone will make a platformer.

Navigation

[0] Message Index

[#] Next page

Go to full version