Omnimaga
Calculator Community => TI Calculators => General Calculator Help => Topic started by: saintrunner on February 21, 2012, 09:41:10 pm
-
As Casio calcs are becoming more and more popular here at Omni, I took it upon myself to figure out a very simple movement code so all us new Casio users can begin our long but enjoyable journey on more Casio games! If you are accustom to TI-BASIC you could probably figure all this out as only a few things are different. Also I would like to state that if you plan to use tiles with this code (I'll probably make a tutorial on that later) you might need to tweak a few things like the location of cleartext's.
28=up, 27=right, 38=left, 37=down
Now to the nitty gritty :) The best way for me to do this is to comment the code and explain areas of importance:
ClrGraph:ClrText ->this will just make sure there is nothing on the screen
1->X:2->Y -> sets your variables for your beginning location
While 1 ->begins loop
Getkey->G ->sets all keypresses to G in a sense
Locate X,Y,"@" -> commonly 'output(' in TI-Basic this will draw your symbol as point X,Y, or 1,1
If (G=27 And X=/21) ->checks if getkey 27 (or right) is pressed and X does not 21 (the far right side of the screen)
Then X+1->X ->add one to X, or in other words move to the right
Clrtext ->gets rid of previously drawn character so you don't end up with a line of characters :P
IfEnd -> ends the If statement
If (G=38 And X=/1) ->if left key is pressed and not all the way to the left
Then X-1->X
Clrtext
IfEnd
If (G=37 And Y=/7) ->the next lines of code will be basically the same thing, but in accordance to up and down or Y
Then Y+1->Y
ClrText
IfEnd
If (G=28 And Y=/1)
Then Y-1->Y
ClrText
IfEnd
If G=47 ->if exit is pressed
Stop -> .....well STOP! lol
IfEnd
WhileEnd -> end the whole while loop
that's about it :) post comments and questions, but most of this should make sense!
Enjoy!
-
can't you pull down ClrText to the bottom instead of putting a lot of them?
-
Interesting, I haven't checked the whole code yet, but I shall try to copy it on my calculator to see how it looks like and hopefully take a few pictures.
You should post the program file on the forums as well, so people can load it on their calc faster.
-
If (G=27 And X=/21) ->checks if getkey 27 (or right) is pressed and X does not 21 (the far right side of the screen)
Then X+1->X ->add one to X, or in other words move to the right
Clrtext ->gets rid of previously drawn character so you don't end up with a line of characters :P
IfEnd -> ends the If statement
If (G=38 And X=/1) ->if left key is pressed and not all the way to the left
Then X-1->X
Clrtext
IfEnd
If (G=37 And Y=/7) ->the next lines of code will be basically the same thing, but in accordance to up and down or Y
Then Y+1->Y
ClrText
IfEnd
If (G=28 And Y=/1)
Then Y-1->Y
ClrText
IfEnd
If G=47 ->if exit is pressed
Stop -> .....well STOP! lol
IfEnd
could be optimized into:
If G ->make sure to delete G at the beginning of the loop, though :P
Then Clrtext
IfEnd
X+(G=27 And X=/21)-(G=38 And X=/1)->X ->if right is pressed, X is incremented by 1, if left is pressed, X is decremented by one
Y+(G=37 And Y=/7)-(G=28 And Y=/1)->Y ->same deal here, except with Y
If G=47 ->this stays the same as in saintrunner's code...
Then Stop ->methinks that you forgot a Then...
IfEnd
This might be a bit harder to understand for noobs, but it should be smaller(and maybe faster)
EDIT: this would also save some space:
delete this:
If G=47
Then Stop
IfEnd
and replace the while loop with this:
While G=/47
This eliminates another If loop :D
EDIT2: We should probably add a casio-basic section to our tutorials...
-
Yeah, I was planning on optimizing it today, I just wanted to get something out so people can get a feel for stuff :) also there shouldn't be any clrtexts in there if you want to display other 'tiles' otherwise you end up deleting them all....instead a locate x,y, " " would be better
and I'll add the file above, but I recommend just typing it in to the calc so you get used to the Casio feel
-
Double post ...sorta tutorial update:
This version supports menu's and optimized code. A bit more complicated, but still WAYYY smaller....232 bytes including menus. Enjoy :)
-
If G=47
Then Stop
IfEnd
This can be optimized to
G=47=>Stop
;)
=> can be found in JUMP menu.
-
Double post ...sorta tutorial update:
This version supports menu's and optimized code. A bit more complicated, but still WAYYY smaller....232 bytes including menus. Enjoy :)
How did you add menus and movement in 232 bytes?? O.O
-
It'll be interesting to see how crazy-optimized Prizm Basic can get 0.o
Maybe there might be some built-in semi-hidden things eventually found, like how you could Text(-1..) in Ti-Basic...
-
Double post ...sorta tutorial update:
This version supports menu's and optimized code. A bit more complicated, but still WAYYY smaller....232 bytes including menus. Enjoy :)
How did you add menus and movement in 232 bytes?? O.O
with the Menu command
Menu "name","option1",#variable,"option2",#variable
just like in TI BASIC
example:
Menu "Menu","start game",S,"quit",Q
lbl s
blah blah blah
lbl Q
Stop