Creating a Side-View game

Okay, now for tutorial #4, in this tutorial we introduce the concept of a side-view. This is useful if you were going to recreate Wanders from Y's. The entire concept of a side-view is based around gravity, jumping, and walking.

First off you may want to consider your options here, you can use the graph-screen, but that is a bit tricky and complicated, though I may write a tutorial on that later. There is the option of using xLIB, which is not only easy, but looks pretty, but in order to use xLIB I belive you need to know how to do similar things on the homescreen, thus, we are going to make the 3rd option; we are going to make ourselves a platform engine on the homescreen.

To start things off, let's set up our screen ,matrix, and tiles.

:ClrHome						;
:[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,			;This is broken into many lines so you can read it
   1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,			;in reality it needs to all be in 1 line so the calc
   1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,			;won't freak out.
   1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,			;
   1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,			;
   1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,			;
   1,0,0,0,1,8,8,8,8,8,8,1,0,0,0,1,			;
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1/->/[A]		;/->/ is Sto
" X      ^ /->/Str1					;/->/ is once again, Sto

Fancy huh? The 0's are going to be blank, the 1's are going to be walls, and the 8's are going to be something like water or lava, either way, it's going to be able to be movable in. Now, to draw the screen.

:For(A,1,8						;
:For(B,1,16						;
:Output(A,B,sub(Str1,[A](A,B)+1,1			;This outputs the tile that the map tells it to
:End							;
:End							;
:2/->/C:2/->/D:1/->/F					;/->/ is always Sto
:2/->/A:2/->/B:0/->/G					;
:Repeat X=45						;45 is the getKey for [CLEAR]
:Output(A,B," 						;Outputs a space where we used to be
:Output(C,D,"/pi/					;/pi/ is the pi symbol, that is us
:getKey/->/X						;Unlike a walking engine, this getKey is not within a
							;Repeat Ans:End block, this is because you don't want
							;action to stop!
:C/->/A:D/->/B						;Stores were you are, to were you will be
:C+(G>0 and [A](C+1,D)>7 or not([A](C+1,D		;If your personal gravity is more than 0 and there is
							;nothing solid below you, you go down.
:Ans-(G<0 and not([A](C-1,D/->/C			;If your personal gravity is less than 0 and there is
							;nothing above you, then you are allowed to go up.
:G+(G/<=/0)+(1-G)(0<[A](C-1,D				;This adds 1 to your personal gravity, and makes it 1
							;if there is something above you.
:Ans-4(X=21 and [A](C+1,D/->/G				;This subtracts 4 from your personal gravity if you
							;press [2nd] and are standing or are ontop of something
							;solid or semisolid, you can jump off of any non 0 tile
:D+(X=26 and [A](C,D+1)>7 or not([A](C,D+1		;This'll add 1 to your horizontal if you press Right
:Ans-(X=24 and [A](C,D-1)>7 or not([A](C,D-1/->/D	;and this'll subtract 1 if you press left
:F-2(F=24 and F)+2(F=26 and F<0/->/F			;This changes your direction, 1 == Right, -1 == Left
:End							;

This engine is just a core engine, and is fast at that. You can add many things to it to make it better, and to prove that I did, it turned out to be Metroid Pure. If you open up the game you can still recognize the original code!

Some ideas to add, perhaps abilities to walk off the screen, you can make it so there is a larger repeat loop around the drawing and the main repeat loop will exit with [CLEAR] or if you travel off screen. Perhaps enemies and shooting is a good idea as well, It's easiest to make the enemies travel for the player!

Thanks, and happy programming - Fred Sparks

Return to the previous page