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

Username:   Password: 
 RegisterRegister   
 Interactive Font.Draw?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
teh_man




PostPosted: Sat Aug 13, 2005 8:21 pm   Post subject: Interactive Font.Draw?

Ok guys I want to have a scene prior to my RPG where the player decides on their player traits and details. So naturally I want it to be interactive, using get variable. but I do not want to use put, I want to use Font.Draw, unless I can customize put text like Font.Draw. Here is what I have...

code:
Font.Draw ("Character Development", 10, 575, font1, red)
Font.Draw (" Firstname: ", 10, 550, font2, red)..
get firstname
Font.Draw (" Middlename: ", 10, 540, font2, red)..
get middlename
Font.Draw (" Gender: ", 10, 530, font2, red)..
get gender
Font.Draw (" Age: ", 10, 520, font2, red)..
get age


Something along those lines. But I want to be able to customize that font, rather than have the plain old white background with black text. Any ideas?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Aug 14, 2005 7:51 am   Post subject: (No subject)

Are you saying you don't want to use get? For getting input and using Font.Draw instead of get, you'll need to learn to use getch(). Check out the help file. Also, you need to learn how to convert variable types. Check out my String Manipulation Tutorial. Converting variable types is a ways down.

Here's some code:
Turing:

View.Set ("graphics:600;600,nocursor")
colourback (black)
cls
var font1 := Font.New ("Impact:18")
var font2 := Font.New ("Impact:16")

var character_development : array 1 .. 3 of string := init ("First Name:", "Middle Name:", "Last Name:")
var character_information :
    record
        names : array 1 .. 3 of string      %first name, middle name, and last name
    end record

fcn getch_input (x, y, font, clr : int) : string

    var building_string := ""
    var input : string (1)      % A string of length 1
    loop
        getch (input)
        exit when input = KEY_ENTER
        if index ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", input) ~= 0 then   %if input is found within the allowed characters string
            building_string += input
        end if
        Font.Draw (building_string, x, y, font, clr)
    end loop
    result building_string
end getch_input

Font.Draw ("Character Development", 10, 575, font1, red)
for i : lower (character_development) .. upper (character_development)
    Font.Draw (character_development (i), 50, 560 - i * 30, font2, red)
    character_information.names (i) := getch_input (60 + Font.Width (character_development (i), font2), 560 - i * 30, font2, red)
end for


Or, if you wanted it to be really great, you could use textfields. Here's the code (you'll have to download the .zip fileand run this program in the same folder):

Turing:

import TEXTFIELD
include "textfield procedures.t"
View.Set ("graphics:600;600,offscreenonly")
colourback (43)
cls
var font1 := Font.New ("Impact:18")
var font2 := Font.New ("Impact:16")

var quit_program := false

var field : array 1 .. 3 of pointer to TEXTFIELD
for i : lower (field) .. upper (field)
    new TEXTFIELD, field (i)
end for

field (1) -> INIT (maxx div 2, 400, 300, 30, "Enter First Name")
field (2) -> INIT (maxx div 2, 300, 300, 30, "Enter Middle Name")
field (3) -> INIT (maxx div 2, 200, 300, 30, "Enter Last Name")

fcn input_confirmed_in (textField : array 1 .. * of ^TEXTFIELD) : boolean
    for i : lower (textField) .. upper (textField)
        if not textField (i) -> is_inputConfirmed then
            result false
        end if
    end for
    result true
end input_confirmed_in

proc input (textField : array 1 .. * of ^TEXTFIELD)
    for i : lower (textField) .. upper (textField)
        textField (i) -> getInput
    end for
    if input_confirmed_in (textField) then
        quit_program := true
    end if
    handle_behaviour (field)
end input

loop

    input (field)

    cls
    draw (field)
    View.Update
    delay (10)

    exit when quit_program
end loop
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: