High score help
Author |
Message |
mnorman
|
Posted: Mon May 16, 2011 11:18 am Post subject: High score help |
|
|
Im trying to make a simple highscore table but im having problem displaying the score
<Replace all the <> with your answers/code and remove the <>>
im trying to use font.draw to display the text but when i try to use an interger varable turing dosent like it
also how to i get it to display from highest to lowest in stead of lowest to highest
ive trie using font. set but it dosent work either
Turing: |
<setscreen ("graphics:1000;500")
var score : array 1 .. 10 of int := init (100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000)
var names : array 1 .. 10 of string := init ("Moe", "Chris", "Devin", "Matt", "Nik", "Joe", "Alex", "Lisa", "Emma", "Oden")
var ranks, sScore : array 1 .. 10 of string
var newIndex : int := 0
var choice : string
var userScore, font1 : int
var name : string
font1 := Font.New ("Algerian:40")
put "Please enter your name"
get name
put "Please enter your score"
get userScore
function getRank (score : int) : string
if score <= 100000 then
result "Slave"
elsif score >= 100001 and score <= 200000 then
result "Peasant"
elsif score >= 200001 and score <= 300000 then
result "Horse Man"
elsif score >= 300001 and score <= 400000 then
result "Archer"
elsif score >= 400001 and score <= 500000 then
result "Knight"
elsif score >= 500001 and score <= 600000 then
result "Earl"
elsif score >= 600001 and score <= 700000 then
result "Duke"
elsif score >= 700001 and score <= 800000 then
result "Queen"
elsif score >= 800001 and score <= 900000 then
result "King"
elsif score >= 900001 then
result "Emperor"
end if
end getRank
cls
for decreasing i : 10 .. 1
put score (i ), "\t", names (i ), "\t", getRank (score (i ))
end for
put " "
put "Do you want to save your score or not? (Y/N)"
get choice
procedure sort
for i : 1 .. 10
for j : 2 .. 10
if score (j - 1) < score (j ) then
var temp : int := score (j - 1)
score (j - 1) := score (j )
score (j ) := temp
var temp2 : string := names (j - 1)
names (j - 1) := names (j )
names (j ) := temp2
end if
end for
end for
if userScore > score (1) then
newIndex := 1
else
for k : 1 .. 9
if userScore < score (k ) and userScore > score (k + 1) then
newIndex := (k + 1)
end if
if userScore = score (k ) then
newIndex := k
end if
end for
end if
if newIndex not= 0 then
for decreasing j : 10 .. (newIndex + 1)
names (j ) := names (j - 1)
score (j ) := score (j - 1)
end for
names (newIndex ) := name
score (newIndex ) := userScore
end if
end sort
var words : string
if choice = "y" then
sort
cls
for i : 1 .. 10
Font.Draw (getRank (score (i )), 25, i * 40, font1, green)
Font.Draw (names (i ), 350, i * 40, font1, green)
Font.Draw (i, 0, i * 40, font1, green)
Font.Draw (score (i ), 500, font1, green)
end for
elsif choice not= "y" then
cls
end if>
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Zren
|
Posted: Mon May 16, 2011 11:33 am Post subject: RE:High score help |
|
|
intstr(number)
Would return a string. Eg: 10 -> "10". |
|
|
|
|
|
mnorman
|
Posted: Tue May 17, 2011 10:37 am Post subject: RE:High score help |
|
|
thanks i looked that up in index but it looked complicated, turns out its simple |
|
|
|
|
|
|
|