
-----------------------------------
mike200015
Sat Jan 29, 2005 1:09 pm

Text over Graphics
-----------------------------------
How can i put text over a graphic but so it doesnt cut it off.. heres the 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!

-----------------------------------
Cervantes
Sat Jan 29, 2005 1:12 pm


-----------------------------------
Try using fonts.  Check the Turing Help File, or [url=http://www.compsci.ca/v2/search.php]search CompSci.ca.

-----------------------------------
person
Sat Jan 29, 2005 2:18 pm


-----------------------------------
for example :


var font : Font.New ("TimesNewRoman:20")
Draw.Text (%ur text,%xcoord,%ycoord,font,%colour)


-----------------------------------
person
Sat Jan 29, 2005 6:26 pm


-----------------------------------
to th second part of ur question, this does the same thing as having if statements inside if statements

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
Sat Jan 29, 2005 6:46 pm


-----------------------------------
to th second part of ur question, this does the same thing as having if statements inside if statements

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 :D 

and as for the shorter 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
Sat Jan 29, 2005 7:10 pm


-----------------------------------
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, and the second is 