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

Username:   Password: 
 RegisterRegister   
 help with Pic.Draw
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
1kd7




PostPosted: Tue Oct 07, 2014 8:10 pm   Post subject: help with Pic.Draw

What is it you are trying to achieve?
Well im trying to make a side scroller and want the white in these pictures to be transparent but you need to use pic.draw to do that from what i see.
But pic.draw does not allow you to attach things at the end like pic.screenload
example:
Pic.Draw(LinkRun1,x,y,picmerge)
Pic.ScreenLoad("LinkRun"+intstr(R)+".bmp",x,y,picmerge)


The red text is what i want to do but cant



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


var R,x,y,S :int:=1
var mx, my, button : int
var ex : int := maxx-30
var ey : int := 10
var speed :int:=7
View.Set("graphics:1250;400,offscreenonly")
var run : array char of boolean
var platform:boolean:=false
var LinkRun1 : int := Pic.FileNew ("LinkRun1.bmp")
var LinkRun2 : int := Pic.FileNew ("LinkRun2.bmp")
var LinkRun3 : int := Pic.FileNew ("LinkRun3.bmp")
var LinkRun4 : int := Pic.FileNew ("LinkRun4.bmp")
var LinkRun5 : int := Pic.FileNew ("LinkRun5.bmp")
var LinkRun6 : int := Pic.FileNew ("LinkRun6.bmp")
var LinkRunL1 : int := Pic.FileNew ("LinkRunL1.bmp")
var LinkRunL2 : int := Pic.FileNew ("LinkRunL2.bmp")
var LinkRunL3 : int := Pic.FileNew ("LinkRunL3.bmp")
var LinkRunL4 : int := Pic.FileNew ("LinkRunL4.bmp")
var LinkRunL5 : int := Pic.FileNew ("LinkRunL5.bmp")
var LinkRunL6 : int := Pic.FileNew ("LinkRunL6.bmp")
var LinkStand : int := Pic.FileNew ("LinkStand.bmp")
var LinkStandL : int := Pic.FileNew ("LinkStandL.bmp")
var LinkSlash1 : int := Pic.FileNew ("LinkSlash1.bmp")
var LinkSlash2 : int := Pic.FileNew ("LinkSlash2.bmp")
var LinkSlash3 : int := Pic.FileNew ("LinkSlash3.bmp")
var LinkSlash4 : int := Pic.FileNew ("LinkSlash4.jpg")
var LinkSlash5 : int := Pic.FileNew ("LinkSlash5.bmp")
var LinkSlashL1 : int := Pic.FileNew ("LinkSlash1.bmp")
var LinkSlashL2 : int := Pic.FileNew ("LinkSlash2.bmp")
var LinkSlashL3 : int := Pic.FileNew ("LinkSlash3.bmp")
var LinkSlashL4 : int := Pic.FileNew ("LinkSlash4.jpg")
var LinkSlashL5 : int := Pic.FileNew ("LinkSlash5.bmp")

Pic.SetTransparentColor (LinkRun1,white)
Pic.SetTransparentColor (LinkRun2,white)
Pic.SetTransparentColor (LinkRun3,white)
Pic.SetTransparentColor (LinkRun4,white)
Pic.SetTransparentColor (LinkRun5,white)
Pic.SetTransparentColor (LinkRun6,white)
Pic.SetTransparentColor (LinkRunL1,white)
Pic.SetTransparentColor (LinkRunL2,white)
Pic.SetTransparentColor (LinkRunL3,white)
Pic.SetTransparentColor (LinkRunL4,white)
Pic.SetTransparentColor (LinkRunL5,white)
Pic.SetTransparentColor (LinkRunL6,white)
Pic.SetTransparentColor (LinkStand,white)
Pic.SetTransparentColor (LinkStandL,white)
Pic.SetTransparentColor (LinkSlash1,white)
Pic.SetTransparentColor (LinkSlash2,white)
Pic.SetTransparentColor (LinkSlash3,white)
Pic.SetTransparentColor (LinkSlash4,white)
Pic.SetTransparentColor (LinkSlash5,white)
Pic.SetTransparentColor (LinkSlashL1,white)
Pic.SetTransparentColor (LinkSlashL2,white)
Pic.SetTransparentColor (LinkSlashL3,white)
Pic.SetTransparentColor (LinkSlashL4,white)
Pic.SetTransparentColor (LinkSlashL5,white)


procedure Stand
cls

Pic.ScreenLoad(LinkStand,x,y,picMerge)
View.Update
end Stand

procedure StandL
cls

Pic.ScreenLoad(LinkStandL,x,y,picMerge)
View.Update
end StandL

procedure RunRight
Pic.ScreenLoad(LinkRun+R,x,y,picMerge)
View.Update
delay(95)
cls

R:=R+1
x:=x+speed
if R = 6 then
R:=1
end if
end RunRight

procedure RunLeft
Pic.ScreenLoad(LinkRunL+R,x,y,picMerge)
View.Update
delay(95)
cls

R:=R+1
x:=x-speed
if R = 6 then
R:=1
end if
end RunLeft


procedure SlashRight
Pic.ScreenLoad(LinkSlash1,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlash2,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlash3,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlash4,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlash5,x,y,picMerge)
View.Update
delay(95)
cls

end SlashRight

procedure SlashLeft
Pic.ScreenLoad(LinkSlashL1,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlashL2,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlashL3,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlashL4,x,y,picMerge)
View.Update
delay(95)
cls

Pic.ScreenLoad(LinkSlashL5,x,y,picMerge)
View.Update
delay(95)
cls
end SlashLeft

loop
Input.KeyDown (run)
if run('d') then
RunRight
elsif run('a') then
RunLeft
%elsif run('w') then
%JumpRight
elsif run(' ') then
Mouse.Where (mx, my, button)
if mx<x then
SlashLeft
elsif mx>x then
SlashRight
end if
else
Mouse.Where (mx, my, button)
if mx<x then
StandL

elsif mx>x then
Stand

end if
end if

end loop




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Oct 07, 2014 8:20 pm   Post subject: RE:help with Pic.Draw

There might be some confusion between LinkRun1, the variable name; and "LinkRun1.bmp", a string value.

That is, you can totally do
code:

var LinkRun1 : int := Pic.FileNew ("LinkRun" + intstr(1) + ".bmp")


You would probably want to loop over such variables, so arrays (see The Turing Walkthrough) are appropriate
code:

var links : array 0 .. 5 of int
for i: 0 .. 5
   links(i) := Pic.FileNew ("LinkRun" + intstr(i+1) + ".bmp")
end for
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  [ 2 Posts ]
Jump to:   


Style:  
Search: