Author Topic: Platformer Help!  (Read 4159 times)

0 Members and 1 Guest are viewing this topic.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Platformer Help!
« on: March 31, 2011, 07:23:21 am »
So, I was trying to make a platformer shoot'em up game, but I'm stuck here.
1. This guys should aim up when I press up, but it never happens.
2. How do I make him shoot?(Not 1 bullet at a time)
Here's the code and program:
prgmMSLUG is the executable program.

Code: (Source1) [Select]
:.SPRITELIB
:
:.PROTAGONIST
:.FRONTBUFFER
:.RIGHT1
:[00000F1F1F13110E→Pic1
:[0000804000003F3F1F1F1F1117171B1FC0C0300000000080
:.RIGHT2
:[00000F1F1F13110E0000804000003F3F1F1F1F11254CD271C0C0300000E0C080
:.LEFT1
:[000001020000FCFC0000F0F8F8C8887003030C0000000001F8F8F888E8E8D8F8
:.LEFT2
:[000001020000FCFC0000F0F8F8C8887003030C0000070301F8F8F888A4324B82
:.JUMPRIGHT
:[00000F1F1F13110E0000804000003F3F1F1F1F10E6C9F080C0C030C020987020
:.JUMPLEFT
:[000001020000FCFC0000F0F8F8C8887003030C0304190E04F8F8F80867930F01
:.LOOKUPRIGHT1
:[30303F3F33331D0E00008040000000001F1F1F1117171B1F0000000000000080
:.LOOKUPRIGHT2
:[30303F3F33331D0E00008040000000001F1F1F11254CD271C0C0300000E0C080
:.LOOKUPLEFT1
:[00000102000000000C0CFCFCCCCCB8700000000000000001F8F8F888E8E8D8F8
:.LOOKUPLEFT2
:[00000102000000000C0CFCFCCCCCB87003030C0000070301F8F8F888A4324B82
:
:.BACKBUFFER
:.RIGHT1
:[00000F1F001F1F0E→Pic2
:[0000804000003F3F10101F1F1D1D1B1F3030000000000080
:.RIGHT2
:[00000F1F001F1F0E0000804000003F3F10101F1F3F7FF3713030300000E0C080
:.LEFT1
:[000001020000FCFC0000F0F800F8F8700C0C0C00000000010808F8F8B8B8D8F8
:.LEFT2
:[000001020000FCFC0000F0F800F8F8700C0C0C00000703010808F8F8FCFECF8E
:.RIGHTJUMP
:[00000F1F001F1F0E0000804000003F3F10101F1FFFF9F080303030C0E0F87020
:.LEFTJUMP
:[000001020000FCFC0000F0F800F8F8700C0C0C03071F0E040808F8F8FF9F0F01
:.LOOKUPRIGHT1
:[30303F3F3E3F1302000080400000000011111F1F1D101B1F0000000000000080
:.LOOKUPRIGHT2
:[30303F3F3E3F1302000080400000000010101F1F3F7FF3713030300000E0C080
:.LOOKUPLEFT1
:[00000102000000000C0CFCFC7CFCC84000000000000000018888F8F8B8B8D8F8
:.LOOKUPLEFT2
:[00000102000000000C0CFCFC7CFCC8400C0C0C00000703010808F8F8FCFECF8E
:
:.PROJECTILE
:[0000181818180000→Pic3


Code: (Source2) [Select]
  :.MSLUG
:prgmθA
:
:0→A→X→B→C
:48→Y
:
:Repeat getKey(15)
:
:ClrDraw
:ClrDrawr
:
:sub(DS,X,Y
:
:.WALKING
:If getKey(3)
:X+1→X
:If B
:4→A
:End
:!If B
:!If A
:1→A
:Else
:0→A
:End
:End
:If getKey(4)
:If A≠6
:6→A
:Else
:7→A
:End
:End
:End
:
:If getKey(2)
:X-1→X
:If B
:5→A
:End
:!If B
:If A≠2
:2→A
:Else
:3→A
:End
:End
:If getKey(4)
:If A≠8
:8→A
:Else
:9→A
:End
:End
:End
:
:.JUMP
:If getKey(54) and (B=0
:1→B
:If A≤1
:4→A
:Else
:5→A
:End
:End
:
:If B≠0 and (B≤6
:Y-4→Y
:B+1→B
:End
:If B=7
:Y+1→Y
:C+1→C
:End
:If C=24
:0→B→C
:End
:
:
:DispGraphrr
:End
:
:Lbl DS
:Pt-On(r1,r2,32*A+Pic1
:Pt-On(r1,r2,32*A+Pic2)r
:Pt-On(r1+8,r2,32*A+Pic1+8
:Pt-On(r1+8,r2,32*A+Pic2+8)r
:Pt-On(r1,r2+8,32*A+Pic1+16
:Pt-On(r1,r2+8,32*A+Pic2+16)r
:Pt-On(r1+8,r2+8,32*A+Pic1+24
:Pt-On(r1+8,r2+8,32*A+Pic2+24)r
:Return
« Last Edit: March 31, 2011, 07:24:42 am by yeongJIN_COOL »
Sig wipe!

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Platformer Help!
« Reply #1 on: March 31, 2011, 07:29:13 am »
I believe the problem is that you have "If getkey(4)" twice in there.  What I do for getkey, is store it into Theta or K, after storing 0 into (Let's just Use) K, outside the loop.
So:
Code: [Select]
If K=0 : GetKey->K : End
Then, whenever you check keys, do if K=4 or whatever.  When you are done with the key to check, and the routine needs to flag the key as taken care of, you store 0 into K.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Platformer Help!
« Reply #2 on: March 31, 2011, 07:31:53 am »
So...

Code: [Select]
If K=0 : GetKey->K : End
if K=3 :MOVELEFTROUTINE
if K=2 :MOVERIGHTROUTINE
if K=48: JUMPROUTINE
Like this?
Sig wipe!

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Platformer Help!
« Reply #3 on: March 31, 2011, 07:43:43 am »
That's what I would do.  Because you have to "recognize" the key by setting K to 0 in order to do it again.  This also helps prevent the same key being pressed over and over, and the game lagging behind, while it's just pressing that key too many times or whatever.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Platformer Help!
« Reply #4 on: March 31, 2011, 07:56:14 am »
but it decrease the speed dramatically D:
Sig wipe!

Offline Compynerd255

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +53/-4
  • Betafreak Games
    • View Profile
    • Betafreak Games
Re: Platformer Help!
« Reply #5 on: March 31, 2011, 12:33:34 pm »
Use a modified version of this:

http://ourl.ca/9659

Don't subtract the delay variable when checking the address, and that should result in instantaneous key replies, but only read the key once. The problem with using getKey?K is that you can only read one key at a time. This solution will also add delay so that the character doesn't have automatic machine gun fire.

Also, to shoot more than one bullet at a time, keep your bullets in a table with five variables per bullet:
  • Alive/affiliation (0 for dead bullet, 1 for you, 2 for enemy, this keeps you from shooting yourself)
  • X and Y position
  • X and Y velocity
Then, when you shoot, store the bullet into a dead bullet slot on the table. Then, every frame, update the bullets and draw them.
« Last Edit: March 31, 2011, 12:38:53 pm by Compynerd255 »
The Slime: On Hold, preparing to add dynamic tiles

Axe Eitrix: DONE

Betafreak Games: Fun filled games for XBox and PC. Check it out at http://www.betafreak.com