Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Cram on December 20, 2011, 06:10:13 pm
-
hi im new in axe and i want to know how to jump like in a mario game?
-
Simple jumps, or more realistic jumps?
I already have code I used to help 2 people out with jumps. I'll go fetch it.
-
well im starting so simple jump will be fine :P
-
Ok, since I already got a simple more realistic jump code, here it is anyways:
Jumping isnt really that bad.
[FFFFFFFFFFFFFFFF]->Pic1 ;Pic, but just a cube
56*256->Y ;X and Y are inflated by 256 for accuracy
0->X->V->W->A->B->J
Repeat getKey(15)
If getKey(54)
-256->W ;Set Y velocity to -256 to go up
256->V ;Set X velocity
8->B ;Set a downward acceleration to fall
End
If Y/256>57 ;simple collision with the bottom of screen
56*256->Y ;Reset
0->A->B->V->W
End
V+A->V+X->X ;Find X coordinates
W+B->W+Y->Y ;Find Y
Pt-On(X/256,Y/256,Pic1)
DispGraphClrDraw
End
Where X,Y are coordinates
V,W are velocities
A,B are accelerations
Collisions with realistic jumps get tricky once you get involved with collisions.
For a simple linear jump, keep a variable for jumping, lets say J. Then we'll have an X and Y.
Probably other ways to do it, though.
[FFFFFFFFFFFFFFFF]->Pic1
0->X->J
56->Y
Repeat getKey(15) ;loop here
If getKey(54) ;push 2nd to jump.
!If J ;checks if ready
1->J
End
End
If J<16
J++
X++
Y-- ;go up
ElseIf J<31
J++
X++
Y++ ;go down
Else
0->J
End
Pt-On(X,Y,pic1)
DispGraphClrDraw
End
Simple thing I thought up ^
But no collisions. Just go down as far as you went up in that code :P
-
wow thx i will check this :) but what is the 56*256? :O
-
The variables are multiplied by 256 to be measured in 256ths of a pixel to be precise.
-
nice but you forgot a dispgraph and an end in the last code lol but do you know how to jump and to be able to move left and right with arrow?
-
Lol, oh yeah. Fixed it (and also added ClrDraw).
I had to do it quick since I was short on time :P
getKey(2)?X--
getKey(3)?X++
I think that is a quick way to move.
-
If any of the code doesn't make sense you can talk to Parser Padwan, Epic7, or me....(Parser showed me, and correct me if I'm wrong but didn't I show you epic? or did parser show you to?)
Also more realistic jumping isn't that much harder....collisions are whats hard :) I can write up a quick movement engine (Super simple) if you want:)
-
No, I just figured it out :P
Once, you explained it to me when I already knew it since you misinterpreted my question :P
-
AHH now I remember...lol, now I see, *saintrunner looks closely at epic's code* Yeah Mine is a lot different...I think Shorter too, but yours looks like it's less complex, so Its better for teaching :)
edit YEAH JUMPING!!
-
yes if you have a more simpler code, can you teach me? ;D
-
Here's a pretty simple explanation: http://www.omnimaga.org/index.php?action=articles;sa=view;article=37
Though this tutorial is in TI Basic, it breaks down everything very well and could be (hopefully) understood by a non-programmer as well as a programmer. I suggest giving it a look and seeing if it can help you at all.
-
Lol I don't understand any of that code example because of my weak Ti-basic skills :P
-
wel I do it very similar to epic....but here is it explained
[FFFFFFFFFFFFFFFF]->pic1M //This is our sprite...yes it's a box :)
line(0,0,95,0)
line(0,63,95,63)
line(0,0,0,63)
line(95,0,95,63) //this will draw a border
45->X
55->Y
0->J // setting all variables
repeat getkey(15) //main loop till 'clear' is pressed (getkey(15)=clear button)
if getkey(2) and (X/=0) //If left button is pressed and it is not hitting the left side (I'll show you later how to do simple collision) (/= means does not equal)
X-1->X //move sprite over one pxl to the left
End
if getkey(3) and (X/=87) //if right is pressed
X+1->X //move to right
End
if getkey(4) and pxl-test(X,Y+8) //if he is on the ground and up is pushed
15->J //change this for your jump height
End
if (J>0)
J-1->J
Y-1->Y //decreace J and decrease Y (bring him up...notice subtracting from Y makes him go up!)
End
if (pxl-test(X,Y+8)=0) and (J=0) //if nothing is below him and J is 0
0->J //just in case you land on a platform
Y+1->Y //bring you back down
End
Pause 25 //so it's not too fast
pt-change(X,Y,pic1M)
Disgraph
pt-change(X,Y,pic1M)
End
That should be it....any questions, and you know where to find me :)
-
wow thx a lot i understand how to jump now! :D and i found a little glitch lol one of your line is (0,0,0,64) so if getkey(2) and (X/=0) should be if getkey(2) and (X/=1) :P
-
oh yeah (its called a bug) and I just wrote that wrong....I usually write that part as a collision (more difficult)
-
ah ok and that is my next question, how can i put more collision? :O
-
Collision with what type of gravity, and collisions on all sides?
-
easiest way is to do it is with pxl-test. just throw in arguments like
if getkey(2) and pxl-test(X,Y+8)=0 //if left is pushed and the pxl at the bottom left hand corner is off (remember X and Y set at zero is the top left hand corner)
-
I could give grappler's current subroutines. They use pxl-test (which I need to change) but a more complicated way, which I could simplify for simple gravity and post here.
-
I think he gets the gravity, it's just replacing the left and right hitting of objects.....but go ahead :) (I'm actually interested in seeing how your doing it, cause you generally optimize better then me)
-
For pxl-testing?
-
sorry I misread you post, go ahead, I think that might help :)
-
I was going to show my collisions for more realistic gravity, but mine aren't perfectly functioning so.... :P
-
Mine are slightly skewed as well, But I'm working on it...as for simple collision and gravity, pxl-test will work for now :)
-
I need to use virtual pxltesting.
-
heres a source code for a simple movement/platformer engine I made a while back :) I hope it helps a little
:.JUMP
:[1C141C080C081C22]→Pic0MR
:[3828381030103844]→Pic0ML
:1→D
:0→J
:40→X
:55→Y
:Lbl 1
:Line(0,63,95,63)
:Line(0,0,0,63)
:Line(95,0,95,63)
:Line(0,0,95,0)
:Line(0,50,25,50)
:Line(25,50,25,63)
:Line(70,50,95,50)
:Line(70,50,70,63)
:
:Repeat getKey(15)
:If getKey(2) and (pxl-Test(X,Y+7)≠1)
:X-1→X
:2→D
:End
:If getKey(3) and (pxl-Test(X+7,Y+7)≠1)
:X+1→X
:1→D
:End
:If getKey(4) and (pxl-Test(X+1,Y+8) or pxl-Test(X+8,Y+8) and (S≠1))
:15→J
:End
:If (J>0)
:Y-1→Y
:J-1→J
:End
:If (pxl-Test(X+8,Y+8) or pxl-Test(X+1,Y+8)=0) and (J=0)
:Y+1→Y
:End
:If (D=1)
:Pt-Change(X,Y,Pic0MR)
:Pause 20
:End
:If (D=2)
:Pt-Change(X,Y,Pic0ML)
:Pause 20
:End
:DispGraph
:If (D=1)
:Pt-Change(X,Y,Pic0MR)
:End
:If (D=2)
:Pt-Change(X,Y,Pic0ML)
:End
:End
btw, the D variable is for the direction of the sprite (look at my screenie a couple posts above) you don't need this unless you want your sprite to look like he is looking different directions
-
Allow me to optimize/shorten a bit :P
:.JUMP
:[1C141C080C081C22]→Pic0MR
:[3828381030103844]
:1→D-1->J
:40→X
:55→Y
:Lbl 1
:Line(0,63,95,63)
:Line(0,,,63)
:Line(95,0,95,63)
:Line(0,,95,0)
:Line(0,50,25,50)
:Line(25,50,25,63)
:Line(70,50,95,50)
:Line(70,50,70,63)
:Repeat getKey(15)
:If getKey(2) and (pxl-Test(X,Y+7)≠1)
:X--
:2→D
:End
:If getKey(3) and (pxl-Test(X+7,Y+7)≠1)
:X++
:1→D
:End
:If getKey(4) and (pxl-Test(X+1,Y+8) or pxl-Test(X+8,Y+8) and (S≠1))
:15→J
:End
:If J>0
:Y--
:J--
:End
:If (pxl-Test(X+8,Y+8) or pxl-Test(X+1,Y+8)=0) and (J=0)
:Y++
:End
:For(Z,0,1)
:Pt-Change(X,Y,D*8+Pic0MR
:!If Z
:DispGraph
:Pause 20
:End
:End
:End
-
The reason I didn't optimize it was because this is so he can learn how to do it, I know how to do all that.....but thanks...?
-
Oh, ok. I dont really know too much about optimizing anyways :P
(That would be epic if squidjetx made a second guide :P)
But he should use the D*8+Pic0 thingy, thats always good to use.
-
sure :) (you should probably explain that though)
(lol he's not even online so he will have some tutorial when he does get on !)
-
Each monochrome sprite is 8 bytes, so by adding 8 to an initial pointer sprite you end up with the sprite immediately after that initial one.
In your code, if D is 0, it'll draw Pic0. If D is 1, it'll draw Pic0+8, which is the sprite data directly after the first 8 bytes of Pic0. And so on.
This is pretty useful, so you don't have to make cases, because casework is always bad.
-
thank everyone for your help i understand better now! ;D but i added a monster to kill me and i tryed this code but it dosnt work :(
[...]
sub(DIE)
if D
return
end
[...]
Lbl DIE
if pxl-test(u-1,v)=1
1->D
return
when i go close to my monster, he just continu to move across me and nothing happen.. what sould i do or what is the problem? :O
-
are you moving from the right? your are pxl-testing the top left hand corner (one spot to the left) so is your sprite tall enough to hit that? or are you smaller then the monster? try pxl-test(U-1,V+7)
edit: this should work (and take up less space)
if pxl-test(U-1,V+7)=1
return
end
I don't think you need a subroutine
-
are you moving from the right? your are pxl-testing the top left hand corner (one spot to the left) so is your sprite tall enough to hit that? or are you smaller then the monster? try pxl-test(U-1,V+7)
the monster walk left and go across me after that he go right and walk across me again even if i change v by v+7 :S
-
can I see a screenie?
and did you try my code, minus a subroutine ^^
-
can I see a screenie?
and did you try my code, minus a subroutine ^^
yes i tryed it but dont work lol and how can i do a screenie?
-
you need wabbit emu....but lets fix this problem first, then I'll teach you that, Ok so can you post your full code? or is that too long?
-
ok but i will skip useless thing like graphism :P
-
I just need to see movement and displays
-
Also welcome on the forums by the way :D
It will be a good idea to post the code so people can see what you are doing wrong. I personally cannot help, though, since I have barely coded in Axe. Also I suggest to not start straight away with a Mario clone, since it would be a ridiculous amount of work as first ever calc project. A platformer game with less features is fine, though. :)
-
lol my first one was a mario clone...with a shotgun....lol Mario is such a common clone...A GOOD ONE though is a lot harder
-
0→r→d→z→j+43→y+27→x
0→w+27→u
15→v
repeat getkey(15)
if pxl-test(u-1,v+7)=1
return
end
sub(MMO)
if getkey(2) and (pxl-test(x,y+7)≠1)
x-1→x
if z=0
2→z
elseif z=2
0→z
end
elseif getkey(3) and (pxl-test(x+7,v+7)≠1)
x+1→x
if z=0
2→z
elseif z=2
0→z
end
end
if getkey(1) and pxl-test(x+5,y+8)
3→z
elseif getkey(4)
0→z
end
if getkey(54) and (pxl-test(x+2,y+8) or pxl-test(x+6,y+8)
15→j
1→z
end
if(j>0)
j-1→j
y-1→y
end
if(pxl-test(x+6,y+8) or pxl-test(x+2,y+8)=o and (j=0)
0→j
0→z
y+1→y
end
if y=49
return
end
pause 25
pt-change (x,y,z*8+pic0p1
dispgraph
pt-change (x,y,z*8+pic0p1
end
lbl mmo
pt-change(u,v,r*8+pic0M1
if u≥27 and w=0
u+1→u
elseif u≤62 and w=1
u-1→u
end
if u=27
0→w
elseif u=62
1→w
end
pt-change(u,v,r*8+pic-M1
return
i think everything is here
-
Oh I meant making a Super Mario Bros 1/2/3/World clone, literally. Some people get their calc and start straight with a full Mario port, then realize the project is beyond their programming experience then quit.
-
this is not really a mario clone only a platformer game :P
-
put your monster pxl test in he subroutine, in between the two point changes.....and I suggest moving the secon monster point change outside of the routine and after the displaygraph...do that and tell me what happens....ALSO BACK UP YOUR WORK!!!
did it work?
-
nah.. lol i dont know if i did the right thing but nothing is working now xD
can you show me what you mean in my code plz?
-
hmmm, This should'nt be that difficult....go back to what you had, and just move the pxltest monster thing around... I think you are just telling it to check for an ON pxl when it is also changing spots...so it doesn't read it
I meant
0→r→d→z→j+43→y+27→x
0→w+27→u
15→v
repeat getkey(15)
sub(MMO)
if pxl-test(u-1,v+7)=1
return
end
if getkey(2) and (pxl-test(x,y+7)≠1)
x-1→x
if z=0
2→z
elseif z=2
0→z
end
elseif getkey(3) and (pxl-test(x+7,v+7)≠1)
x+1→x
if z=0
2→z
elseif z=2
0→z
end
end
if getkey(1) and pxl-test(x+5,y+8)
3→z
elseif getkey(4)
0→z
end
if getkey(54) and (pxl-test(x+2,y+8) or pxl-test(x+6,y+8)
15→j
1→z
end
if(j>0)
j-1→j
y-1→y
end
if(pxl-test(x+6,y+8) or pxl-test(x+2,y+8)=o and (j=0)
0→j
0→z
y+1→y
end
if y=49
return
end
pause 25
pt-change (x,y,z*8+pic0p1
dispgraph
pt-change (x,y,z*8+pic0p1
pt-change(u,v,r*8+pic-M1
end
lbl mmo
pt-change(u,v,r*8+pic0M1
if u≥27 and w=0
u+1→u
elseif u≤62 and w=1
u-1→u
end
if u=27
0→w
elseif u=62
1→w
end
return
edit: and if that doesn't work I got one more idea....lol, you'll learn very quickly that a lot of coding is trial and error :P
-
yes that what i did but i had to put the first pt-change in the end of mmo just before return but it still not work.. :(
-
try pxl-testing U and V right before the display graph...cuz your trying to see if it is hitting your character...but you need your character to move before it can test that
-
yeah that it exactly what i just did and he work now ;D thx for all your time! :)
-
:) sure thing! lol and remember to always back up your work! For my seeker game ( check it out if you don't know it, It's a pretty good platformer..not done yet though) I've hit even worse bugs, and have had over 30 ram clears!! lol trial and error my friend, trial and error :)
-
ahah yeah we learn from error :P
-
unless your a perfect coding guru, who never errors.....I wish I was one lol!
edit: to be honest, I should have know it was needed by the displaygraph! lol, thats like common sense! I think it was the subroutine throwing me off :P
-
probably xD well i think i will never do this error again :banghead:
-
Good! Also (as I hinted above *cough cough*) you can always check out my Seeker thread to see how that platformer is going :) When I first made platformers,I got Ideas from other ones, :) PLUS I need more people to test it! which I posted a demo if you have free time! also do you want me to tell you about wabbit emu now?
-
im going to sleep now but you can tell me and tomorrow i will look it + test your game :)
-
Also since you are into Axe, an advice I must tell you early before you get too far into a project then get a surprise is backing up your progress often. Sometimes in Axe if you do an error, you will get a RAM clear or archive corruption, losing all your work. It's always good to copy your progress on an hard drive and a flash drive from time to time.
Good luck!
-
SEE even DJ does it :) lol and now to wabbit Emu.....basically it is an emulater for your calc, you can download it for windows or mac at http://wabbit.codeplex.com/releases/view/44625 and then follow the install instructions. I'll tell you now you are going to need to get Rom images from your calc which is explained how to in the install window, But have our calc at hand! and if you don't have TI connect...get it (I assume you do) although it is usually stupid and doesn't always transfer files.
Why do I need these?:
with TI Connect, you will be able to transfer files to and from your calc AND THEN
You can simply drag them to an open Emu window to test/get screenie/mess with, with out worrys of stupid RAM clears!....well you still get them but, it matters less.
Screenies:
when you have all this installed and a Emu window open, you can now enter the wonderful world of SCREENIES!! very helpful in shwing off your work and getting help with bugs
Just press backspace.....you'll see a blue thing around the screen, which means it is recording, and the press backspace again to stop. this will safe the screen shot as a .gif file in what ever location you specified during install (I think...you'll figure that out it's easy,just mess around with it a little)
The you can upload screenies here, by clicking Reply, then choose file for attachments, and finally finding your file. EASY!
I also recommend downloading noshell for your Emu because, then you don't have to worry about most of the shells. just download and install from apps (noshell is also good on calc, in my opinion)
find that at http://www.ticalc.org/archives/files/fileinfo/400/40005.html
well thats a simple over view, if you have any questions, you always have me, omni, or youtube :) good luck!
-
You should also make sure to set the recording FPS to 60 in the options menu. It makes for smoother screenshots.
-
thx but can you tell me more about ROM image? how it work?
-
I'm not an expert in that area, but if you follow the install instructions, its all cool. I think, Its just copy of run info from your calc. in the install it will tell you to tell what type of calc you have, then it has you download a file onto your calc and run it. this will create two more files on your calc. you then transfer those two files to the computer and put them in the install window (It tells you how to do that) then click finish....should be all good...check this out for a better explaination
http://youtu.be/fmvp7WY7AeI
-
ok thank for all! :) i will check all that tonight because im going to work now and if i have a problem, i will ask you :D
-
sure thing, your welcome