Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: cooliojazz on July 18, 2009, 10:53:21 pm

Title: Platformer (NOT FOR CONTEST!) Help
Post by: cooliojazz on July 18, 2009, 10:53:21 pm
OK, so I saw the platformer contest.  I was like Yes, I have awesome skills at calculator programming! I will win by far!  Now, here I am, a month later, feeling stupid, realizing, I, so far, cannot do platformers.  The thing is though, I would love to learn.  So, I am going to post my code here and ask for you people to help me see why it is so stupid and inneffective so maybe I can learn to do these... maybe
Code: [Select]
1:real(0:If not(Ans:Then:ClrDraw:Text(-1,0,24,"Requires":Repeat Ans:AüC:BüD:randInt(0,12üA:randInt(1,7üB:Text(-1,8D,6C,"    ":Text(("B0 31" is an invalid token)1,8B,6A,"XLib":getKey:End:Output(1,1,"":Stop:End
RectGC:CoordOff:GridOff:AxesOff:LabelOff:ExprOff:Degree:Func:Normal:Float:Connected:Sequential:Real:Full
[[29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,7,13,13,13,13,13,9,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,6,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,2,2,3,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,8,12,12,12,12,12,10,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]]ü[A]
[[0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0]]ü[B]
real(7,0
0üX:0üY:5üdim(LGUY:1üLGUY(1:1üLGUY(2:2üdim(LMAP:0üLMAP(1:0üLMAP(2:0üLGUY(5
100üT

Real(12,0,80,1,80,62,0:Real(12,0,95,1,95,62,0:Real(12,0,81,0,94,0,0:Real(12,0,81,63,94,63,0
Lbl 1
Real(2,1,0,0,10,8,0,10,0,8,100,0,8,0
Real(2,0,LMAP(2),LMAP(1),10,8,0,10,0,8,100,2,8,1
While 1
If T÷0:Goto FN
T-.2üT
Real(8
AnsüK
dim([A])üLDIM
LGUY(2üLGUY(4:LGUY(1üLGUY(3
If K=3:LGUY(2)+1üLGUY(2
If K=2:LGUY(2)-1üLGUY(2
If LGUY(5)=1:Then:LGUY(1)-2üLGUY(1:2üLGUY(5:End
If K=54 and LGUY(5)=0:Then:LGUY(1)-2üLGUY(1:1üLGUY(5:End
If K=1:LGUY(1)-1üLGUY(1)
If K=55:Goto FN
LGUY(1)+1üLGUY(1)
If LGUY(2)<1:1üLGUY(2)
If LGUY(1)<1:1üLGUY(2)
If [A](LGUY(1),LGUY(2))ø0:Then
If [A](LGUY(1),LGUY(4))=0:Then:LGUY(4üLGUY(2:0üLGUY(5:End
If [A](LGUY(2),LGUY(3))=0:LGUY(3üLGUY(1
End
If LGUY(1)>LMAP(1)+4:LMAP(1)+1üLMAP(1
If LGUY(1)<LMAP(1)+4:LMAP(1)-1üLMAP(1
If LGUY(2)>LMAP(2)+5:LMAP(2)+1üLMAP(2
If LGUY(2)<LMAP(2)+5:LMAP(2)-1üLMAP(2
If LMAP(2)<0:0üLMAP(2
If LMAP(2)>LDIM(2)-10:LDIM(2)-10üLMAP(2
If LMAP(1)<0:0üLMAP(1
If LMAP(1)>LDIM(1)-8:LDIM(1)-8üLMAP(1
If LGUY(2)øLGUY(4) or LGUY(1)øLGUY(3:Then:0ü[A](LGUY(3),LGUY(4)):29ü[A](LGUY(1),LGUY(2:LGUY(1üLGUY(3:LGUY(2üLGUY(4:Goto 1:End
End




Lbl FN
ClrHome:Output(1,1,"":Stop
NOTE: Uses XLIb.  Currently I have (tried) to implement loading a map, moving a guy (back and forth with gravity and jumping), and guy tracking (I do like this part, I think it's awesome.  Maybe that's just me though...)
Oh, and pic 100:(http://survivingm-s.webs.com/Tilemap.bmp)
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: JoeyBelgier on July 18, 2009, 10:56:08 pm
the only thing I can help with is designing stuff
Xlib = Chinese for me

EDIT: Actually, even TI-basic is like ehm, German to me :p
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: Eeems on July 18, 2009, 10:58:03 pm
could I have some comments on the code so I know what you are trying to do with each part?
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: cooliojazz on July 18, 2009, 11:03:02 pm
Sure, ecxept I realized there are some issues,, as in, IT'S MESSED UP!  Oops.  OK, can someone tell me how your'e supposed to write code?  Because copying it from my basic editor didn't work...  Once I fix that I'll comment it.
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: Eeems on July 18, 2009, 11:04:45 pm
use sourcecoder2 (http://www.cemetech.net/projects/item.php?id=11)
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: cooliojazz on July 18, 2009, 11:20:37 pm
Code: [Select]
:1:real(0:If not(Ans:Then:ClrDraw:Text({-}1,0,24,"Requires":Repeat Ans:A→C:B→D:randInt(0,12→A:randInt(1,7→B:Text({-}1,8D,6C,"    ":Text({-}1,8B,6A,"XLib":getKey:End:Output(1,1,"":Stop:End     //XLib Test and Report
:Func:CoordOff:GridOff:AxesOff:LabelOff:ExprOff:Degree:Func:Normal:Float:Connected:Sequential:Real:Full
:[[29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,0,0,0,0,0,7,13,13,13,13,13,9,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,6,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,2,2,3,0,11,0,0,0,0,0,14,0,0,0,0,0,0,0][5,0,0,0,0,0,8,12,12,12,12,12,10,0,0,0,0,0,0,0][5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0][5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]]→[A]     //Map matrix
:[[0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0][0,0,0,0,0,0,0,0,0,0]]→[B]     //Blank map for screen clearing
:real(7,0
:0→X:0→Y:5→dim(∟GUY:1→∟GUY(1:1→∟GUY(2:2→dim(∟MAP:0→∟MAP(1:0→∟MAP(2:0→∟GUY(5     //Initialize variables (∟Guy: 1=new y, 2= new x, 3=old y, 4=old x, 5=jump on/off)
:100→T
:
:real(12,0,80,1,80,62,0:real(12,0,95,1,95,62,0:real(12,0,81,0,94,0,0:real(12,0,81,63,94,63,0     //Draw HUD
:Lbl 1
:real(2,1,0,0,10,8,0,10,0,8,100,0,8,0     //Clear map
:real(2,0,∟MAP(2),∟MAP(1),10,8,0,10,0,8,100,2,8,1     //Draw New map
:While 1
:If T≤0:Goto FN
:T-.2→T     //That T thing is to keep track of time that has passed so far
:real(8
:Ans→K
:dim([A])→∟DIM
:∟GUY(2→∟GUY(4:∟GUY(1→∟GUY(3     //Store new to old so I can check If theyv'e been changed and therefore update the screen
:If K=3:∟GUY(2)+1→∟GUY(2     //checks for keys pressed and acts accordingly (Next 7 Lines)
:If K=2:∟GUY(2)-1→∟GUY(2
:If ∟GUY(5)=1:Then:∟GUY(1)-2→∟GUY(1:2→∟GUY(5:End
:If K=54 and ∟GUY(5)=0:Then:∟GUY(1)-2→∟GUY(1:1→∟GUY(5:End
:If K=1:∟GUY(1)-1→∟GUY(1)
:If K=55:Goto FN
:∟GUY(1)+1→∟GUY(1)     //Gravity
:If ∟GUY(2)<1:1→∟GUY(2)
:If ∟GUY(1)<1:1→∟GUY(2)     //Check for off screen
:If [A](∟GUY(1),∟GUY(2))≠0:Then      //(Block of three lines)  Checks if guy is not in open space
:If [A](∟GUY(1),∟GUY(4))=0:Then:∟GUY(4→∟GUY(2:0→∟GUY(5:End
:If [A](∟GUY(2),∟GUY(3))=0:∟GUY(3→∟GUY(1
:End
:If ∟GUY(1)>∟MAP(1)+4:∟MAP(1)+1→∟MAP(1     //(Next 8 Lines) Moves map with guy, keeping him centered, except when not possible
:If ∟GUY(1)<∟MAP(1)+4:∟MAP(1)-1→∟MAP(1
:If ∟GUY(2)>∟MAP(2)+5:∟MAP(2)+1→∟MAP(2
:If ∟GUY(2)<∟MAP(2)+5:∟MAP(2)-1→∟MAP(2
:If ∟MAP(2)<0:0→∟MAP(2
:If ∟MAP(2)>∟DIM(2)-10:∟DIM(2)-10→∟MAP(2
:If ∟MAP(1)<0:0→∟MAP(1
:If ∟MAP(1)>∟DIM(1)-8:∟DIM(1)-8→∟MAP(1
:If ∟GUY(2)≠∟GUY(4) or ∟GUY(1)≠∟GUY(3:Then:0→[A](∟GUY(3),∟GUY(4)):29→[A](∟GUY(1),∟GUY(2:∟GUY(1→∟GUY(3:∟GUY(2→∟GUY(4:Goto 1:End     //Checks if the guys position is changed, if it is, redraw the map.
:End
:
:
:
:
:Lbl FN
:ClrHome:Output(1,1,"":Stop     //Game finish
Tell me if you need it more commented than that.  Thanks for the tool Eeems :)

EDIT: BTW, the biggest problem is speed
Title: Re: Platformer (NOT FOR CONTEST!) Help
Post by: Eeems on July 18, 2009, 11:23:28 pm
I'll take a look later, thanks for commenting it