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

Username:   Password: 
 RegisterRegister   
 Need Help Asap
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ghostblade




PostPosted: Tue May 07, 2013 12:13 pm   Post subject: Need Help Asap

What is it you are trying to achieve?
trying to make my process work


What is the problem you are having?
it says it finishes execution but doesn't do anything!

Describe what you have tried to solve this problem
tried to add and remove variables, tried to put it in a separate program


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



Turing:


setscreen("graphics:max;max")
setscreen ("offscreenonly")

%Boat Variables
var movingboat : int := 0
var movingboat2 : int := 1
var motorboat : int := Pic.FileNew ("motor boat.bmp")


proc boat
    movingboat := movingboat + movingboat2
    Pic.Draw (motorboat, 940 - movingboat, 295, picMerge)
    drawline (1020 - movingboat, 305, 1040 - movingboat, 305, black)
    drawfillbox (1040 - movingboat, 295, 1260 - movingboat, 320, white)
    if movingboat = 1350 then
        movingboat := 0

        end if
end boat>



Please specify what version of Turing you are using
not sure lol i guess the latest JUST NEED HELP please fix it for me step by step so i can learn from my mistakes!
Sponsor
Sponsor
Sponsor
sponsor
Nathan4102




PostPosted: Tue May 07, 2013 12:47 pm   Post subject: RE:Need Help Asap

You need to call your process, simply creating it doesn't actually execute anything.
mirhagk




PostPosted: Tue May 07, 2013 1:06 pm   Post subject: RE:Need Help Asap

The relevant term you want to look up in the help docs (you can use them from this site if your version doesn't have them working) is FORK.

btw to check your version in Turing (as well as nearly any program) go to help, then about. We don't necessarily need it for this question, but it's handy to have for questions.
Tony




PostPosted: Tue May 07, 2013 3:43 pm   Post subject: Re: Need Help Asap

Ghostblade @ Tue May 07, 2013 12:13 pm wrote:
please fix it for me step by step so i can learn from my mistakes!

There is no learning from copying answers though. There _is_ learning if you are fixing those mistakes yourself (though our guidance could be beneficial here).

Among other problems, it would help you if you can explain how
code:

setscreen ("offscreenonly")

in your code works.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Ghostblade




PostPosted: Wed May 08, 2013 1:10 pm   Post subject: RE:Need Help Asap

not sure i just added that hoping it would fix something but it didnt work out and btw what do you mean by "calling my process" nathan, im new to turing.
Nathan4102




PostPosted: Wed May 08, 2013 1:15 pm   Post subject: RE:Need Help Asap

The same way you call a proceudre,
Turing:
procedure Hello
    put "hello!"
end Hello

Hello


However when you're using processed, use fork like tony said. There's some info on fork here.
http://compsci.ca/holtsoft/doc/fork.html
Ghostblade




PostPosted: Wed May 08, 2013 1:57 pm   Post subject: RE:Need Help Asap

ok i found an easier way,


setscreen("graphics:max;max")

%BOAT MOVING%
var posy1 :int:=400
var posx2 : int:= 400
loop
var motorboat : int := Pic.FileNew ("motor boat.bmp")
Pic.Draw (motorboat,posx2,posy1,picMerge )
posx2 := posx2-1
delay (100)
cls
end loop

the problem is when i import an image as my background now... it covers the boat and you cant see it, how do i fix this?
andrew.




PostPosted: Wed May 08, 2013 2:43 pm   Post subject: RE:Need Help Asap

Well if you look at the code, you'll notice that Turing executes each line of code in order. So think about what would happen if you did this:
Turing:
Pic.Draw(motorboat, x, y, picMerge)
Pic.Draw(background, x, y, picMerge)


as opposed to this:
Turing:
Pic.Draw(background, x, y, picMerge)
Pic.Draw(motorboat, x, y, picMerge)
Sponsor
Sponsor
Sponsor
sponsor
Ghostblade




PostPosted: Thu May 09, 2013 11:40 am   Post subject: RE:Need Help Asap

Not working Sad its still not showing


%############Loading Screen#############%
var loadPercent : int := 0
var loadingMessage : string := ""


proc load1 ()
loadingMessage := "Loading Screen"
delay (100)
loadPercent += 10
end load1

proc load2 ()
loadingMessage := "Loading Objects"
delay (150)
loadPercent += 15
end load2

proc load3 ()
loadingMessage := "Loading Animations"
delay (200)
loadPercent += 50
end load3

proc load4 ()
loadingMessage := "Loading Pure Awesomeness"
delay (250)
loadPercent += 25
end load4


process loadGameProcess ()
load1 ()
load2 ()
load3 ()
load4 ()
loadingMessage := "DONE"
end loadGameProcess


proc loadGame ()
fork loadGameProcess

% Display Loading Bar
var loadingPercentFont : int := Font.New ("sans serif:16:bold")
var loadingMessageFont : int := Font.New ("sans serif:24:bold")

loop
View.Update ()
Time.DelaySinceLast (100)
Draw.Cls

Font.Draw ( loadingMessage, 30, maxy div 2 + 40, loadingMessageFont, black )

% The actual bar and the percentage listed for it
Draw.FillBox (0, maxy div 2 + 15, maxx, maxy div 2 + 20, black )
Draw.FillBox (0, maxy div 2 - 15, maxx, maxy div 2 - 20, black )
Draw.FillBox (0, maxy div 2 - 15, round (maxx / 100 * loadPercent), maxy div 2 + 15, darkgrey)
Font.Draw ( intstr(loadPercent)+"%", maxx div 2 - 8, maxy div 2 - 8, loadingPercentFont, brightred )

exit when loadPercent >= 100
end loop


end loadGame


View.Set ("offscreenonly")
loadGame ()


%#################BACKGROUND################%
setscreen("graphics:max;max")
var font4 : int
var motorboat : int := Pic.FileNew ("motor boat.bmp")
var beach := Pic.FileNew ("beach.jpeg")
Pic.Draw (beach, 1, 50, picMerge)

%SUMMER SCENE WORDS%
font4 :=Font.New ("Arial:35:Italic")
Font.Draw ("SUMMER SCENE", 20, 600, font4, 7)

font4 :=Font.New ("Arial:20:Italic")
Font.Draw ("By: MOHAMMED ALCHAER", 20, 50, font4, 7)


%BOAT MOVING%

process Boat
var posy1 :int:=200
var posx2 : int:= 200
Pic.Draw (motorboat,posx2,posy1,picMerge )

loop

posx2 := posx2-1
delay (100)
cls
end loop
end Boat

That is my entire code it works but only the boat doesnt show up??!!!?? Sad((
Nathan4102




PostPosted: Thu May 09, 2013 12:47 pm   Post subject: RE:Need Help Asap

In your infinite loop, you change the coords, but never draw the boat. Also look into formatting your code a bit better. Give everything it's own procedure, and then your main loop will consist of procedure calls, much easier to read.
Ghostblade




PostPosted: Fri May 10, 2013 12:58 pm   Post subject: RE:Need Help Asap

ok i got everything to work but one final problem ive encountered, my program ends too quickly and it flickers a bit. i want my boat to reach the end but it just ends expectantly Sad



%############Loading Screen#############%
var loadPercent : int := 0
var loadingMessage : string := ""


proc load1 ()
loadingMessage := "Loading Screen"
delay (1000)
loadPercent += 10
end load1

proc load2 ()
loadingMessage := "Loading Objects"
delay (1500)
loadPercent += 15
end load2

proc load3 ()
loadingMessage := "Loading Animations"
delay (2000)
loadPercent += 50
end load3

proc load4 ()
loadingMessage := "Loading Pure Awesomeness"
delay (2500)
loadPercent += 25
end load4


process loadGameProcess ()
load1 ()
load2 ()
load3 ()
load4 ()
loadingMessage := "DONE"
end loadGameProcess


proc loadGame ()
fork loadGameProcess

% Display Loading Bar
var loadingPercentFont : int := Font.New ("sans serif:16:bold")
var loadingMessageFont : int := Font.New ("sans serif:24:bold")

loop
View.Update ()
Time.DelaySinceLast (100)
Draw.Cls

Font.Draw ( loadingMessage, 30, maxy div 2 + 40, loadingMessageFont, black )

% The actual bar and the percentage listed for it
Draw.FillBox (0, maxy div 2 + 15, maxx, maxy div 2 + 20, black )
Draw.FillBox (0, maxy div 2 - 15, maxx, maxy div 2 - 20, black )
Draw.FillBox (0, maxy div 2 - 15, round (maxx / 100 * loadPercent), maxy div 2 + 15, darkgrey)
Font.Draw ( intstr(loadPercent)+"%", maxx div 2 - 8, maxy div 2 - 8, loadingPercentFont, brightred )

exit when loadPercent >= 100
end loop


end loadGame


loadGame


%####SETSCREEN###%
setscreen("graphics:max;max")


%#######BOAT MOVING + BACKGROUND#######%
var posy1 :int:=200
var posx2 : int:= 400

loop
var motorboat : int := Pic.FileNew ("motor boat.bmp")
Pic.Draw (motorboat,posx2,posy1,picMerge )
posx2 := posx2-1
delay (1)
var beach := Pic.FileNew ("beach.jpeg")
Pic.Draw (beach, 1, 50, picMerge)
end loop
cls
Nathan4102




PostPosted: Fri May 10, 2013 1:09 pm   Post subject: RE:Need Help Asap

For the flickering, look into setscreen("offscreenonly") and View.Update. Try to declare all your variables at the top of the program, and NEVER declare them inside a loop, unless theres a reason you need to. What you're doing is loading the boat image every time the boat moves a pixel, which isn't needed.

Your cls should be inside the loop aswell, because you want to clear the screen every frame, not after all your frames have been drawn.
Ghostblade




PostPosted: Fri May 10, 2013 1:32 pm   Post subject: RE:Need Help Asap

offscreenonly makes my whole screen white so its no good and it flickers like crazy when i put the cls inside the loop as for putting the var outside the loop, nothing changes it still ends randomly... ?
view.update isnt changing anything as i can see though.
Nathan4102




PostPosted: Fri May 10, 2013 1:38 pm   Post subject: RE:Need Help Asap

You can't just call View.Set("offscreenonly") and expect it to solve all your problems. Read the "offscreenonly" section of http://compsci.ca/holtsoft/doc/view_set.html, it explains how to fix your flickering problem.

The variable thing isn't to fix your flickering, its to save memory. If you run that thing long enough, I'm pretty sure you'll fill all your RAM with those two images.
Ghostblade




PostPosted: Fri May 10, 2013 1:41 pm   Post subject: RE:Need Help Asap

the link isnt working?
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: