
-----------------------------------
Dan
Thu Dec 19, 2002 9:29 pm

[Tutorials] Pictures/Images
-----------------------------------
How to use images in Turing


You can load 3 different types of pictures in Turing. They are PCX, BMP and TIM.


1st you need to load the image into Turing's memory:

var varname :int := Pic.FileNew ("filename") 


     Ex.

     
     %for a file that is in the same dir as your Turing code                                                                                                                    
      var mypic :int := Pic.FileNew ("coolpic.bmp") 
      

or

       
       %to specify the exact location of this file
       var mypic :int:= Pic.FileNew ("c:\turing\mygame\coolpic.bmp")
       

2nd you need to show the picture and set it's location on the screen

Pic.Draw (picID, x, y, mode)


Ex.

                %to draw the picture in the center of the screen with no mode
	Pic.Draw (mypic, maxx div 2, maxy div 2, 0)


The modes:

picCopy    This draws the picture on top of what was  underneath, obscuring it completely.

picXOR    This draws the picture XORing it with the background.

picMerge    This draws the picture like picCopy except that any occurrence of the background color in the picture is not drawn to the screen.

picUnderMerge    This draws the picture, but only where the background color was displayed underneath it


If you want to get rid of the picture after you have drawn it on the screen use cls and to get it out of the memory of the computer use Pic.Free (mypic).


Example of a program that uses pics:



		%program to show a logo picture
		var mypic :int := Pic.FileNew ("coolpic.bmp")
		Pic.Draw (mypic, maxx div 2, maxy div 2, 0)
		
		delay (2000)
		cls
		Pic.Free (mypic)



this was one of the 1st  turealrs i made, i dont think i did a good job on it but i  figered why  not post. so here it is...

-----------------------------------
Tony
Thu Dec 19, 2002 10:29 pm


-----------------------------------
turing 4.x also supports .jpg format. And you can also hope for .gif support in about 4-5 years from now.

-----------------------------------
cutecotton
Mon Dec 23, 2002 12:59 am


-----------------------------------
*sniff* how i wished i found this forum earlier..i've been struggling for 2 days to find out howt o do that in turing..*sniff*

-----------------------------------
Vicous
Fri Feb 28, 2003 9:52 am

window size
-----------------------------------
on a side note, what is the code for changing the window size, I know it has something to do with setscreen

-----------------------------------
Tony
Fri Feb 28, 2003 10:02 am


-----------------------------------
View.Set("graphics:length;height")

as in View.Set("graphics:400;100")

-----------------------------------
Vicous
Fri Feb 28, 2003 10:12 pm

view.set, setscreen
-----------------------------------
wha? whats the dif between view.set and setscreen?

-----------------------------------
Tony
Sat Mar 01, 2003 12:08 am


-----------------------------------
no difference... you can use ether one you like.

-----------------------------------
Vicous
Sun Mar 02, 2003 4:45 am

Re: [Tutorials] Pics
-----------------------------------
How to use images in Turing

The modes:

picCopy    This draws the picture on top of what was  underneath, obscuring it completely.

picXOR    This draws the picture XORing it with the background.

picMerge    This draws the picture like picCopy except that any occurrence of the background color in the picture is not drawn to the screen.

picUnderMerge    This draws the picture, but only where the background color was displayed underneath it



can you elaborate on a few things, such as how to set which background color, and what XORing means?

-----------------------------------
Asok
Wed Mar 05, 2003 7:09 pm


-----------------------------------
I figured picXor was just some guys at UofT being leet.

don't hax0r my picX0r!

ooooh yea!  :)

-----------------------------------
Tony
Wed Mar 05, 2003 7:33 pm


-----------------------------------
someone beeing playing too much counter-stike :wink:

its a good game though  8)

-----------------------------------
Tubs
Wed Mar 05, 2003 7:40 pm


-----------------------------------
rofl thats good

its not just in cs, that kind of language is on every internet game

btw cs sucks compared to mohaa bf1942 etc etc

-----------------------------------
Asok
Wed Mar 05, 2003 7:51 pm


-----------------------------------
I have to agree, in bf1942 you get to run people over in viechles! *remembers tribes2*

*beep beep*
whoops  :lol:

-----------------------------------
Vicous
Wed Mar 05, 2003 7:56 pm

well
-----------------------------------
hate to be the one to break up this converstation (Counterstrike sounds familiar but I can't pin it down right now) but I kinda want the answer

-----------------------------------
Asok
Wed Mar 05, 2003 8:11 pm


-----------------------------------
k, all the pic options have to do with picture layering on top of eachother

picMerge will set it so that the color that matches the background is actually transparents so you can see images underneath

picCopy place the image on top of allready drawn images.

picXor inverts the color that is different than the background when a picture is touching it.

picUnderMerge sends the picture to the back so that other images that were drawn before it are still above it.

EDIT: oh and to set the background color is:

colorback(color)

where the parameter is replaced with the actual color you want. (the Candian spelling of "colour" works too.)

-----------------------------------
Vicous
Wed Mar 05, 2003 8:22 pm

the devil made me say it
-----------------------------------
what is this candian place and do they have candy?

sorry, that was just too tempting, thank you for answering my questions and giving me a reason to laugh

-----------------------------------
Tony
Wed Mar 05, 2003 8:57 pm


-----------------------------------
canada is a large North American nation located between Greenland and Alaska, most of which is above sea-level. Its the place where bombs will land once US anti-missile defence initiative takes place.

We dont have any candy, but I can offer you some sweets if you'd like :wink:

Alright... in case some smartass will start lecturing me on proper use of english and difference between its variations, I'll admit that we dont have any sweets ether... British do :? But we do import candy from US so feel free to treat yourself :wink:

-----------------------------------
Vicous
Thu Mar 06, 2003 7:49 pm

Im canadian too!
-----------------------------------
I'm canadian too, I was just joking as he posted that the "candian" (notice Candian, not Canadian) spelling of colour works too.

mmmmmmmmmm, candy

-----------------------------------
Tony
Thu Mar 06, 2003 8:12 pm


-----------------------------------
this is getting way off topic, but hey, what can I do?

if you start talking to dan, you can soon figure that he doesnt need to encript any of his documents cuz noone would be able to read them anyway :wink:

-----------------------------------
Dan
Thu Mar 06, 2003 9:48 pm


-----------------------------------
hell ya, and thats the way i like it (cuts down on cost of enrption software). also stops poleop form using find on my computer to find any of my docments  :wink: .

-----------------------------------
haujobb
Mon Mar 24, 2003 9:39 pm


-----------------------------------
I'm having trouble with these commands I'm using:

var title : int := Pic.FileNew ("a:\title.pcx") 

and:

Pic.Draw (title, 300, 300, 0)

and I get the error:

Illegal pic identifier

Does anyone know what that means, and can poeple hurry, I don't mean to be demanding but I'm on a tight schedule and I can't do much more until this damn thing works...

-----------------------------------
Tony
Mon Mar 24, 2003 9:44 pm


-----------------------------------
well although Dan said that file type is supported, I've never seem it before so I sujest using something we KNOW works. .bmp and .jpeg

or maybe it just cant find the file since its on an a:\ drive? such as floppy is missing... (why would you put image file on a floppy!?).

Illigal pic ID basically means you didnt load the file.

-----------------------------------
Delta
Tue Mar 25, 2003 2:35 pm

PCX hahahaha...(cough)
-----------------------------------
I remember PCX files but that was back in the day when I downloaded the DOS version of Turing. But you're a lot better off just sticking to BMP and JPG files.

-----------------------------------
Â¿Â§Â¥JÃ¥mÃ«sÂ¥Â§Â¿
Sat Aug 23, 2003 7:24 pm


-----------------------------------
How do you make the pic fill the whole screen like a back ground?









Canada rocks!!!!!! :D

-----------------------------------
krishon
Sat Aug 23, 2003 9:29 pm


-----------------------------------
i think it should be in the help files...i dunno...haven't touched turing in a while...and i mean a while, lol...its been all c++

-----------------------------------
Â¿Â§Â¥JÃ¥mÃ«sÂ¥Â§Â¿
Sun Aug 24, 2003 10:26 am


-----------------------------------
It just might be somewhere in the help files but I have no clue how to find ot can someone please help!!! :(  :?:

-----------------------------------
Tony
Sun Aug 24, 2003 7:27 pm


-----------------------------------

for y:1..maxy step pic.height(picID)
   for x:1..maxx step pic.width(picID)
   pic.draw(picID,x,y)
end for
end for


something like above.. standart grid filling algorithm.

Note: not actual turing code, might need to use proper syntax instead

-----------------------------------
AsianSensation
Sun Aug 24, 2003 9:39 pm


-----------------------------------
How do you make the pic fill the whole screen like a back ground?

Pic.Scale can do that.

newpicID := Pic.Scale (picID, maxx, maxy)

that would stretch a picture to fill the entire run window.

or ...

You can customize the picture before hand. Like use some editing tools, like Paint Shop Pro, and edit it, and then call up the image.

-----------------------------------
Â¿Â§Â¥JÃ¥mÃ«sÂ¥Â§Â¿
Sun Aug 24, 2003 9:44 pm

thanx
-----------------------------------
Thanx alot that'll really help :D

-----------------------------------
air_force91
Sun Jan 04, 2004 12:11 pm

i can't view the pic
-----------------------------------
u know how i need to enter (mypic, maxx div 2, maxy div 2, 0) 

well...the "0" at the end's creating a problem...this is what im getting: Illegal picture ID '0'. (Probable cause: Picture was not successfully created)...

-----------------------------------
Tony
Sun Jan 04, 2004 7:21 pm


-----------------------------------
no... the 0 is the value of picCopy mode.

the problem is your picture ID, which is "mypic" variable

-----------------------------------
DanShadow
Sun Jan 04, 2004 8:00 pm


-----------------------------------
Yes, your program is doing this:
(mypic, maxx div 2, maxy div 2, 0) 
Picture variable=             mypic
x co-ordinate of picture=  maxx div 2 
y co-ordinate of picture=  maxy div 2
value of picture=             0?????
Turing Program: 0?! Wtf does that mean!! AhhaAh! Dying!!!
The 0 has to be one of the following: (picCopy, picMerge, picXOR, etc.) I forget the rest of th em, but replace one of those with 0 to make the picture load correctly.

-----------------------------------
Mazer
Sun Jan 04, 2004 8:33 pm


-----------------------------------
no. 0 is perfectly fine. PicCopy is just a constant for 0.

watch:

put picCopy
put picXor
put picMerge
put picUnderMerge


tada! those are four of turings draw modes. you could type those, or you could type a number from 0 to 4 instead. 4 will work as a draw mode but it doesn't seem to do anything useful.

so, to sum up, the problem was indeed with the loading of the picture. you probably had the filename typed wrong.

-----------------------------------
DanShadow
Sun Jan 04, 2004 9:29 pm


-----------------------------------
Oh really?! I thought the value of the pic had to be identified by pic+something...not numbers. Hm, interesting

-----------------------------------
help_wanted
Fri Jan 09, 2004 1:11 pm

doesn't work
-----------------------------------
THIS DOES NOT WORK

-----------------------------------
DanShadow
Fri Jan 09, 2004 3:50 pm


-----------------------------------
NO! IT DOES WORK! YOU DONT WORK! WORK DAMN YOU!!
hehe, sorry for caps. And yes, it does work, make sure your picture, and .exe are in the same directory (folder). 
 

var ogre:int:=Pic.FileNew("ogre-picture.bmp")
Pic.Draw(ogre,200,200,picMerge)

Put a picture named "ogre-picture.bmp" in the same directory as your turing file, try this, and tell me it doesnt work. tx

-----------------------------------
recneps
Fri Jan 09, 2004 9:19 pm


-----------------------------------
sorry to be off topic (not that half of this topic has been) but why is the first page messed up?

-----------------------------------
Dan
Sat Jan 10, 2004 2:48 am


-----------------------------------
sorry to be off topic (not that half of this topic has been) but why is the first page messed up?

b/c an evil compsci.ca bug creeped up and eat the formating on the latter post on that page.

i am trying to kill this infseation of bugs but it has been slow going, alougth you may noticed that that waring on the main page is gone  :wink:

-----------------------------------
syphon4
Fri Jun 03, 2005 8:10 pm

pic
-----------------------------------
it always has a problem with my pic ture name in the location of the file..help
var pic : int := Pic.FileNew ("C:\pink pimp") 


my picture is saved directly under c: and its called pink pimp and its a jpeg file..................how can i make this program works

p.s. I will pwn any of you noobs in CS because im uber pro

-----------------------------------
Cervantes
Sat Jun 04, 2005 6:45 am

Re: pic
-----------------------------------
it always has a problem with my pic ture name in the location of the file..help
var pic : int := Pic.FileNew ("C:\pink pimp") 

my picture is saved directly under c: and its called pink pimp and its a jpeg file..................how can i make this program works

It's time we cleared something up.  Asking the same question multiple times does NOT increase the chances of getting help.  Rather, it infuriates people.

p.s. I will pwn any of you noobs in CS because im uber pro
:lol: And this doesn't help you get your answers either.

Now, go look in your [url=http://www.compsci.ca/v2/viewtopic.php?t=9129]other thread for your answer.

-----------------------------------
questionableninja
Wed Nov 21, 2007 5:00 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
when i input an img and i try to move it around it goes off the curser meaning that  when the curser goes off the screen the game ends : (

-----------------------------------
Clayton
Wed Nov 21, 2007 5:50 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
You're going to have to be a bit more descriptive here. I have absolutely no idea what you are talking about. Is the image set to track with the mouse? Is the image set to the keyboard cursor? I think you see the problem here.

-----------------------------------
sh0td0wn
Wed Jan 16, 2008 12:02 am

Re: [Tutorials] Pictures/Images
-----------------------------------
How do you kill the image after you're done with it, or at least hide?

-----------------------------------
syntax_error
Wed Jan 16, 2008 12:15 am

Re: [Tutorials] Pictures/Images
-----------------------------------
are you talking bout free.pic?
not sure if that is quite teh syntax but its something like that

-----------------------------------
ericfourfour
Wed Jan 16, 2008 4:36 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
If you want to remove a picture from the screen, you have to draw over it. To deallocate a picture's memory use Pic.Free.

-----------------------------------
revangrey
Fri Jan 02, 2009 5:05 pm

Re: [Tutorials] Pictures/Images
-----------------------------------
seeing as how many times this thread has been brought back I do not consider this to be a "necro"

I hope...

anyways I seem to be unable to put in a .jpg image

or any image for that matter

now I am pretty sure I have followed the steps but would anyone care to explain this to me?

I may have missed something...

-----------------------------------
Insectoid
Fri Jan 02, 2009 7:49 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
If you have a valid question, necroing a tutorial is perfectly fine. What version of Turing are you using? The original tutorial looks dated to me, written before JPGs were supported. I suggest looking through other people's code or posting your code in the help section. Then we can help better.

-----------------------------------
mrt2323
Sun Mar 15, 2009 11:10 pm

Re: [Tutorials] Pictures/Images
-----------------------------------
wtf is the A suppose to do after you specify the location of the pic. I can get it to work. Im noob at this.. it's only been my first 2 weeks with turing.

-----------------------------------
Insectoid
Mon Mar 16, 2009 8:44 am

RE:[Tutorials] Pictures/Images
-----------------------------------
That is a graphical error. Ignore it.

use Pic.FileNew ("blahblahblah.bmp")

-----------------------------------
bigone150
Tue Apr 28, 2009 8:34 am

Re: [Tutorials] Pictures/Images
-----------------------------------
var Alien : int := Pic.FileNew ("Alien.bmp")
Pic.Draw (Alien, 520, 195, 0) % 520,1



hmm that is my coding for a picture i wanna keep at coordinates 520,195...  when i run it it comes up as a blank screen even when i have all my coding... there.
Also while im at it i would like to make the picture shake left right a bit as its an alien.. IF someone could reply to this fast. I would really appreciate it as its due in 45 mins..

-----------------------------------
mirhagk
Thu Sep 24, 2009 10:42 am

Re: [Tutorials] Pictures/Images
-----------------------------------
Hey so i've read the tutorial on printing, I have a question though, is there any way to print a picture?

-----------------------------------
syntax_error
Thu Sep 24, 2009 11:07 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
You would have to write your own function for that to be remotely possible; I am certain there is no in built function with turing.

-----------------------------------
D_homes
Tue Jan 19, 2010 3:31 pm

RE:[Tutorials] Pictures/Images
-----------------------------------
Is it possible to use the same image more than once at a time?

-----------------------------------
TheGuardian001
Tue Jan 19, 2010 4:06 pm

Re: RE:[Tutorials] Pictures/Images
-----------------------------------
Is it possible to use the same image more than once at a time?
Yes.

-----------------------------------
D_homes
Tue Jan 19, 2010 4:35 pm

Re: RE:[Tutorials] Pictures/Images
-----------------------------------

Yes.

And how would one go about doing that?

-----------------------------------
TheGuardian001
Tue Jan 19, 2010 5:27 pm

Re: [Tutorials] Pictures/Images
-----------------------------------
The same way you did it the first time.
[code]
var myImg : int := Pic.FileNew("MyImage.jpg")
Pic.Draw(myImg,10,10,picMerge)
Pic.Draw(myImg,300,300,picMerge)
[/code]

-----------------------------------
Jfenty15
Sat Dec 25, 2010 1:35 am

RE:[Tutorials] Pictures/Images
-----------------------------------
K wat if ive got a forked backround looping, but continueously 'cls'ing? for me the picture just flickers :(
and how do i post code so i can show you?

-----------------------------------
Jfenty15
Sat Dec 25, 2010 1:37 am

RE:[Tutorials] Pictures/Images
-----------------------------------
here but warning this could cause siezures or epileptic reactions so beware: View.Set ("graphics:1200;800, nobuttonbar")

var i : int := 0

procedure sticky (y : real)
    var stickyleft : int := Pic.FileNew ("Sticky left.GIF")
    var stickyright : int := Pic.FileNew ("Sticky right.GIF")
    if y = 1 then
        cls
        Pic.Draw (stickyleft, maxx div 2, maxy div 2, picCopy)
    elsif y = 2 then
        cls
        Pic.Draw (stickyright, maxx div 2, maxy div 2, picCopy)
    end if
end sticky

process playstuff
    loop
        Music.PlayFile ("Full Double Rainbow.wav")
    end loop
end playstuff

process backround
    loop
        if Rand.Real > 0.5 then

            for x : 32 .. 54
                colorback (x)
                cls
            end for
        end if
    end loop
end backround


fork playstuff
fork backround
loop
    for y : 1 .. 2
        sticky (y)
    end for
end loop

-----------------------------------
Tony
Sat Dec 25, 2010 1:44 am

RE:[Tutorials] Pictures/Images
-----------------------------------
Drawing the background and foreground at the same time is just a bad idea. I'll let you figure out as to why that is.

-----------------------------------
TokenHerbz
Sat Dec 25, 2010 3:17 am

RE:[Tutorials] Pictures/Images
-----------------------------------
ya terrible, try also offscreenonly and View.Update to help smooth things over.

-----------------------------------
Jfenty15
Sun Dec 26, 2010 12:02 am

RE:[Tutorials] Pictures/Images
-----------------------------------
is there a way to clear backround and for ground seperatly?

-----------------------------------
Jfenty15
Sun Dec 26, 2010 12:09 am

RE:[Tutorials] Pictures/Images
-----------------------------------
oh and is it possible to delay one part but not another if they are both part of a fork?

-----------------------------------
Jfenty15
Sun Dec 26, 2010 12:18 am

RE:[Tutorials] Pictures/Images
-----------------------------------
:S sorry one more thing um... i ran out of max id numbers even tho im "cls"ing so if i can delete the image or reset the id numbers? but before i finish the whole thing crashes because of loss of id numbers... here is the new program:

View.Set ("graphics:800;600, nobuttonbar")

var i : int := 0

procedure sticky (y : real)
    var stickyleft : int := Pic.FileNew ("Sticky left.GIF")
    var stickyright : int := Pic.FileNew ("Sticky right.GIF")
    if y = 1 then
        cls
        Pic.Draw (stickyleft, (800 div 2)-100, (600 div 2)-75, picMerge)
        delay (100)
    elsif y = 2 then
        cls
        Pic.Draw (stickyright, (800 div 2)-50, (600 div 2)-75, picMerge)
        delay (100)
    end if
end sticky

process playstuff
    loop
        Music.PlayFile ("Full Double Rainbow.wav")
    end loop
end playstuff

process backround
    loop
        if Rand.Real > 0.5 then

            for x : 32 .. 54
                colorback (x)
            end for
        end if
    end loop
end backround


fork playstuff
fork backround
loop
    for y : 1 .. 2
        sticky (y)
    end for
end loop

please enter your own audio file and pic and see if you can make it work?... maybe using Pic.Mirror?

-----------------------------------
Tony
Sun Dec 26, 2010 12:28 am

RE:[Tutorials] Pictures/Images
-----------------------------------
Every time you use [tdoc]Pic.FileNew[/tdoc], it uses a new ID (up to a max of 1000, I think). Think about what it does (do you really need 1000 unique pictures at the same time?).

The background and foreground can be conceptually different, but you have only one screen to draw on. At the point the only difference is that you draw the background first and then the foreground on top. If you clear the screen, the entire thing clears. If you draw the background after the foreground, all you'll have on the screen is the background. forks makes the computer draw stuff at random, making everything a huge mess. Stop doing that.

-----------------------------------
gnauhZ
Thu May 19, 2011 11:33 am

Re: [Tutorials] Pictures/Images
-----------------------------------
I get an "Illegal Extended Character in string literal" at ("H:\Turing Game--->\M