   TI-83 Plus - "Hero"
  Edit: Problem resolved. See bottom posts.  I don't expect there to be many people on this forum who program a TI-83 calculator, but in case there is anyone, please help me with my code.  First, I'll tell you what code I have.In my code below I represent two symbols as follows:STO symbol: ->does not equal: /=Also, if I mess up the code tags, can someone tell me how they are done?:0->Q:1->E:1->F:0->U:0->V:ClrHome::Disp "USE THE ARROW","BUTTONS TO","NAVIGATE.","","PRESS ANY BUTTON","TO CONTINUE.":Pause::While Q/=1:ClrHome::For(V,1,8):For(U,1,16):If U=E and V=F:Then:Output(V,U,"O"):Else:Output(V,U,"."):End:End:End::If E=16 and F=8:Goto ND:If getKey=24:E-1->E:If getKey=25:F-1->F:If getKey=26:E+1->E:If getKey=34:F+1->F:End::Lbl ND:ClrHome:Disp "YOU WIN!":DelVar V:DelVar U:DelVar F:DelVar E:DelVar Q:Stop  I realize that this code isn't terribly efficient, especially at refreshing, which takes ages, but that isn't my concern right now. I'm trying, first of all, to figure out what I did wrong on the movement. If anyone can direct me on how to make the code more efficient, that would help as well. For example, I tried building up a string in the for-loop nested within the for-loop, but it gave an invalid dimension error. This is how I did it, by the way::"O"+Str1->Str1  Thanks in advance for anyone with any answers. If you need me to clarify my problem, just let me know.[Edited by - Tallun on April 21, 2006 4:17:31 PM]
  Well I'm not sure what the problem with the movement is even (and I don't know where my calculator is to test it :\) but for the efficiency bit, instead of redrawing the entire screen each time through the loop, how about filling it with .'s before the main loop then inside the loop all you need to do is replace the old position, which would be an 'O', with a '.' and replace the new position (which would be a '.' with an 'O'. Writing 2 chars each loop should give a decent increase over writing 8*16 chars.Hopefully that made sense... but it also wouldn't be the first time I've been accused of not making sense. Also note that it's been quite some time since I've done any programming on my calc ;];  What specific problems are you having? As for efficiency, one thing you could do is use lists rather than individual variables, for that you would first create a list (in this case named "Name") in memory, then to use it:14->dim(lName)essentially a list "lName" of length 14, to access the list you would write:lName(n)where 'n' is the index. This allows you to use more than 26 variables at any given time, which is especially good since all variables in TI-83 Basic are global (last I checked)Keep in mind that TI-83 Basic was never meant to be particularly fast, for that you'll need a link cable and some of the TI tutorials on Z-80 assembly. They also have TI-83 emulators so you can test it on your computer without bricking your $100 calculator.   ;  I LOVE programming for TI-83's [smile]Your problem is that you have no loop to wait for user input; you just move on to the next frame.  This code fixes that problem.:0->Q:1->E:1->F:0->U:0->V:ClrHome::Disp "USE THE ARROW","BUTTONS TO","NAVIGATE.","","PRESS ANY BUTTON","TO CONTINUE.":Pause::While Q/=1:ClrHome::For(V,1,8):For(U,1,16):If U=E and V=F:Then:Output(V,U,"O"):Else:Output(V,U,"."):End:End:End::If E=16 and F=8:Goto ND/* This part changed */:Repeat X:getKey->X:End:If X=24:E-1->E:If X=25:F-1->F:If X=26:E+1->E:If X=34:F+1->F/* End change */:End:Lbl ND:ClrHome:Disp "YOU WIN!":DelVar V:DelVar U:DelVar F:DelVar E:DelVar Q:StopWhat this basically does is repeat until the user gives X a value by hitting a key.  Then it compares X to each arrow value.As for the very slow updates, you will have to change your code so that it only calls Output for 2 cells: the one Where the player goes and the one where he came from (to replace the old 'O' with a '.')  This will take some logic, but should be doable.Hope that helps!   ;  @All: Will try. I was kinda thinking about the replacement thing before but I wasn't entirely sure how to do it.I'll post my results in a moment.Edit: Okay, I did Simian Man's improvement. Much better. Now to the rest...Edit 2: Is it possible to erase a character in a specified position?   ;  Good ole' TI-83 calcs. :)  Programmed my first game on an 83, which was a very primitive version of number munchers (took forever). After that I did simpler games, such as blackjack, hi-low, several variations of those games where you have to memorize a sequence of lights and repeat it (although, I used numbers and characters instead), and once I even made a mini text-based RPG with combat and the works. Then I realized it was way better to do that sort of stuff in C++. :)Anyway, as px said, you can cut down your drawing by pre-drawing the scene and then only updating the spaces where movement has occured. With TI-83's, never, ever try to redraw the entire scene each frame; 83's are way too slow at processing and you'll never get any decent graphics results trying to refresh so often. Just draw the field ahead of time before the While statement, and then all your while statement should be is checking for user input and then updating the spaces needed (also remember to take ClrHome out of the While loop). And draw only when there is user input; don't draw every frame.Another suggestion: for your getkey, store it as a variable (such as theta). I'd do that because getkey grabs the current key the user is pressing, which could actually change between the if statements; storing the getkey as a variable keeps the same input throughout the rest of that iteration of the loop. I'd also turn the direction checks (left, right, up, down) into an if-else branch.Hope that helps.   ;Quote:Original post by TallunEdit 2: Is it possible to erase a character in a specified position?Yes. Just use Output() as you have been, only do something like Output(x, y, " ") with an empty character (i.e. a space).   ;  @Omega147: Yes, Simian Man posted code doing that already, but thanks anyway.Edit: Right, too slow, never mind this portion.Thanks again everyone.Edit 2: That'd be it Omega147, thanks.   ;Quote:Original post by Tallun@Omega147: Yes, Simian Man posted code doing that already, but thanks anyway.Actually, Simian's code is still redrawing at every pass through the loop...Edit: Or, if you're referring to the key input thing, the Repeat is one way to do it, but if you want to check for other things within the loop (such as if you have a timer going) then I wouldn't take that route.   ;  I once wrote a football game for the TI-83 that was so large I had to stop working on it because it was too big to fit on the calculator's memory.  I had deleted everything else and it was still too big.Using a real language is so much easier, but with the TI, you always have bored math students to test your games on [smile].I read about a C compiler for the Z80 a while ago.  I might have to look into that.   