Author Topic: Saint's Casio BASIC n00b movement engine  (Read 4917 times)

0 Members and 1 Guest are viewing this topic.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Saint's Casio BASIC n00b movement engine
« 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:

Code: [Select]
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!
« Last Edit: February 22, 2012, 03:18:50 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Saint's Casio BASIC n00b movement engine
« Reply #1 on: February 21, 2012, 09:44:37 pm »
can't you pull down ClrText to the bottom instead of putting a lot of them?
Sig wipe!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Saint's Casio BASIC n00b movement engine
« Reply #2 on: February 22, 2012, 02:54:41 am »
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.

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
Re: Saint's Casio BASIC n00b movement engine
« Reply #3 on: February 22, 2012, 05:31:59 am »
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
If G=47
Then Stop
IfEnd
and replace the while loop with this:
Code: [Select]
While G=/47This eliminates another If loop :D

EDIT2: We should probably add a casio-basic section to our tutorials...
« Last Edit: February 22, 2012, 05:37:38 am by turiqwalrus »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Saint's Casio BASIC n00b movement engine
« Reply #4 on: February 22, 2012, 02:48:56 pm »
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
« Last Edit: February 22, 2012, 03:18:23 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Saint's Casio BASIC n00b movement engine
« Reply #5 on: February 22, 2012, 06:03:06 pm »
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 :)


My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Saint's Casio BASIC n00b movement engine
« Reply #6 on: February 22, 2012, 06:33:14 pm »
Code: [Select]
If G=47
Then Stop
IfEnd

This can be optimized to

Code: [Select]
G=47=>Stop

;)
=> can be found in JUMP menu.
Sig wipe!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Saint's Casio BASIC n00b movement engine
« Reply #7 on: February 22, 2012, 06:36:30 pm »
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

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Saint's Casio BASIC n00b movement engine
« Reply #8 on: February 22, 2012, 06:39:31 pm »
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...
« Last Edit: February 22, 2012, 06:40:09 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Saint's Casio BASIC n00b movement engine
« Reply #9 on: February 22, 2012, 06:46:15 pm »
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
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES: