Author Topic: [TUTORIAL] Making a platformer engine in Axe  (Read 4511 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
[TUTORIAL] Making a platformer engine in Axe
« 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?
« Last Edit: May 23, 2011, 02:17:47 pm by aeTIos »
I'm not a nerd but I pretend:

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #1 on: May 23, 2011, 01:25:47 pm »
Nice. Also congrats on your 1000th post :D

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #2 on: May 23, 2011, 02:08:59 pm »
Update!
I'm not a nerd but I pretend:

Offline BrownyTCat

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 420
  • Rating: +37/-8
    • View Profile
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #3 on: May 23, 2011, 05:52:24 pm »
You said you were going to do this!
... 8XPs please. :D

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #4 on: May 24, 2011, 04:36:12 am »
8XPs coming when this is finished.
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #5 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
« Last Edit: May 25, 2011, 04:40:31 am by DJ_O »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #6 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)
I'm not a nerd but I pretend:

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #7 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?

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #8 on: May 25, 2011, 03:18:34 pm »
Uh, hit-detection with enemies?
I even dont know how to do enemies myself... :P
I'm not a nerd but I pretend:

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: [TUTORIAL] Making a platformer engine in Axe
« Reply #9 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



Sig wipe!