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

Username:   Password: 
 RegisterRegister   
 My Image Will Not Stay On The Screen
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
22




PostPosted: Fri Jan 13, 2017 9:29 am   Post subject: My Image Will Not Stay On The Screen

What is it you are trying to achieve?
Make my image stay on the screen.


What is the problem you are having?
When my program moves to a new page, the image on that page will not stay on the screen. It disappears after about 2 seconds.


Describe what you have tried to solve this problem
I tried using delay, but it still didn't work.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
var name:string (1)
var name1:string := ""
var nameX:int :=320
var answer:int
var enter : string (1) := chr (13)
var counter,score:int :=0
var fontid,fontid2:int
var introCount:int :=0
fontid:=Font.New("Broadway:40:Bold")
fontid2:=Font.New("Times New Roman:15:Bold")
var fontid3:=Font.New("Palatino:20:bold")
var fontid4:=Font.New("Arial:20:bold")
var picID:int :=Pic.FileNew("1deab7e6c0b2947a17343d3d0efee99c.jpg")
var scaledPicID:=Pic.Scale(picID,130,200)
var picID2:int :=Pic.FileNew("Image #2.jpeg")
var scaledPicID2:=Pic.Scale(picID2,400,100)
var picID3:int :=Pic.FileNew("icecream.jpg")
var scaledPicID3:=Pic.Scale(picID3,150,200)
var picID4:int :=Pic.FileNew("amadeus.jpg")
var scaledPicID4:=Pic.Scale(picID4,55,80)
var x,y,button:int
var gameTittle:int :=1



colourback(39)
for row:1..25
for column:1..80
locate (row,column)
put " "
end for
end for

drawfillbox(10,10,630,390,58)

Pic.Draw(scaledPicID,20,180,picCopy)
Pic.Draw(scaledPicID2,20,50,picCopy)
Pic.Draw(scaledPicID3,475,50,picCopy)

process welcomePage
loop
Font.Draw("FunQuiz",180,290,fontid,11)
delay(500)
Font.Draw("FunQuiz",180,290,fontid,black)
delay(500)
Font.Draw("FunQuiz",180,290,fontid,11)
mousewhere(x,y,button)
exit when gameTittle=0
end loop
cls
end welcomePage

fork welcomePage
Font.Draw("Enter your name: ",170,230,fontid2,48)
loop
locatexy(320,230)
colorback(58)
getch(name)
Font.Draw(name,nameX,230,fontid2,48)
nameX:=nameX+10
exit when (ord(name)=10)
name1:=name1+name
end loop


Font.Draw("Welcome",170,200,fontid3,red)
Font.Draw(name1,300,200,fontid3,red)
drawbox(475,15,624,45,red)
Font.Draw("Next",520,20,fontid3,red)
loop
mousewhere(x,y,button)
if (button=1) and x>=520 and x<=624 and y>=15 and y<=45 then
gameTittle:=0
cls
exit
end if
end loop


Pic.Draw(scaledPicID4,20,20,picCopy) %This picture is the one that won't stay






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




PostPosted: Fri Jan 13, 2017 10:35 am   Post subject: RE:My Image Will Not Stay On The Screen

I see you're using processes for your menus. This is a great way to give yourself a serious headache. Switch to procedures or functions to retain your sanity.

The issue is caused by your process. It loops forever and it has a cls in it, which means your program will wipe the screen arbitrarily every few seconds.
22




PostPosted: Sat Jan 14, 2017 12:52 pm   Post subject: Re: My Image Will Not Stay On The Screen

Wait so should I get rid of cls? I'm not too familiar with procedure or function, so I'm not sure how to use them or how they work, but if it's just a matter of cls, is there a substitute for cls that I could use?
Insectoid




PostPosted: Sat Jan 14, 2017 7:42 pm   Post subject: RE:My Image Will Not Stay On The Screen

No, it's not just a matter of cls. It's a matter of cls, inside a loop, in a process that potentially never ends.

The issue here is that processes let other code execute almost at the same time. You fork your welcome page, and then the rest of your code (the game itself) is executed simultaneously. I have a feeling that this isn't what you want.

A procedure is identical to a process except for one thing- it has to finish executing before any other code can run. It does not let other code run at the same time. You write them exactly the same, substituting 'procedure' for 'process'. When calling a procedure, you do not need the fork keyword. Instead of 'fork blah', just write 'blah'.

This should solve your problem.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: