Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Variables in Font.Draw
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chipanpriest




PostPosted: Tue Dec 06, 2011 9:50 pm   Post subject: Variables in Font.Draw

Hey guys, it's me again, Aaron. I was just making another program which is like a hide-and-seek type of game. I want to be able to display the final score at the end in a bigger font than the Turing default when I do "put score". Can anyone help meh? Very Happy

Turing:


var mousex, mousey, click, boxx, boxy, col, score, timevar, font : int

View.Set ("graphics:1000;600,offscreenonly")
font := Font.New ("Comic Sans MS:30")

timevar := 0
score := 0
loop
    randint (col, 1, 15)
    randint (boxx, 20, maxx - 20)
    randint (boxy, 20, maxy - 120)

    loop
        cls
        mousewhere (mousex, mousey, click)
        drawfilloval (mousex, mousey, 50, 50, 0)
        drawfillbox (boxx - 10, boxy - 10, boxx + 10, boxy + 10, col)
        drawfillbox (0, 500, maxx, maxy, 0)
        drawline (0, 500, maxx, 500, 7)
        colourback (0)
        put "score: ", score
        locate (1, 50)
        put timevar
        colourback (col)
        View.Update
        if timevar = 5000 then
            exit
        end if
        timevar := timevar + 1
        if mousex >= boxx - 10 and mousex <= boxx + 10 and mousey >= boxy - 10 and mousey <= boxy + 10 and click = 1 then
            score := score + 1
            exit
        end if
    end loop
    if timevar = 5000 then
        exit
    end if
end loop
colourback (0)
cls

Font.Draw (score,100,100,font,7)



Please specify what version of Turing you are using
4.1.1



Hide and Seek.t
 Description:

Download
 Filename:  Hide and Seek.t
 Filesize:  987 Bytes
 Downloaded:  76 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Dec 06, 2011 10:00 pm   Post subject: RE:Variables in Font.Draw

What does the error say? Read the docs for Font.Draw to see what the function expects.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
chipanpriest




PostPosted: Wed Dec 07, 2011 7:08 am   Post subject: Re: Variables in Font.Draw

It says (txtStr : string, x, y, fontID, Color : int) which means that txtStr needs to be a string value but I need to be able to put a variable there so I was wonderin if maybe there's another way of doing this? all I want is to display my score with big font.
HairyDonut




PostPosted: Wed Dec 07, 2011 10:24 am   Post subject: RE:Variables in Font.Draw

Change score to intsr(score) and you'll be fine

i.e
Font.Draw (intstr(score),100,100,font,7)
chipanpriest




PostPosted: Wed Dec 07, 2011 11:50 am   Post subject: RE:Variables in Font.Draw

Thanks a lot that worked :p
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: