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

Username:   Password: 
 RegisterRegister   
 [tutorial] For Extreme Newbies
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hez




PostPosted: Wed May 21, 2003 11:29 pm   Post subject: [tutorial] For Extreme Newbies

maybe this should have been in the ""turing Help" forum but i wasn't sure..


This is for Serious newbies only, i will explain and show you the most common progs (I Think) that newbies want to

know about Laughing



Using Font Tags:

code:

var fontID:int:=Font.New("IMPACT:50:italic")

Font.Draw("TESTING!...", 250 , 200, fontID, black)


As you can see, font tags alow you to have a different font/size/color for your message rather than the default font in turing....

code:
var fontID:int:=Font.New("IMPACT:50:italic")
Allows you to specify which font/size/style your font will

be and they have to be in that specific order.
code:
Font.Draw("TESTING!...", 250 , 200, fontID, black)
Allows you to write your font on the screen, "250" is the x axis spacing and "200" is the y axis spacing,

try this and see if you can get the hang of it.

Fahreneit to Celsius
code:

var celsius,fahrenheit: real
var counter:int:=0

put "Please enter a degree in fahrenheit"
get fahrenheit

celsius := 5/9 * (fahrenheit - 32)

put "When converted "..
put fahrenheit..
put " degrees fahrenheit into celsius it would be: ",celsius:50:2 ..
put " degrees celsius"

The main key in this program is the formula "5/9 * (fahrenheit - 32)" which converts from two bases... very easy

Minutes to Convert to Days, Hours and Minutes Left
code:

var mins,hr1,min1,days1,hrleft: int


put " Please Enter the Number of Minutes to convert"
get mins

hr1:= mins div 60
days1:= hr1 div 24
min1:= mins mod 60
hrleft:= hr1 - days1 * 24

put "Days "..
put days1
put "Hours "..
put hrleft
put "Minutes "..
put min1

This program shows how to pass values when one value is full, and usage of "mod"(remainder) and div "(Divide without

decimal places).

Area of an Triangle
code:

var sd1,sd2,sd3,s,area: real

put "Please Enter the first side of the triangle"
get sd1

put "Please Enter the second side of the triangle"
get sd2

put "Please Enter the third side of the triangle"
get sd3

s:= (sd1 + sd2 + sd3) / 2
area:=( sqrt (s * (s-sd1) * (s-sd2) * (s-sd3) ) )



put "The area of the trangle would be "..
put area

This shows you how to use the forumla "( sqrt (s * (s-sd1) * (s-sd2) * (s-sd3) ) )" to figure out the area inside an

triangle.

Slot Machine
code:

var token : int := 100
var num1, num2, num3 : int
var ans : string


loop
    if token = 0 then
        play ("8>>b<<>b<b<b>pppp")
        put ("Whoops! You ran out of tokens better luck next time...")
        exit
    end if

    put "You have ", token, " tokens. Pull?" ..
    put "   <Y/N>   " ..
    get ans
    if ans = "Y" or ans = "y" then
        cls
        token -= 1
        for spin:1..20
            cls
            put "Spinning.."
            put "---------"
            randint (num1, 1, 3)
            randint (num2, 1, 3)
            randint (num3, 1, 3)
            put "[", num1, "]" ..
            put "[", num2, "]" ..
            put "[", num3, "]"
            put "---------"
            delay(50)

        end for

        if num1 = 1 and num2 = 1 and num3 = 1 then
            play (">>>faba<<<p")
            put "You won 4 Tokens!"
            token += 4

        elsif num1 = 2 and num2 = 2 and num3 = 2 then
            play (">>>faba<<<p")
            put "You won 8 tokens!"

        elsif num1 = 3 and num2 = 3 and num3 = 3 then
            play (">>>faba<<<p")
            put "You won 12 tokens!"
            token += 12
        else
            play ("<<<<<f>>>>>p")
            put "You lost"
        end if

    elsif ans = "N" or ans = "n" then
        cls
        put "Better Luck Next Time.."
        exit
    else
        cls
        put "PLEASE ENTER 'Y' for YES or 'N' for NO"
        put ""

    end if

end loop


A fun little olg game which simply uses 3 randint numbers and compares them, if they turn out to be the same you get

tokens,else you lose a token every turn (100 to start off with).


Well, thats it for now hope someone can benefit from this tiny stuff.
More availible at : http://infostat.port5.com
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu May 22, 2003 10:17 am   Post subject: (No subject)

thx hez Smile

+20Bits

Maybe you could post some more from your site? Or expand on our tutorials if the topics are already covered.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Prince




PostPosted: Thu May 22, 2003 10:24 am   Post subject: (No subject)

good job... cool site too
whowho




PostPosted: Thu May 22, 2003 4:55 pm   Post subject: (No subject)

cool Twisted Evil Twisted Evil Razz Mad
who is Nat Por
skatelhs




PostPosted: Thu May 22, 2003 5:01 pm   Post subject: not that newbie

hey, im in grade 10 compsci and that stuff isnt all that easy for me...
try like

var name:string
get name
put "Hello, ", name
Asok




PostPosted: Thu May 22, 2003 5:41 pm   Post subject: (No subject)

we have a tutorial on that allready skate.
delusional_




PostPosted: Sat Nov 15, 2003 5:11 pm   Post subject: thanx

thanks for that website, there should be more sites like that out there for people who suk at proggramming coz their skool courses suk Rolling Eyes
Tony




PostPosted: Sat Nov 15, 2003 5:28 pm   Post subject: (No subject)

yeah... well it looks like we're the only site around Confused

if you have any sujestions for improvement, let us know Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
santabruzer




PostPosted: Sun Nov 16, 2003 8:54 pm   Post subject: (No subject)

This is an amazing site...
(At least people are taking the initiative... and creating other great sites)
TheLostSoul




PostPosted: Thu Mar 11, 2004 6:35 pm   Post subject: (No subject)

Thx For This, I Have A Question Tho....I Am Learning This In School, And I Am Trying To Make A Animation With This Slot Machine, I Am Wondering How I Would Put The Numbers In Different Positions On The Screen? The Only Way I Can Think Of Is Using

put "":10, "[",num1,"]"

And Such, I Was Wondering If There Is A Better Way, So I Can Change The Size As Well?

Thx A Lot
Tony




PostPosted: Thu Mar 11, 2004 7:26 pm   Post subject: (No subject)

well... use Font module
code:

var fontID:int := Font.New("Arial:30")
var text:string

loop
text:= "["+intstr(Rand.Int(0,9))+"]["+intstr(Rand.Int(0,9))+"]["+intstr(Rand.Int(0,9))+"]"
Font.Draw(text,100,100,fontID,black)
delay(100)
cls
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
recneps




PostPosted: Fri Mar 12, 2004 2:34 pm   Post subject: (No subject)

even simpler than what tony said, if you dont understand it, is use the
intstr command, it converts and integer to a string (or strreal, i tink you can figure that one out) and just stick that in your Font.Draw like this

code:
Font.Draw(intstr(x),xpos,ypos,defFontID,7)

thatll draw your variable, x, as a string, using Font.Draw at xposition xpos and y position ypos.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: