Omnimaga
Calculator Community => TI Calculators => General Calculator Help => Topic started by: Gale on March 13, 2010, 11:18:36 am
-
Heyyy guys! I'm new to the forum :P Anywayy, i'm not sure if we're supposed to do BASIC code in a special box when posting like on other forums, but here i goooo.
I'm making a horse racing game for my calculator, which involves selecting one of five horses (i had a friend do cool graphics for each one :3), and placing a bet on a horse . I've made the racing animation work, yet it takes up tonsss of memory, because it wanted to have the winning horse in front of the others in each animation. So, being the TI-noob that i am, i made a seperate race code for each horses' victory. Is there anyway I can shrink it down to code for just one race? Here it is:
:ClrHome
:ClrDraw
:randInt(1,5)->R
:If R=1:Then
:ClrHome
:For(X,2,16) //it's starting at 2 so the other horses can be "behind" the lead horse
:Output(2,X,"o //row #2 is first lane so the race is more in the center of the screen
:Output(3,X-1,"o
:Output(4,X-1,"o
:Output(5,X-1,"o
:Output(6,X-1,"o
:For(Y,1,150)
:End
:Output(2,X," "
:Output(3,X-1," "
:Output(4,X-1," "
:Output(5,X-1," "
:Output(6,X-1," "
:End
:Goto AE //the victory scene is on lbl AE
:End
Now this code would be repeated for all 5 potential R values (each horse). Is there any way I can avoid repeating this code, but still have one horse winning? (In this case, the horse in lane 1 won)
-
Welcome here! ;D
I think it would be easiest to help you if you put the complete winning animation code up here. You can put it in the little code box by typing [code ] and then [/code ] (without the spaces in there) at the end. :)
Good luck! I'll (and everyone else) try to help you once I can tell what the other horses do. :D
Edit: Here's a fix:
:randInt(1,5)->R
:ClrHome
:For(X,1,15) //it's starting at 1 so the other horses can be "behind" the lead horse, but you don't have to change their values.
:Output(2,X+(R=1),"o //row #2 is first lane so the race is more in the center of the screen
:Output(3,X+(R=2),"o
:Output(4,X+(R=3),"o
:Output(5,X+(R=4),"o
:Output(6,X+(R=5),"o
:For(Y,1,150)
:End
:Output(2,X+(R=1)," "
:Output(3,X+(R=2)," "
:Output(4,X+(R=3)," "
:Output(5,X+(R=4)," "
:Output(6,X+(R=5)," "
:End
:Goto AE //I'm not sure here, but it's here because it's in your code. :)
-
I'll have to test it out later because i'm going bowling now, but the syntax makes sense!!
thank you!!!
oh, is there a way to convert pictures to code efficiently? i got a pic-to-program converter on the TI website, but it's terrible with memory because it turns on each individual pxl, and an error always pops up halfway through converting.
because i dont want to have to upload each individual pic along with the main program when sending it to other people.
-
It's probably best to make them Pics because it will be fastest this way. I don't mind that much, and if you think multiple files are bad, they aren't, so you can use pics if you want. :D
Oh, and there is not an easily used pic converter program out there, plus if you try to convert a pic it will get much larger and it will be a lot slower. If you still want to not use Pics, then I'd try Vertical Text Sprites: http://ourl.ca/4059
Good luck!
-
i've heard of text sprites before, but they looked too confusing for me. i'll give them a try ;D
thank you!
-
Wouldn't the use of text sprites (horizontal or vertical) depend on the size of the animation?
-
i'm not sure if we're supposed to do BASIC code in a special box when posting like on other forums
It is recommended, since it's easier to read, but it's not necessary. Just always make sure to disable smileys if you don't use these boxes because some of your code will turn into emoticons.
Welcome here btw :)
-
thank you :D
and i still don't understand text sprites. so they're used to make "blocks" of pixels appear on the graph screen?
-
I still don't get vertical text sprites myself x.x
Sadly, though, these ones are no longer really efficient, though, with OS 2.53 and Nspire OS 2.0, because they won't show properly on these OS.
-
ohh. yeah, i accidentally downgraded my OS on my TI-84+ to a 2.22 from a 2.53 last night xD
-
Mhmm, I would recommend maybe getting the latest possible that is under 2.53MP if you can find one, though, in case older ones may have bugs. The latest is 2.43, if I remember. Again, though, it's not a big hurry if you regulary perform backups.
-
Nice. ;D
I'd recommend 2.43 unless you use your calc only for math, when I'd recommend 2.53MP. :D
-
i dont want to have to upload each individual pic along with the main program when sending it to other people.
Working with pic's will be the fastest tho in pure basic. The solution for not having to send individual files equalz Grouping them after all code is done/all art is made.
BTW, welcome here (:
-
Sometimes to have complex games you have no choice but have people sacrify memory and possibly have the install process more complicated, because otherwise your games might just be too simple. You will probably have to group the pics with the program so they can be sent easier
-
I already said that, like, one post ago q:
EDIT; No wait, now it's 2 posts ago
and yay, this is my 444th, finally
EDIT2: It's prolly just me, but I don't see the offensive side off this. Then again, at least 2 others did..
So I'm off again.. <_< Ciao
-
hey, if I agree with your post I can repeat again, right? Plus I was going in more details regarding game size/memory
-
thanks guys! and yeah, i decided that i will just use normal pics xD
the one thing i hate is just how you can only have up to 10 stored pics.. it gets annoying when i want to have several complex programs on my calc that involve a lot of pics.
now i'm working on the "horse's market", where you can buy your horse food and gear to make it more likely to win P:
-
With Xtravar on ticalc.org, you can actually have 255, but keep in mind these are very hard to send from PC to calc. First, to be sent to the PC, they need to be ungrouped. Then, when sent to the calc, they must not be ungrouped during transfer. Only after you finished then go in 2nd+MEM->Group->Ungroup. However, the problem is that on certain computer hardwares, the "Send to TI Device" option will not show up when right-clicking calc programs on the computer and sadly, this one sending method is the only way to send such pics to the calc, as all other methods ungroups the files then give "invalid filename" errors when sending.
-
hey, if I agree with your post I can repeat again, right? Plus I was going in more details regarding game size/memory
Sure, I just thought you read over it :X
-
Xtravar just made my day. thank you! :D
does everybody who will be using the programs involving pics(11-255) need to have xtravar?
-
hey, if I agree with your post I can repeat again, right? Plus I was going in more details regarding game size/memory
Sure, I just thought you read over it :X
nah I didn't. Keep in mind that even if I did, though, we have to be careful to how we word stuff sometimes, though, because if said to some people, the people might feel like you are humiliating them in public then feel like not posting again.
Back on Xtravar:
Xtravar just made my day. thank you! :D
does everybody who will be using the programs involving pics(11-255) need to have xtravar?
nope, you don't need to keep Xtravar on the calc to use the pics. These pics can even be used with xLIB and recallpic command. Just keep a copy of xtravar around during coding then when people download your game, they don't need it.
Also keep up the good work on the racing game. Feel free to ask more help if you need some
-
I recommend Picarc personally, it lets you store your map files in a subprogram and thus makes it easy to transfer and use large amounts of pics, it can also be renamed of course so it sits nice and neat at the bottom of the program list, just be sure to credit Iambian if you use it :D
-
Oh right I always forget about that one x.x, I assume pics are stored in archive while you use some other program to recall them, right? Seeing "arc" in the name that's what I guessed but I was not entirely sure...
-
while using xLIB a LOT today, i found that you can recall pics and store/create 255 pics with xLIB, which includes archived pics.
what do you mean "subprograms" with picarc?
ehh, i have another question. is there any way i can make randInt based off of probability? because i want to create the "horse shop" where you can buy things to increase the probability of a specific horse winning.
-
yeah you can, just use variables to define the range and just change the variables to change the range for your probability.
-
ahh. never thought of that! thank you
-
Np, always glad to help :)
-
okay, now i'm using variables to change the probability, but i'm 90% sure that my method is terribly unefficient. i'm just using a:
:If S>1 and S<20:Then
: blah blah blah
type of thing, (with more If statements added of course), with the variables just at randInt(1,100) right now. is there a better way? i want it so when somebody buys something, it will increase the probability for one horse and decreasing the probability for the other horses.
-
I would probably set the variables and do randInt(1,S) instead
-
I'd do it that way too. :D
I was inspired by this, so I made a horse racing game:
ClrHome
{25,25,25,25,25->L1
{1,1,1,1,1->L2
While 17>int(max(L2
For(A,1,5
max(10,min(100,L1(A)+randInt(-5,5->L1(A
End
L2+.01L1->L2
For(A,1,5)
int(L2(A
Output(A,1," //16 spaces
If Ans<17
Output(A,Ans,"*
End
End
Output(6,14,max((max(L2)=L2)cumSum(binomcdf(4,0
DelVar L1DelVar L2Output(6,1,"WINNER:HORSE
If you want to, you can take any code from it. That goes for anyone! ;D
Oh, and if anyone wants it explained, I'll gladly explain it! ;)
-
@ eeems
thanks! i'll give it a try!
@ztrumpet
haha nice!!! i'll try it out later! can't wait :P
-
while using xLIB a LOT today, i found that you can recall pics and store/create 255 pics with xLIB, which includes archived pics.
what do you mean "subprograms" with picarc?
ehh, i have another question. is there any way i can make randInt based off of probability? because i want to create the "horse shop" where you can buy things to increase the probability of a specific horse winning.
by subprograms i mean having other .8xp files besides the main one, the other programs can be called within the main program with the prgm token, or something along that line (i have not touched any ti-basic code in a while)
and yes, the subprogram storing the pictures is both optimised and archive-able with picarc
with picarc you could have your programs be like:
HORSE
ZHORSE1
*ZHORSE2
(notice the last one is archived and the subprograms have Z infront so they will appear at the very bottom of your program list)
where HORSE is the main program, ZHORSE1 is the picarc program, and ZHORSE2 is the program holding all of your pic files
the documentation that comes with picarc explains how to use it :)
also keep in mind that if you do rename picarc you will have to replace any commands given by the documentation that have PICARC in them with whatever you named it
-
You can do probablity like this...
RandInt(1,10)
(Ans<3)+2(Ans>2 and Ans<5)+3(Ans>4)->P
This gives 1 a 1\5 chance, 2 a 1\5 chance, and 3\5 chance
-
RandInt(1,10)
(Ans<3)+2(Ans>2 and Ans<5)+3(Ans>4)->P
Also the stuff in red can be removed :)
-
I put the end parethases?... Wow, that's odd... I don't even put them in equations during math class...
Also the above post should be that 3 has 3/5 of a chance :P
-
nice! thanks jazz! and ztrumpet, for some reason the program you posted isn't working. for me, at least.
-
What does it do? Does it error? Does it just stop? What happens?
I'm pretty sure I didn't mistype it when I put it up here, so I don't know what the problem is. =\
-
nevermind, I actually mistyped when i entered it in my calc. but, after the race it displays "WINNER:HORSE {1,2,3,4,5}", rather than just one number. but it's great! how did you get the horses to move at random times?
-
Output(6,14,max((max(L2)=L2)cumSum(binomcdf(4,0
Ah, I'm glad it works! ;D This line is the one you need to look at if it says {1,2,3,4,5}. :)
The horses all have a speed. Here's some pseudo code to explain it:
Initialize: Speeds start at 25 and columns all start at one.
Main Loop: Loops until one of the horses goes off the screen.
{
Randomly Change the Speed of each horse, between -5 and 5 of their previous speed. (Max speed:100 Min speed:10)
Add .01 of the Speed to the Column. In other words, if the speed is 25 every time, then the horse will move one column each 4 "turns".
Show the horse's position.
}
Figure out what element in the list is the largest, and display which horse is the winner.
The horses all move at random times, and because of this they appear to move randomly. :)
I'm glad you liked it! :D
-
there we go! i fixed it, and now it displays the right horse. thanks! is there a reason you put the final Output( command in the same line as the DelVar commands?
-
Yes, as DelVar is the only command that (because of glitch on Ti's part in all the OSes) doesn't need a newline or : after it. I used this to save two bytes at the end. ;D
-
ohh :D since i mostly run archived programs now, and have TONS of archive memory, i always just throw optimization out the window unless i'm making a program for somebody else xD
-
personally i like to leave random unoptimized math programs on peoples calculators, unarchived, unhidden, and unlocked. the reason i do this is because that way they can look at the source and maybe potentially get interested in programming :)
I always try to optimize games tho.
-
yeah, i try to get all my friends into programming. only one friend is moderately interested, but he's so busy he says he doesn't have the time. =/ so sad. but there's this guy in my school who i'm not really friends with who made a HUGE one player tanks game in all BASIC with sprites. i wish i knew him enough to talk to him xD