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

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




PostPosted: Thu May 12, 2005 9:43 pm   Post subject: Scaling Font Text

I'm a little stuck on having a decent intro effect. The fade text in and out tutorial worked, but it destroyed w/e was next in the proceeding code.

So, I tried another effect made by myself. In this case, I want a quick explosion of the text growing from small to big quickly.

I've tried doing it look so:

code:
   
setscreen("graphics:700;600")
 for size : 1 .. 24
        var introFont : int := Font.New ("Impact:" + intstr (size))
        Font.Draw ("Intro text here" ,10, 400, introFont, black)
        delay (10)
    end for


But I a crumpled up, black bloch on my screen, that doesnt look like the text at all.
Sponsor
Sponsor
Sponsor
sponsor
Bacchus




PostPosted: Thu May 12, 2005 9:58 pm   Post subject: (No subject)

your not clearing the area after you put the text, so its writting the new bigger text over the old one making it look like crap. try adding in a cls or just drawing a white box over the previous area
syntax0r




PostPosted: Thu May 12, 2005 10:27 pm   Post subject: (No subject)

Wow, how stupid of me!

code:

setscreen ("graphics:700;600")
for size : 1 .. 24
    var introFont : int := Font.New ("Impact:" + intstr (size))
    Font.Draw ("Intro text here", 10, 400, introFont, black)

    delay (10)
    cls
end for
var introFont : int := Font.New ("Impact:24")
 Font.Draw ("Intro text here", 10, 400, introFont, black)


Now, the hard is to have it scale from within the center of the text >Sad ..

Im a little stuck there
Bacchus




PostPosted: Fri May 13, 2005 5:50 am   Post subject: (No subject)

try using Font.Width to help you out. what you do is take the point you want as the middle of the text and subtract the width of the text (using Font.Width) divded by 2 (so subtract half the width). also its easiest to put the cls before the text so you dont have to draw it again. i also took the variable out of the for loop so it wont be declared may times and set the intro text to a variable so you only have to change one thing instead of 2
code:
setscreen ("offscreenonly,graphics:700;600")
var introFont : int
var introText : string := "Intro Text Here"
for size : 1 .. 54
    cls
    introFont := Font.New ("Impact:" + intstr (size))
    Font.Draw (introText, round ((maxx / 2) - (Font.Width (introText, introFont) / 2)), 400, introFont, black)
    View.Update
    delay (10)
end for
syntax0r




PostPosted: Fri May 13, 2005 6:35 am   Post subject: (No subject)

Thanks for the help!

I didn't know what the Font.Width statement or View.Update, but i looked those commands up and I understand your code.
mercuryy




PostPosted: Sat May 21, 2005 6:04 pm   Post subject: (No subject)

I was thinking is there anyother way other using the "offscreen" command to smooth the animation "welcom" because i wanna do a program like

code:


setscreen ("graphics:600;400")
var introFont : int
var introText : string := "Welcome "
for size : 1 .. 55
    cls
    introFont := Font.New ("Impact:" + intstr (size))
    Font.Draw (introText, round ((maxx / 2) - (Font.Width (introText, introFont) / 2)), 200, introFont, black)
    View.Update
    delay (10)
end for

delay(500)
colourback(grey)
cls
colour(white)
var x1, y1, x2, y2, x, y,x9, button, x3, x4, mouseX, mouseY : int
x1 := 10%x-cordinate for left side of the box 1
y1 := 30%y-cordinate for left side of the box 1&2
x2 := 83%x-cordinate for right side of the box 1
y2 := 60%y-cordinate for right side of the box 1&2
x3 := 100%x-cordinate for left side of the box 2
x4 := 180%x-cordinate for right side of the box 2
x9:=1

 
loop
put " "
put "        ", Time.Date

        drawbox (x1, y1, x2, y2, black)
        locate(23,3)
        put"Button 1"..
       
        drawbox (x3, y1, x4, y2, black)
         locate(23,14)
        put" Button 2"..
       
        Mouse.Where (x, y, button)
        if button = 0 and x >= x1 and x <= x2 and y >= y1 and y <= y2
        then
       
        drawbox (x1, y1, x2, y2, white)
        delay(100)
   
        elsif button = 1 and x >= x1 and x <= x2 and y >= y1 and y <= y2
        then
       
   
    cls
    locate(x9,1)
    put "star"
   
elsif button = 0 and x >= x3 and x <= x4 and y >= y1 and y <= y2
then
drawbox (x3, y1, x4, y2, white)
delay(100)
elsif button not= 0 and x >= x3 and x <= x4 and y >= y1 and y <= y2
then
       
   
    cls
    locate(x9,1)
    put "moon"

        end if
    end loop







but if i use offscreen command the loop doesn't work for some reason.


this is how i put it
code:


setscreen ("offscreenonly,graphics:600;400")
var introFont : int
var introText : string := "Welcome "
for size : 1 .. 55
    cls
    introFont := Font.New ("Impact:" + intstr (size))
    Font.Draw (introText, round ((maxx / 2) - (Font.Width (introText, introFont) / 2)), 200, introFont, black)
    View.Update
    delay (10)
end for

delay(50)
colourback(grey)
cls
colour(white)
var x1, y1, x2, y2, x, y,x9, button, x3, x4, mouseX, mouseY : int
x1 := 10%x-cordinate for left side of the box 1
y1 := 30%y-cordinate for left side of the box 1&2
x2 := 83%x-cordinate for right side of the box 1
y2 := 60%y-cordinate for right side of the box 1&2
x3 := 100%x-cordinate for left side of the box 2
x4 := 180%x-cordinate for right side of the box 2
x9:=1

 
loop
put " "
put "        ", Time.Date

        drawbox (x1, y1, x2, y2, black)
        locate(23,3)
        put"Button 1"..
       
        drawbox (x3, y1, x4, y2, black)
         locate(23,14)
        put" Button 2"..
       
        Mouse.Where (x, y, button)
        if button = 0 and x >= x1 and x <= x2 and y >= y1 and y <= y2
        then
       
        drawbox (x1, y1, x2, y2, white)
        delay(100)
   
        elsif button = 1 and x >= x1 and x <= x2 and y >= y1 and y <= y2
        then
       
   
    cls
    locate(x9,1)
    put "star"
   
elsif button = 0 and x >= x3 and x <= x4 and y >= y1 and y <= y2
then
drawbox (x3, y1, x4, y2, white)
delay(100)
elsif button not= 0 and x >= x3 and x <= x4 and y >= y1 and y <= y2
then
       
   
    cls
    locate(x9,1)
    put "moon"

        end if
    end loop



I tried to set the screen again after the "welcome" part of the program but it doesn't seem to work. thanks and sorry for the long code
Cervantes




PostPosted: Sat May 21, 2005 7:14 pm   Post subject: (No subject)

Your problem is you forgot to add a View.Update in the main loop (the one with the buttons).
In that loop, you should try to group all your drawing together. You should only have one cls, and only one View.Update.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: