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

Username:   Password: 
 RegisterRegister   
 Another Challege With View.Set this time.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
StarGateSG-1




PostPosted: Wed Jun 01, 2005 4:25 pm   Post subject: Another Challege With View.Set this time.

I have to programs Identical except for one thing which total changes the way the program runs, why?

The first program
code:
% Sets the screen

View.Set("graphics:640;480,nobuttonbar,offscreenonly,nocursor,noecho,xor,
title:Dark Tides: The Beginnings")

% Declaration of Variables
var location : % record of location (x_coor,y_coor)
    record
        x_coor : int
        y_coor : int
    end record

var message : % Record of message (Title)
    record
        Creator : string
        Title : string
    end record

var font : % Record of font (Biblo_Regular,Biblo_Bold,Biblo_Fine,Tolkien,Ring_Bearer,Elven_Common)
    record
        Biblo_Regular : int
        Biblo_Bold : int
        Biblo_Fine : int
        Tolkien : int
        Ring_Bearer : int
        Elven_Common : int
    end record
   
% Declaration of procedures
forward procedure Intro
forward procedure MainScreen

% Declaration of font. values
font.Biblo_Regular := Font.New ("Bilbo-hand:20:Bold")
font.Biblo_Bold := Font.New ("Bilbo-hand-Bold:20")
font.Biblo_Fine := Font.New ("Bilbo-hand-fine:20")
font.Tolkien := Font.New ("Tolkien:20")
font.Ring_Bearer := Font.New ("Ringbearer:20")
font.Elven_Common := Font.New ("ElvenCommonSpeak:20")

% Declaration of message. values
message.Title := "Dark Tides:The Beginning"

% Declaration of location. values
location.x_coor := maxx div 2 - 150
location.y_coor := maxy div 2


body procedure Intro
    for i : 1 .. length (message.Title)
        for decreasing Colour : 31 .. 16
            Font.Draw (message.Title (i), location.x_coor, location.y_coor, font.Biblo_Bold, (Colour))
            delay (15)
        end for
        location.x_coor := location.x_coor + 16
        delay (240)
    end for
end Intro

body procedure MainScreen


end MainScreen

Intro

The second program
code:

% Sets the screen

View.Set ("graphics:640;480,nobuttonbar,offscreenonly,nocursor,noecho,xor,black,title:Dark Tides: The Beginnings")


% Declaration of Variables
var location : % record of location (x_coor,y_coor)
    record
        x_coor : int
        y_coor : int
    end record

var message : % Record of message (Title)
    record
        Creator : string
        Title : string
    end record

var font : % Record of font (Biblo_Regular,Biblo_Bold,Biblo_Fine,Tolkien,Ring_Bearer,Elven_Common)
    record
        Biblo_Regular : int
        Biblo_Bold : int
        Biblo_Fine : int
        Tolkien : int
        Ring_Bearer : int
        Elven_Common : int
    end record
   
% Declaration of procedures
forward procedure Intro
forward procedure MainScreen

% Declaration of font. values
font.Biblo_Regular := Font.New ("Bilbo-hand:20:Bold")
font.Biblo_Bold := Font.New ("Bilbo-hand-Bold:20")
font.Biblo_Fine := Font.New ("Bilbo-hand-fine:20")
font.Tolkien := Font.New ("Tolkien:20")
font.Ring_Bearer := Font.New ("Ringbearer:20")
font.Elven_Common := Font.New ("ElvenCommonSpeak:20")

% Declaration of message. values
message.Title := "Dark Tides:The Beginning"

% Declaration of location. values
location.x_coor := maxx div 2 - 150
location.y_coor := maxy div 2


body procedure Intro
    for i : 1 .. length (message.Title)
        for decreasing Colour : 31 .. 16
            Font.Draw (message.Title (i), location.x_coor, location.y_coor, font.Biblo_Bold, (Colour))
            delay (15)
        end for
        location.x_coor := location.x_coor + 16
        delay (240)
    end for
end Intro

body procedure MainScreen


end MainScreen

Intro


The only difference is that in the View.Set there is the word 'black, in there. That one word chnages the whole program. Why?
Edit :

I forgot to add this I know how to fix it I just found it funny
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Jun 01, 2005 5:32 pm   Post subject: (No subject)

Having junk in that setup string screws the whole thing up, as far as I know.
Also, that's a really terrible way of doing that kind of stuff. You should be using Font.Width. Here's an example:
code:

proc typeText (text : string, X, y, delay_ : int, fontTitle : string, fontHeight, clr : int)
    var s := text
    var x := X
    var font := Font.New (fontTitle + ":" + intstr (fontHeight))
    for i : 1 .. length (s)
        Font.Draw (s (i), x, y, font, clr)
        x += Font.Width (s (i), font)
        delay (delay_)
    end for
end typeText
typeText ("Hello World", 100, 100, 200, "Arial", 16, red)

And if you want to make the colours fade, let's use RGB please. Wink
code:

proc typeTextBlackToWhite (text : string, X, y, shades, delay_ : int, fontTitle : string, fontHeight : int)
    var s := text
    var x := X
    var font := Font.New (fontTitle + ":" + intstr (fontHeight))
    for i : 1 .. length (s)
        for decreasing j : shades .. 1
            exit when s (i) = " "   %we don't want to draw the spaces...
            RGB.SetColour (240, j / shades, j / shades, j / shades)
            Font.Draw (s (1 .. i - 1), X, y, font, black)
            Font.Draw (s (i), x, y, font, 240)
            delay (5)
        end for
        x += Font.Width (s (i), font)
        delay (delay_)
    end for
end typeTextBlackToWhite


typeTextBlackToWhite ("Hello World", 100, 100, 50, 50, "Monotype Corsiva", 72)
StarGateSG-1




PostPosted: Wed Jun 01, 2005 5:59 pm   Post subject: (No subject)

Ok, I already chnaged that, but that is not the problem, if you ran both code you would see it. It is one of those funny turing glictches. All I want is a reason why. Thanks for your input, I had already chnaged it though. They were just filler code.
Cervantes




PostPosted: Wed Jun 01, 2005 6:09 pm   Post subject: (No subject)

They don't seem to be all that different. Ones got a button bar, the other doesn't. One displays the output, the other doesn't. Confused
You know, since you're using offscreenonly, you might want to use a View.Update somewhere in your code. Thinking
StarGateSG-1




PostPosted: Wed Jun 01, 2005 6:24 pm   Post subject: (No subject)

I changed alot since I posted this code, you knwo how it evolves after you get to sleep on it.

I do have a true problem thought.

Basicly I have my game file which has the Game, read me, and then Data file. I need to way to axcess the data file without typing out the full pathname becasue then you would have to place the program in the same place everytime. I wnat it to know were it is and then and then add that on to the file name. I tryed using File.FullPath (Pathname) but that didn't work, I could play music located in Data//Music//file name.

I could use soem help plz.
Cervantes




PostPosted: Wed Jun 01, 2005 6:33 pm   Post subject: (No subject)

if you do
code:
open : fileNo, "folder//file.extension", put

Then you could put data into a file located at (the path of the Turing file)\folder.
And, why doesn't File.FullPath work? You would, obviously, need to add some stuff onto the end of the string returned by this function.
Lastly, does this still have to do with View.Set? Eh
StarGateSG-1




PostPosted: Wed Jun 01, 2005 6:36 pm   Post subject: (No subject)

No that ended, It it was a funny error that was fixed. But I added this on here, I meant to make new topic, but I solved my problem again. Sry for you time.
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: