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

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




PostPosted: Fri Feb 14, 2003 7:47 am   Post subject: Graphics

hi.
My class is doing a program on Logo. that's where you move the turtle with the commands. As u know in turing, you have various characters. yeah, so i wanted a spades charcter. I use the code for it. i want to know two things:
1. how do i put the character at the center
2. When the right command is used, i am supposed to rotate the turtle 90 degrees. how do i do that. In the sense what should i say to make it rotate 90 degrees.

replies are appreciated.
thanks Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Feb 14, 2003 9:13 am   Post subject: (No subject)

to put the character in the middle of the screen, you can use command locate(row,column)... such as
code:

locate(round(maxrow/2),round(maxcol/2))
put "tony"

will place word TONY in the middle of the screen (well the letter T will be in the exact middle Wink)

to rotate an image, you can ether load different images, premade and rotated as needed.

In turing version 4.x there's a new feature - Rotate() that allows you to generate a new image by rotating an existing one.

You can't output characters on an angle, but you can take a picture of it and rotate it as an image. For an example see:

Source Codes -> Text Effects -> Text Arc
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Swetha




PostPosted: Sat Feb 15, 2003 11:48 am   Post subject: Graphics

hi, its swetha. yeah, i sort of got that. but like you know that there are characters like, chr(216).. or something like that. so how do u put that in the center ? and what if you are using a previous version like 3.0 somthing?
please reply soon.
Tony




PostPosted: Sat Feb 15, 2003 12:03 pm   Post subject: (No subject)

same as before... you just replace the regular text with special characters such as:
code:

locate(round(maxrow/2),round(maxcol/2))
put chr(216)


as for the rotations... dan has a tutorial on how to use images in your program - http://danco.no-ip.com/turing/viewtopic.php?t=191

You can use MS Paint (included in every version of Windows) to draw basic images and to rotate them the way you want.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Swetha




PostPosted: Sat Feb 15, 2003 12:21 pm   Post subject: (No subject)

This is what i tried to do, and it gave me an saying lllegal picture identifier
i dont understand this


var mypic :int := Pic.FileNew ("Turtle.bmp")
Pic.Draw (mypic, maxx div 2, maxy div 2, 0)
Dan




PostPosted: Sat Feb 15, 2003 1:10 pm   Post subject: (No subject)

i just tested your code and it wroked.

you have to save the code in the same dir as the pic if you are loading with the code. also make shure that if you are using an older verison of turing that the diricory browser is set up right.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Swetha




PostPosted: Sat Feb 15, 2003 2:23 pm   Post subject: (No subject)

What do u mean by the directory setting up right. I copies the picture to the directorty where i save my tuing files That didnt work. It still gave me the same error message. Illegal pic identifier
Tony




PostPosted: Sat Feb 15, 2003 2:30 pm   Post subject: (No subject)

I know that DOS Turing requires full file path... though if you got WinOOT it shouldn't matter.

Maybe you spelled file name wrong? I belive its capital sensetive
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Swetha




PostPosted: Sat Feb 15, 2003 3:10 pm   Post subject: (No subject)

k, i got it. k here is a rought part of a program: logo.
i got the character to be in the ceter, but i cant figure out how to move that same sign foward, ie if the user inputs the command as " f "

var sCommand : string
var sFwd : string := "f"
var sLft: string := "l"
var sRght : string:= "r"
var iDst : int
var sSign : string
var sQuit : string := "q"
var x : int := 0
var y : int := 0

sSign := chr(6)
locate(round(maxrow/2),round(maxcol/2))
put sSign
loop
put "please enter a command"
get sCommand
if sCommand = sFwd then
put "Please enter a distance"
get iDst
y := y + iDst
put sSign , y
end if
end loop
Tony




PostPosted: Sat Feb 15, 2003 3:26 pm   Post subject: (No subject)

you placed character output OUTSIDE the loop... is has to be inside for it to draw. Also locate() need to have variables inside, not constants to actually move around...

here's your modified program:

code:

var sCommand : string
var sFwd : string := "f"
var sLft: string := "l"
var sRght : string:= "r"
var iDst : int
var sSign : string
var sQuit : string := "q"
var x : int := 15
var y : int := 15

sSign := chr(6)
loop

locate(round(y),round(x))
put sSign

locate(1,1)
put "please enter a command"
get sCommand
if sCommand = sFwd then
put "Please enter a distance"
get iDst
y := y + iDst
put sSign , y
end if
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Swetha




PostPosted: Sat Feb 15, 2003 5:08 pm   Post subject: (No subject)

Oh thanks a lot. you guys a real life saver. or real turing gods. k i got that. but i didnt understand one thing. what does locate (1,1) do?
just check this code. this is for when the command is right.

elsif sCommand = sRgt then
sSign = rotate (90)

and how to make the sign leave a trial like dwaring a line
Tony




PostPosted: Sat Feb 15, 2003 6:06 pm   Post subject: (No subject)

locate(row,column) moves the curson to a position on the screen from where text outputs. Basically you're using that to move your character.

locate(1,1) return the cursor back to top left so that the message asking for next command doesn't appear in the middle of the screen.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pheonix3000




PostPosted: Tue Feb 18, 2003 11:26 am   Post subject: (No subject)

k when i say var iSign : int:= Pic.FileNew ("Turtle.bmp") , why does it give em a -5? and how do u make the image to leave a trail like draw a line?i tried to draw a line Draw.Line (200. 500.200.10, blue) and it gave me an error at 200 saying that argument not in correct order or something like that.


var iDst : int
var iSign : int:= Pic.FileNew ("Turtle.bmp")
var sQuit : string := "q"
var x : int := 15
var y : int := 15
var direction : int := 0

loop
locate(round(y),round(x))
put iSign


locate(1,1)
put "please enter a command"
get sCommand
if sCommand = sFwd then
put "Please enter a distance"
get iDst
y := y - iDst
put iSign , y
end if
cls
end loop
pheonix3000




PostPosted: Tue Feb 18, 2003 11:28 am   Post subject: (No subject)

k when i say var iSign : int:= Pic.FileNew ("Turtle.bmp") , why does it give em a -5? and how do u make the image to leave a trail like draw a line?i tried to draw a line Draw.Line (200. 500.200.10, blue) and it gave me an error at 200 saying that argument not in correct order or something like that. Can u modify the code by putting in the line code? ie in terms of x and y coordinates


var iDst : int
var iSign : int:= Pic.FileNew ("Turtle.bmp")
var sQuit : string := "q"
var x : int := 15
var y : int := 15
var direction : int := 0

loop
locate(round(y),round(x))
put iSign


locate(1,1)
put "please enter a command"
get sCommand
if sCommand = sFwd then
put "Please enter a distance"
get iDst
y := y - iDst
put iSign , y
end if
cls
end loop
Tony




PostPosted: Tue Feb 18, 2003 12:42 pm   Post subject: (No subject)

code:

loop
locate(round(y),round(x))
put iSign


locate(1,1)
put "please enter a command"
get sCommand
if sCommand = sFwd then
put "Please enter a distance"
get iDst
y := y - iDst

%TRAIL PART BELOW
for i:1..iDst
locate(y+i,x)
put "*"
end for
%END TRAIL PART

put iSign , y
end if
cls
end loop


Also I'm confused... are you trying to use a character such as ^ to represent your moving object or an actual .jpg picture? Because right now you're tring to output picture AS a character Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 15 Posts ]
Jump to:   


Style:  
Search: