Jump to content



Photo
- - - - -

Highscore

Search

  • Please log in to reply
4 replies to this topic

#1 Trinity

Trinity

    Newbie

  • Members
  • Pip
  • 3 posts
  • Gender:Male
  • Location:Germany
  • Interests:IT, Coding

  • Calculators:
    Casio Algebra FX 2.0 plus

Posted 09 May 2014 - 12:20 PM

Hey everyone,
i'm new here an I need help.
First: sorry for my bad English I'm from Germany.

I want to make a Highscore list with 5 cells sorted by >SortD(< for my program Snake on the Algebra FX 2.0+

Can anyone Help me? I can't use if-states thats the reason for the big If-Loops

The sourcecode: Snake

Goto 0
Lbl 2
s+10->S
Text 5,30,S
if S=2550
Then Goto 3
IfEnd
Do
Int 46Ran# +46->U
Int 26Ran# +26->V
LpWhile PxlTest(64-V,U)=1
PlotOn U,V
Dsz M
For L+1->L to 256
Isz M
'Dont remove this text because Syntax'
If M=256
Then 2->M
IfEnd
Getkey->G
If G≠0
Then If G=31
Then Text 1,1,""
Else 0->A~B:IfEnd
If G=27
then 1->A
Else If G=28
Then 1->B
Else If G=38
Then -1->A
Else If G=37
Then -1->B
IfEnd:IfEnd:IfEnd:IfEnd:IfEnd
C+A->C:D+B->D
C->List 1[L]
D->List 2[L]
If C=U And D=V
Then Goto 2
Else If PxlTest(64-D,C=1)
Then Goto 3
IfEnd:IfEnd
PlotOn C,D
If L>1
then PlotOff List 1[M],List2[M]
IfEnd
If L=255
Then 1->L
IfEnd
Next
Lbl 3
ClrText
//Thats my Highscore but its not Perfectly. The score in the Cell will be overwrite. Thats wrong. The Highscore must be a real highscore list. I Hope you understand what i mean.
If S>0
then if S>List3[1]
Then S->List 3[1]
Else if S>List3[2]
Then S->List 3[2]
Else if S>List3[3]
Then S->List 3[3]
Else if S>List3[4]
Then S->List 3[4]
Else if S>List3[5]
Then S->List 3[5]
IfEnd:IfEnd:IfEnd:IfEnd:IfEnd:IfEnd
List 3 /| //Display triangle
Locate 7,4,"GAME OVER"
Locate 1,1,"SCORE:"
Locate 7,1,S
Locate 4,7,"PLAY AGAIN(Y/N)?"
Do:getKey->A
LpWhile A=0
If A=32
then Goto 0
Else If A=64
Then Stop
IfEnd:IfEnd
Lbl 0
ClrText
BG-None
ClrList 1
ClrList 2
0->A~Z
-10->S
45->C
35->D
Locate 8,4,"SNAKE"/| //Display Triangle
1->A
ViewWindows 1,127,0,1,63,0
F-Line 5,53,5,5
F-Line 5,5,120,5
F-Line 120,5,120,53
F-Line 120,53,5,53
Text 5,5,"SCORE:"
Goto 2

Need Help pls!!!!!

Edited by Trinity, 09 May 2014 - 12:26 PM.


#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 09 May 2014 - 08:23 PM

Hello Trinity and welcome to UCF! You should introduce yourself.

Can you save the high scores to a matrix?

#3 Trinity

Trinity

    Newbie

  • Members
  • Pip
  • 3 posts
  • Gender:Male
  • Location:Germany
  • Interests:IT, Coding

  • Calculators:
    Casio Algebra FX 2.0 plus

Posted 10 May 2014 - 01:14 PM

Can you write me the sourcecode to realize that. I don't know how matrics works.

Edited by Trinity, 10 May 2014 - 04:20 PM.


#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 16 May 2014 - 12:32 PM

It's been a while since I programmed in Casio-BASIC, but if I recall correctly, this is how its done:

<highscore> -> Mat A[x][y]

So, if the highscore that you want to store is 15, and that is the highest score, you would do this:
15 -> Mat A[1][1]

However, I just realized that matrices may not be the best way to do it. A list would probably be better. You could do that like this:

15 -> List 1

That will add 15 to the end of the list, which is not desirable. All the highscores should be in order of value. I know that there is a way to sort a list to have the largest numbers at the top, but right now I don't have the owners' manual with me, so someone else will have to help you on that, sorry.

To display the value a list, you can do this:
Locate 1,1,List 1[<cell>]

<cell> is the list cell. So to get the top entry, do this:
Locate 1,1,List 1[1]

Note that this will throw an error (I think it is a Dim Error, but not absolutely sure) if that cell has no value, so make sure that you create the cell before trying to read it. ;)

#5 somebody1234

somebody1234

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts

  • Calculators:
    Casio fxcg10
    Casio fx-9860GII
    Casio Classpad 400

Posted 21 August 2014 - 12:35 PM

It's Mat A[x, y]






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users