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

Username:   Password: 
 RegisterRegister   
 moving fonts
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
starcraft




PostPosted: Sun Jun 04, 2006 7:28 pm   Post subject: moving fonts

code:

setscreen ("graphics:v256")
setscreen ("graphics:640,480")


%Set variable choice.
var startgame: string
var choice: string
var choice2: string
var leave: string


%OUTPUT TITLE
%--------------------------------------------------------------------
%Draws the title page.
drawfillbox (0,0,640,480,16)

for movingfont : 0 .. 160
%Set variable and font.
var height, ascent, descent, internalLeading : int
var font : int
font := Font.New ("Arial Black:50")
Draw.Text ("PACMAN", 150, 540-movingfont, font, 42)
        delay (3)
var font3 : int
font3 := Font.New ("Arial Black:50")
Draw.Text ("PACMAN", 150, 540-movingfont, font3, 254)
       
end for
var font4 : int
font4 := Font.New ("Arial Black:50")
Draw.Text ("PACMAN", 150, 380, font4, yellow)
 
var font2 : int
font2 := Font.New ("timesroman:30")
        Draw.Text ("Created By Jordan Cheng", 120, 65, font2, green)
        Draw.Text ("Press #1 to start the game", 120,30 , font2, green)

for movingpacman : 0 .. 740
Draw.FillArc (-80+movingpacman,230,80,80,10,310,yellow)
delay (3)
Draw.FillArc (-80+movingpacman,230,80,80,10,310,0)
end for


For some reason, The string text I tried to move, its draging, leaving lines. I used a block to cover it up before but then the center of the "p" and "a' are covered in yellow.

Can some one explain?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sun Jun 04, 2006 8:18 pm   Post subject: (No subject)

Shocked

Ok, first, some major problems:

code:

var height, ascent, descent, internalLeading : int
var font : int


Why would you declare these variables within the for loop? Aside from the fact that the first four are never even used...declare them outside instead, it's really bad technique otherwise (as will be elucidated shortly).

font, font3, font4 all surmount to the same thing. By declaring them as a single font outside of the for loop, you can use them multiple times.
eg.
code:

var font : int
font := Font.New ("Arial Black:50")

for i : 1..5
    Font.Draw ("Hello", 100 + i, 20, 12)
    delay (10)
    Font.Draw ("Hello", 100 + i, 20, 7)
end for


As for the flickering - I believe you're referring to the flickering in the PacMan? I don't see any in the font, but that just might be my computer...
Please refer to the Turing FAQ for details on how to reduce flicker.


[/code]
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  [ 2 Posts ]
Jump to:   


Style:  
Search: