Santa Drunk program, need help to fix this
Author |
Message |
universalswag
|
Posted: Wed Jan 16, 2013 2:44 pm Post subject: Santa Drunk program, need help to fix this |
|
|
What is it you are trying to achieve?
So our assignment is to make a christmas scene. I made a scene where everything is messed up, and put the caption "Go home Santa, You're drunk". However, when i try to put the snow ( Which i do not take credit for, teacher told us to take off internet), it does not sync with my stuff. Everything goes white.
What is the problem you are having?
I cannot get the snow to work in conjunction with my program. I have no idea. Project due soon. Any input is appreciated.
Describe what you have tried to solve this problem
I was tried putting snow in different paarts of my program. Tried cls, and View.Update.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
This is my program:
%ICS201
%Mrs. Mihaila,
%Peter Chen
%Summative
%****************WINTER SCENE*********************
View.Set ("graphics:max;max")
View.Set ("offscreenonly")
process bob
loop
for changingwindows : 0 .. 150
Draw.FillBox (494, 320, 753, 298, changingwindows ) %middle window
Draw.FillBox (531, 130, 722, 243, changingwindows ) %garage door
%Double Triangles ont top of pilars
Draw.Line (403, 344, 479, 344, changingwindows ) %Drawing bottom line of observation deck#1
Draw.Line (479, 344, 479, 412, changingwindows ) %Drawing right line of observation deck#1
Draw.Line (479, 412, 403, 344, changingwindows ) %Drawing left line of observation deck#1
Draw.Fill (457, 356, changingwindows, changingwindows ) %Filling in observation deck#1
Draw.Line (855, 344, 779, 344, changingwindows ) %Drawing bottom line of observation deck#2
Draw.Line (855, 344, 779, 412, changingwindows ) %Drawing right line of observation deck#2
Draw.Line (779, 412, 779, 344, changingwindows ) %Drawing left line of observation deck#2
Draw.Fill (800, 367, changingwindows, changingwindows ) %Filling in observation deck#2
delay (90)
View.Update
end for
end loop
end bob
fork bob
%Neptune
process mike
loop
for yolo : 62 .. 100
Draw.FillOval (123, 583, 70, 70, yolo ) %Neptune water
Draw.FillOval (93, 533, 20, 4, yolo + 10) %Clouds of neptune
Draw.FillOval (139, 549, 40, 5, yolo + 10) %" "
Draw.FillOval (126, 527, 10, 3, yolo + 10) %" "
Draw.FillOval (117, 569, 60, 7, yolo + 10) %" "
Draw.FillOval (98, 592, 40, 5, yolo + 10) %" "
Draw.FillOval (160, 610, 20, 4, yolo + 10) %" "
Draw.FillOval (116, 624, 10, 3, yolo + 10) %" "
Draw.FillOval (81, 609, 20, 4, yolo + 10) %" "
Draw.FillOval (128, 638, 20, 4, yolo + 10) %" "
delay (150)
View.Update
end for
end loop
end mike
fork mike
%Disco Craters
process joe
loop
for swag : 32 .. 51
Draw.FillOval (243, 50, 40, 20, swag ) %crater (hole)
Draw.FillOval (919, 98, 40, 20, swag ) %crater (hole2)
Draw.FillOval (770, 21, 50, 30, swag ) %crater (hole3)
Draw.FillOval (410, 95, 30, 10, swag ) %crater (hole4)
delay (100)
View.Update
end for
end loop
end joe
fork joe
%Around neptune
process orbrings
for rings : 75 .. 80
Draw.Oval (123, 583, rings, rings, yellow)
Draw.Oval (123, 583, rings + 5, rings + 5, yellow)
Draw.Oval (123, 583, rings + 10, rings + 10, yellow)
delay (50)
end for
end orbrings
fork orbrings
Draw.FillBox (0, 0, maxx, maxy, blue) %background
Draw.FillOval (653, - 600, 1000, 1000, grey) %The moon
Draw.Line (403, 344, 479, 344, white) %Drawing bottom line of observation deck#1
Draw.Line (479, 344, 479, 412, white) %Drawing right line of observation deck#1
Draw.Line (479, 412, 403, 344, white) %Drawing left line of observation deck#1
Draw.Fill (457, 356, white, white) %Filling in observation deck#1
Draw.Line (855, 344, 779, 344, white) %Drawing bottom line of observation deck#2
Draw.Line (855, 344, 779, 412, white) %Drawing right line of observation deck#2
Draw.Line (779, 412, 779, 344, white) %Drawing left line of observation deck#2
Draw.Fill (800, 367, white, white) %Filling in observation deck#2
Draw.FillBox (460, 354, 840, 150, black) %background of red building
%Pillars on both sides
Draw.FillBox (460, 354, 794, 130, black) %background of red building
Draw.FillBox (789, 126, 855, 344, black) %Pillar on right side
Draw.FillBox (466, 126, 402, 344, black) %Pillar on left side
Draw.FillBox (465, 132, 790, 350, red) %House unit
Draw.FillBox (528, 246, 724, 127, black) %background of garage door
Draw.FillBox (531, 130, 722, 243, white) %garage door
Draw.FillBox (491, 294, 758, 324, black) %background of window
Draw.FillBox (494, 320, 753, 298, yellow) %middle window
%High Flying Snoman
Draw.FillOval (864, 587, 20, 20, white)
Draw.FillOval (853, 592, 3, 3, black)
Draw.FillOval (870, 592, 3, 3, black)
Draw.FillOval (891, 556, 30, 30, white)
Draw.FillOval (921, 515, 40, 40, white)
Draw.FillOval (885, 561, 2, 2, black)
Draw.FillOval (892, 551, 2, 2, black)
Draw.FillOval (900, 541, 2, 2, black)
Draw.Line (861, 585, 841, 581, 41)
Draw.Line (860, 581, 861, 585, 41)
Draw.Line (860, 581, 841, 581, 41)
Draw.Fill (858, 582, 41, 41)
process fontmoving
for movingfont: 0.. 255
var font1: int
font1:= Font.New ("Arial:14")
Font.Draw ("Go Home Santa, You're Drunk!", 10, 3,font1,movingfont )
Font.Free (font1 )
View.Update
delay (50)
end for
end fontmoving
fork fontmoving
%Starsnstuff
process swagstar
loop
for yellows : 34 .. 67
drawfillstar (470, 560, 480, 570, yellows )
drawfillstar (225, 410, 235, 420, yellows )
drawfillstar (1170, 370, 1180, 380, yellows )
drawfillstar (970, 370, 980, 380, yellows )
drawfillstar (860, 510, 870, 520, yellows )
drawfillstar (400, 525, 410, 535, yellows )
drawfillstar (340, 555, 350, 565, yellows )
drawfillstar (280, 520, 290, 530, yellows )
drawfillstar (550, 585, 560, 595, yellows )
drawfillstar (530, 495, 540, 505, yellows )
drawfillstar (550, 585, 560, 595, yellows )
end for
end loop
end swagstar
fork swagstar
process yellowstar
loop
for yello : 14 .. 15
drawfillstar (600, 555, 610, 565, yello )
drawfillstar (424, 632, 434, 642, yello )
drawfillstar (325, 478, 335, 488, yello )
drawfillstar (580, 510, 590, 520, yello )
drawfillstar (690, 460, 700, 470, yello )
drawfillstar (686, 660, 696, 670, yello )
drawfillstar (145, 460, 155, 470, yello )
drawfillstar (88, 305, 98, 315, yello )
drawfillstar (730, 600, 740, 610, yello )
drawfillstar (860, 630, 870, 640, yello )
drawfillstar (860, 440, 870, 450, yello )
drawfillstar (985, 477, 995, 487, yello )
drawfillstar (1130, 590, 1140, 600, yello )
drawfillstar (1070, 500, 1080, 510, yello )
delay (50)
end for
end loop
end yellowstar
fork yellowstar
%Broken Tree
Draw.Line (286, 286, 256, 330, brown)
Draw.Line (319, 286, 286, 286, brown)
Draw.Line (292, 329, 319, 286, brown)
Draw.Line (256, 330, 292, 329, brown)
Draw.Fill (290, 311, brown,brown )
Draw.Line (315, 135, 334, 195, 49)
Draw.Line (315, 135, 296, 195, 49)
Draw.Line (334, 195, 296, 195, 49)
Draw.Fill (312, 174, 49, 49)
Draw.Line (318, 173, 275, 243, 49)
Draw.Line (318, 173, 350, 243, 49)
Draw.Line (275, 243, 350, 243, 49)
Draw.Fill (316, 229, 49, 49)
Draw.Line (310, 221, 256, 285, 49)
Draw.Line (310, 221, 356, 305, 49)
Draw.Line (356, 305, 256, 285, 49)
Draw.Fill (304, 273, 49, 49)
% A person
%Chest
Draw.Line (964, 284, 1002, 305, red)
Draw.Line (1002, 305, 1015, 267, red)
Draw.Line (992, 253, 964, 284, red)
Draw.Line (992, 253, 1015, 267, red)
Draw.Fill (991, 273, red,red )
drawfillstar (300, 120, 330, 150, yellow)
snow code:
type SnowType :
record
X, Y, Spd, Size : int%Define the integers
end record
var Snow : array 1 .. 200 of SnowType %Array
for rep : 1 .. 200 %For statement
Snow (rep ).X := Rand.Int (0, maxx)
Snow (rep ).Y := Rand.Int (0, maxy)
Snow (rep ).Spd := Rand.Int (1, 3)
Snow (rep ).Size := Snow (rep ).Spd
end for
loop%loops the screen
for rep : 1 .. 100
Snow (rep ).Y - = Snow (rep ).Spd
if Snow (rep ).Y < Snow (rep ).Size then%If statement
Snow (rep ).Y := Rand.Int (1000, 1000)
end if%Ends if statement
drawfilloval (Snow (rep ).X, Snow (rep ).Y, Snow (rep ).Size, Snow (rep ).Size, white)%generate the snow size
end for%End for process
View.Update%Update the screen
cls%Clear the screen
|
Please specify what version of Turing you are using
im Using the latest version of turing |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Wed Jan 16, 2013 3:48 pm Post subject: Re: Santa Drunk program, need help to fix this |
|
|
no kidding. You have 4~5 processes, all with their own View.Update going off randomly. What are the chances of them all happening at the right time?
code: |
for yolo : 62 .. 100
...
for swag : 32 .. 51
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
universalswag
|
Posted: Wed Jan 16, 2013 4:27 pm Post subject: Re: Santa Drunk program, need help to fix this |
|
|
so just one view.update, but where in the program should i be putting it?
EDIT:I changed it so that the snow is the only thing that is view.update. However, my program works but everything in a process is flashing, but not showing |
|
|
|
|
 |
Tony

|
Posted: Wed Jan 16, 2013 6:56 pm Post subject: RE:Santa Drunk program, need help to fix this |
|
|
That is the expected behavior of using processes. What you are doing is drawing random bits of your scene across all of those processes, and then pushing this random configuration to screen via View.Update. How much of each process has finished when View.Update gets called? There is no way to tell.
The unanimous suggestion here is to simply not use processes for drawing anything. There is no need for that. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
universalswag
|
Posted: Wed Jan 16, 2013 7:03 pm Post subject: Re: Santa Drunk program, need help to fix this |
|
|
Thanks a lot for being so responsive Tony. I think that not using processes would be cool. I'm gonna try it out.
-Thanks |
|
|
|
|
 |
universalswag
|
Posted: Wed Jan 16, 2013 7:18 pm Post subject: Re: Santa Drunk program, need help to fix this |
|
|
Once again. Another problem has arisen. When i try to make it without processes( all in one loop) the program doesnt work with two for statements in the same loop. How would i fix. Once again thanks :3. Not trying to make you do my homework, my homework is more or less done. |
|
|
|
|
 |
Tony

|
Posted: Wed Jan 16, 2013 7:22 pm Post subject: RE:Santa Drunk program, need help to fix this |
|
|
for-loops are type of loops... one would wait another the previous to finish.
The ideal approach is to think of animation as drawing frames. For-loops do just that -- count the step/frame number of the animation.
code: |
loop
step += 1
draw_step_number(step)
View.Update
end loop
|
the tricky part is mapping the global frame/step number to where inside of each individual for-loops it would have been. This is most easily accomplished with using mod |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
universalswag
|
Posted: Wed Jan 16, 2013 7:30 pm Post subject: Re: Santa Drunk program, need help to fix this |
|
|
probably a question a nooblord would ask but is it absolutely impossible to do with my processes? As an amateur, I really cant do things as fast, and redoing an assignment that was almost finished seems like a waste of time.
-thanks |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Wed Jan 16, 2013 8:01 pm Post subject: RE:Santa Drunk program, need help to fix this |
|
|
You could try to synchronize the processes so that they would wait for each other to finish, before doing the next step. Though that's arguably much more difficult and introduces all kinds of new challenges. Common example is a deadlock -- where all of the processes wait on each other to finish in a circle, so nothing happens. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
|
|