I made/am making a platformer just for fun- it was working perfectly fine until yesterday when I decided to add some stuff to it. As the title says, it's now running a lot slower (specifically when moving left and right) and I'm not sure why.

Looking at the differences (it's a really large image, so I'll avoid embedding it), there are basically none in the parts where it defines left and right movement- in fact, the only differences I can see are that the game loop is 5 lines longer and the setup for the level is 21 lines longer.

So is the reason it's running slower that the file is larger? Because that would suck (I was planning to add extra levels :/). If that is the case, though, could somebody give me pointers on how I could make it smaller? (File download is at the bottom of this post) and of course if that isn't the cause of it running slower, I'd appreciate if somebody could find my error(s) for me (I've only been coding for about a week haha).

I put the files on Mega in an 8xg file here: https://mega.co.nz/#!yJwGWRBK!6Fcf7oe2EKPzWcbl61PJ90Bqgb--Dsop2kYauJadufE

(hyperlink wasn't working for some reason)
MOVE3.8xp is the last backup I have before it got slow, and MOVE31.8xp is the newer (slow) one.

thanks
May seem obvious, but have you tried testing how long the stuff you added takes?
Hitechcomputergeek wrote:
May seem obvious, but have you tried testing how long the stuff you added takes?


Yeah Razz I've also tried gradually adding stuff to the original faster file- the speed decrease appears to (keyword: appears. it might just be confirmation bias) happen gradually the more I add in, which contributed to the idea that it might be the length of the program that does it.
M. I. Wright wrote:
I made/am making a platformer just for fun- it was working perfectly fine until yesterday when I decided to add some stuff to it. As the title says, it's now running a lot slower (specifically when moving left and right) and I'm not sure why.
Make sure that MathPrint is off, if you're using a TI-84 Plus-model calculator. You can toggle MathPrint and Classic mode in the [MODE] menu.

Quote:
Looking at the differences (it's a really large image, so I'll avoid embedding it), there are basically none in the parts where it defines left and right movement- in fact, the only differences I can see are that the game loop is 5 lines longer and the setup for the level is 21 lines longer.
I see nothing in there that would add significant latency to your game.

Quote:
So is the reason it's running slower that the file is larger? Because that would suck (I was planning to add extra levels :/).
No. Larger TI-BASIC programs are only slower if there are Gotos to Lbls that are far down in the program, because the interpreter scans from the top to the bottom of the program to look for Lbls. As long as you use Repeat/While/For loops for all of your big event loops (as you do), program size doesn't correlate with program speed.
Does anything too big get stored in Ans, maybe?
I have a Snake game that's pretty messed up because it's too slow, and the main cause is because I have to append the new location of the head to a list and remove the last item.

if you didn't just get the food
augment({Y}, seq(LLIST(X),X,1,dim(LLIST)-1))->LLIST
else
augment({Y},LLIST)->LLIST

The collision-with-tail part isn't implemented.
Don't point out suggestions, this is the first game I ever wrote. It's never quite been finished ever, but it's playable. Along the way, I've gone back and revised it. But I still haven't revised /all/ of the code.

EDIT: Eventually, I will get around to dedicating a forum topic to my Snake game.

EDIT 2:
KermMartian wrote:
Make sure that MathPrint is off, if you're using a TI-84 Plus-model calculator. You can toggle MathPrint and Classic mode in the [MODE] menu.

Thanks Kerm, that made a big difference even before it starts getting too slow. (It gets gradually slower and slower as the snake grows.)
I'm sorry to hijack M. I. Wright's topic temporarily, but you should look into my Snake CSE v1.0 game and see how a circular buffer (circular list) works. This is the trick to make a snake game work in O(1) time instead of O(tail_length) time.

Back to the regularly-scheduled topic.
KermMartian wrote:
M. I. Wright wrote:
I made/am making a platformer just for fun- it was working perfectly fine until yesterday when I decided to add some stuff to it. As the title says, it's now running a lot slower (specifically when moving left and right) and I'm not sure why.
Make sure that MathPrint is off, if you're using a TI-84 Plus-model calculator. You can toggle MathPrint and Classic mode in the [MODE] menu.

Didn't think of that- but even with Classic mode on, it still runs slower than it did originally with MathPrint. Weird.

Quote:
Quote:
Looking at the differences (it's a really large image, so I'll avoid embedding it), there are basically none in the parts where it defines left and right movement- in fact, the only differences I can see are that the game loop is 5 lines longer and the setup for the level is 21 lines longer.
I see nothing in there that would add significant latency to your game.

Quote:
So is the reason it's running slower that the file is larger? Because that would suck (I was planning to add extra levels :/).
No. Larger TI-BASIC programs are only slower if there are Gotos to Lbls that are far down in the program, because the interpreter scans from the top to the bottom of the program to look for Lbls. As long as you use Repeat/While/For loops for all of your big event loops (as you do), program size doesn't correlate with program speed.


That's great, thanks for responding!

Hitechcomputergeek wrote:
Does anything too big get stored in Ans, maybe?
I have a Snake game that's pretty messed up because it's too slow, and the main cause is because I have to append the new location of the head to a list and remove the last item.

if you didn't just get the food
augment({Y}, seq(LLIST(X),X,1,dim(LLIST)-1))->LLIST
else
augment({Y},LLIST)->LLIST


Huh, this might actually be it. I'll try to fix it and report back later.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement