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

Username:   Password: 
 RegisterRegister   
 Text over Graphics
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mike200015




PostPosted: Sat Jan 29, 2005 1:09 pm   Post subject: Text over Graphics

How can i put text over a graphic but so it doesnt cut it off.. heres the code:

code:
%Variable Declaration
var leftcol, centrecol, rightcol, maplecol, leftcol2, rightcol2 : int
var maplex, mapley, maplex2, mapley2 : int
var lrectx, lrectx2, rrectx, rrectx2 : int
var randx, randy, randcol : int
var startmaplex, startmaplex2, startmapley, startmapley2 : int
var again : string
var font : int := Font.New ("Arial Black:11")
maplex := 137
mapley := 10
maplex2 := 367
mapley2 := 265
startmaplex := 250
startmapley := 135
startmaplex2 := 250
startmapley2 := 135


loop
    %Setting Screen Size
    setscreen ("graphics:500;275,nobuttonbar")


    %Introduction
    colourback (40)
    cls
    Font.Draw ("Welcome To Mike's Crazy Canadian Flag Game", 50, 255, font, 7)
    delay (200)
    drawfillmapleleaf (0, 0, 34, 27, 0)
    delay (400)
    drawfillmapleleaf (0, maxy - 27, 34, maxy, 0)
    delay (400)
    drawfillmapleleaf (maxx - 34, 0, maxx, 27, 0)
    delay (400)
    drawfillmapleleaf (maxx - 35, maxy - 27, maxx, maxy, 0)
    delay (400)
    for i : 1 .. 28
        drawfillmapleleaf (startmaplex, startmapley, startmaplex2, startmapley2, 0)
        delay (35)
        startmaplex -= 5
        startmapley -= 5
        startmaplex2 += 5
        startmapley2 += 5
    end for
    Font.Draw ("Welcome To Mike's Crazy Canadian Flag Game", 50, 255, font, 7)


    %Data Gathering
    locate (4, 1)
    colour (7)
    put "Enter left rectangle colour: (Number from 0-255) " ..
    get leftcol
    delay (200)
    put "Enter flag centre colour: (Number from 0-255) " ..
    get centrecol
    delay (200)
    put "Enter right rectangle colour: (Number from 0-255) " ..
    get rightcol
    delay (200)
    put "Enter maple leaf colour: (Number from 0-255) " ..
    get maplecol
    delay (300)
    if leftcol > 255 then
        leftcol := 255
        if rightcol > 255 then
            rightcol := 255
            if centrecol > 255 then
                centrecol := 255
                centrecol := 0
                if maplecol > 255 then
                    maplecol := 255
                end if
            end if
        end if
    end if
    cls
    Font.Draw ("Your Colours Are Being Processed..", 60, 120, font, 7)
    delay (1000)
    Font.Draw ("Sit Back And Enjoy The Show!!", 80, 100, font, 7)
    delay (2700)
end loop


I want the question of what colour to go on top of the leaf, but so it doesnt cut it off. And also if anyone knows a way to sort of make this code shorter but still do the same thing. ( the extra variables are for the rest of the program)

Thanks!
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Jan 29, 2005 1:12 pm   Post subject: (No subject)

Try using fonts. Check the Turing Help File, or search CompSci.ca.
person




PostPosted: Sat Jan 29, 2005 2:18 pm   Post subject: (No subject)

for example :

Quote:

var font : Font.New ("TimesNewRoman:20")
Draw.Text (%ur text,%xcoord,%ycoord,font,%colour)
person




PostPosted: Sat Jan 29, 2005 6:26 pm   Post subject: (No subject)

to th second part of ur question, this does the same thing as having if statements inside if statements
code:

if leftcol > 255 then
        leftcol := 255
end if
if rightcol > 255 then
        rightcol := 255
end if
if centrecol > 255 then
        centrecol := 255
end if
if maplecol > 255 then
        maplecol := 255
end if
basketball4ever




PostPosted: Sat Jan 29, 2005 6:46 pm   Post subject: (No subject)

person wrote:
to th second part of ur question, this does the same thing as having if statements inside if statements
code:

if leftcol > 255 then
        leftcol := 255
end if
if rightcol > 255 then
        rightcol := 255
end if
if centrecol > 255 then
        centrecol := 255
end if
if maplecol > 255 then
        maplecol := 255
end if


person i dont know what you're talking about... but that doesn't make the code shorter, just more formal and precentable and right Very Happy

and as for the shorter code
code:

%Variable Declaration
var leftcol, centrecol, rightcol, maplecol, leftcol2, rightcol2 : int
var maplex, mapley, maplex2, mapley2 : int
var lrectx, lrectx2, rrectx, rrectx2 : int
var randx, randy, randcol : int
var startmaplex, startmaplex2, startmapley, startmapley2 : int
var again : string
var font : int := Font.New ("Arial Black:11")
maplex := 137
mapley := 10
maplex2 := 367
mapley2 := 265
startmaplex := 250
startmapley := 135
startmaplex2 := 250
startmapley2 := 135
%Proc colour changing
proc colourchanging (var col : int)
    if col > 255 then
        col := 255
    end if
end colourchanging

loop
    %Setting Screen Size
    setscreen ("graphics:500;275,nobuttonbar")


    %Introduction
    colourback (40)
    cls
    Font.Draw ("Welcome To Mike's Crazy Canadian Flag Game", 50, 255, font, 7)
    delay (200)
    drawfillmapleleaf (0, 0, 34, 27, 0)
    delay (400)
    drawfillmapleleaf (0, maxy - 27, 34, maxy, 0)
    delay (400)
    drawfillmapleleaf (maxx - 34, 0, maxx, 27, 0)
    delay (400)
    drawfillmapleleaf (maxx - 35, maxy - 27, maxx, maxy, 0)
    delay (400)
    for i : 1 .. 28
        drawfillmapleleaf (startmaplex, startmapley, startmaplex2, startmapley2, 0)
        delay (35)
        startmaplex -= 5
        startmapley -= 5
        startmaplex2 += 5
        startmapley2 += 5
    end for
    Font.Draw ("Welcome To Mike's Crazy Canadian Flag Game", 50, 255, font, 7)
    %Data Gathering
    locate (4, 1)
    colour (7)
    put "Enter left rectangle colour: (Number from 0-255) " ..
    get leftcol
    colourchanging (leftcol)
    delay (200)
    put "Enter flag centre colour: (Number from 0-255) " ..
    get centrecol
    colourchanging (centrecol)
    delay (200)
    put "Enter right rectangle colour: (Number from 0-255) " ..
    get rightcol
    colourchanging (rightcol)
    delay (200)
    put "Enter maple leaf colour: (Number from 0-255) " ..
    get maplecol
    colourchanging (maplecol)
    delay (300)
    cls
    Font.Draw ("Your Colours Are Being Processed..", 60, 120, font, 7)
    delay (1000)
    Font.Draw ("Sit Back And Enjoy The Show!!", 80, 100, font, 7)
    delay (2700)
end loop

see how i put in a procedure with a parameter pass... so meaning anything thats "col" in the procedure, now turns into watever u want it to be once u put brackets. For example... colourchanging (maplecol) col will then = maple col... not that much shorter but still works


btw... person, stop double posting, theres something called edit. It saves alot of space, see how i have btw on the same message?[/code]
person




PostPosted: Sat Jan 29, 2005 7:10 pm   Post subject: (No subject)

Quote:
person i dont know what you're talking about... but that doesn't make the code shorter, just more formal and precentable


wat hapens if the first colour is >255, and the second is <255?
i know this isnt going to help him, but i just thought that u would like to know

EDIT : i was talking about his old source code
basketball4ever




PostPosted: Sat Jan 29, 2005 7:24 pm   Post subject: (No subject)

person wrote:
Quote:
person i dont know what you're talking about... but that doesn't make the code shorter, just more formal and precentable


wat hapens if the first colour is >255, and the second is <255?
i know this isnt going to help him, but i just thought that u would like to know


doesn't matter its just that IF col >255 then
col := 255

so meaning
if u substitute it
the first variable wont affect the 2nd.. its different due to parameter pass.
mike200015




PostPosted: Sat Jan 29, 2005 9:10 pm   Post subject: (No subject)

thanx for answerin ma question.. and wats the difference between proc and procedure, or is it the same ?
Sponsor
Sponsor
Sponsor
sponsor
basketball4ever




PostPosted: Sat Jan 29, 2005 9:13 pm   Post subject: (No subject)

mike200015 wrote:
thanx for answerin ma question.. and wats the difference between proc and procedure, or is it the same ?


nope, its the same, just less typing Very Happy all better for us. Very Happy theres alot of short cuts into turing. and np, glad to help
mike200015




PostPosted: Sat Jan 29, 2005 11:59 pm   Post subject: (No subject)

wat other short cut kinda stuff r thr.. is thr like a list of different 1s by any chance any where?
Cervantes




PostPosted: Sun Jan 30, 2005 10:15 am   Post subject: (No subject)

Yes.
basketball4ever




PostPosted: Sun Jan 30, 2005 1:37 pm   Post subject: (No subject)

yup theres alot
and learning arrays is probably the biggest one
shortcuts include:
http://www.compsci.ca/v2/viewtopic.php?t=4588... go there... lots and lots of shortcuts that are good. Razz
mike200015




PostPosted: Sun Jan 30, 2005 2:48 pm   Post subject: (No subject)

hey thanx very much. both of those links helped me alot, i never knew thr was shortcuts like that
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  [ 13 Posts ]
Jump to:   


Style:  
Search: