Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: aeTIos on May 23, 2011, 01:24:38 pm

Title: [TUTORIAL] Making a platformer engine in Axe
Post by: aeTIos on May 23, 2011, 01:24:38 pm
Okay, since I wanted to do something special for my 1000th post, I decided to write a tutorial on doing platformers. What? Oh, you can't wait? Let's start, then!

The first thing we need, is a tilemap. In this tutorial, I'm using a simple, very awful, but useful tilemap.

Put this in prgmPLATFTLM:
Code: [Select]
.AXTILEMP
.Map:
[000000000000000000000000→Str1TM
[000000000000000000000000 
[000000000000000000000000
[000206050000000000000000 
[000300040002060500020605 
[000300020605000206000004 
[000300030004000300000004 
[010101010101010101010101 
.Tiles:

[FFAAFF55FFAAFF55→Pic1TL
[0F10204080808080
[8080808080808080
[0101010101010101
[F008040201010101
[FF00000000000000
[0000000000000000
.Now, we can draw the tilemap!
Lbl DMP
.Draw MaP
For(A,0,7
For(B,0,11
If {Str1TL+(A*12)+B}→Θ
Θ -1→Θ
Pt-On(B*8,A*8,Pic1TL+(Θ*8)
End
End
End
Return

If you run this code, you’ll see a not-so-very-bad looking tilemap (uhh, actually nothing, there’s no DispGraph xD).
Now comes the hard part: The collisions. There are 2 ways to do this:
1.   Pixel-based collision
2.   Tile-based collision

The tile-based collision is the hardest. That’s why I’m doing that first.

Put this code in prgmPLATFCOL:
Code: [Select]
.COLLISSN
Lbl COL
.COLlission
.Inputs: arg1=X ,arg2=Y ,arg3=dX to check,arg4=dY to check (I’ll explain later)
.Since we want it smooth-scrolling, we divide the X and Y value by 8 to get the corresponding tile
{Str1TL+(((Y+r2)/8)*12)+((X+r1)/8)}
Return

Okay, we can get the tile now, but there’s nothing to actually check something for!
We need an character, and we need to let it move right and left (Jumping and falling come later).
Put this in prgmPLATCHAR:
Code: [Select]
.CHARACTR
[187E243C7E3C5A66]→Pic1CH
Lbl MOV
.MOVe
If getKey(2) and (X≠0)
X-1→X
End
If getKey(3) and(X≠88)
X+1→X
End
Return
Lbl DCH
.Draw CHaracter
Pt-Off(X,Y,Pic1CH)
.You can also use Pt-Mask(), but come on, this is a tutorial!
Return

Now, that’s done, and we want to actually see something, right?
Put this in prgmPLATFRM:
Code: [Select]
.PLATFORM
0→X
55→Y
Repeat getKey(15)
ClrDraw
Sub(MOV)
Sub(DMP)
Sub(DCH)
DispGraph
End
Return
prgmPLATFTLM
prgmPLATCHAR
See how easy those sub-routines are?
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: Juju on May 23, 2011, 01:25:47 pm
Nice. Also congrats on your 1000th post :D
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: aeTIos on May 23, 2011, 02:08:59 pm
Update!
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: BrownyTCat on May 23, 2011, 05:52:24 pm
You said you were going to do this!
... 8XPs please. :D
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: aeTIos on May 24, 2011, 04:36:12 am
8XPs coming when this is finished.
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: DJ Omnimaga on May 25, 2011, 04:40:19 am
Nice. Try to not elaborate too much, though, lol, like writing an entire platformer game altogether. Else some people might just take the entire game code and modify maps/sprites to make their contest entry :P
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: aeTIos on May 25, 2011, 04:41:54 am
I'm not doing that
There won't be any scrolling or enemies. This is just a skeleton for moving and tilemapping (The basics)
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: yunhua98 on May 25, 2011, 02:40:41 pm
what I can't do is hit-detection and physics while scrolling.  :P

any plans to do those?
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: aeTIos on May 25, 2011, 03:18:34 pm
Uh, hit-detection with enemies?
I even dont know how to do enemies myself... :P
Title: Re: [TUTORIAL] Making a platformer engine in Axe
Post by: Yeong on May 25, 2011, 03:41:44 pm
what I can't do is hit-detection and physics while scrolling.  :P

any plans to do those?
I just use the pxl-test with 2 points that I assigned usually... Like this
Code: [Select]
..Bottom Collision
If pxl-test(X+2, Y+16) and ( pxl-test(X+15, Y+16) )    //For 16x16 sprites
.Do something if something's underneath it
End