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

Username:   Password: 
 RegisterRegister   
 Flickering Castle
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
skyler




PostPosted: Mon May 22, 2006 10:27 am   Post subject: Flickering Castle

hi, i'm designing a program and i have a castle that is flickering when the an object is moved above it, is there any way to prevent that . THANK YOU and here is the code.
code:

setscreen ("graphics:640,480")
setscreen ("graphics:v256")

%ROCKET
for rocket:0..420
drawfilloval(490,500-rocket,10,10,brightred)
drawoval(490,500-rocket,10,10,254)
drawfillbox(480,500-rocket,500,540-rocket,0)
drawbox(480,500-rocket,500,540-rocket,254)
drawfillbox(480,535-rocket,500,540-rocket,brightred)
drawbox(480,535-rocket,500,540-rocket,254)
delay(10)

%CASTLE
%Drawing the bigger castle behind the gate:
drawfillbox (380, 330, 610, 400, 26)
drawfillbox (380, 400, 460, 450, 26)
drawfillbox (380, 450, 400, 470, 26)
drawfillbox (410, 450, 430, 470, 26)
drawfillbox (440, 450, 460, 470, 26)
drawfillbox (530, 400, 610, 450, 26)
drawfillbox (530, 450, 550, 470, 26)
drawfillbox (560, 450, 580, 470, 26)
drawfillbox (590, 450, 610, 470, 26)

%Right side:
var xa : array 1 .. 4 of int := init (590, 590, 610, 610)
var ya : array 1 .. 4 of int := init (230, 340, 330, 235)
Draw.FillPolygon (xa, ya, 4, 8)
var xb : array 1 .. 4 of int := init (590, 590, 610, 610)
var yb : array 1 .. 4 of int := init (230, 340, 330, 235)
Draw.Polygon (xb, yb, 4, black)

%The front of the castle:
drawfillbox (400, 230, 590, 340, 8)
drawbox (400, 230, 590, 340, black)

%The left side:
var xc : array 1 .. 4 of int := init (380, 380, 400, 400)
var yc : array 1 .. 4 of int := init (330, 235, 230, 340)
drawfillpolygon (xc, yc, 4, 8)
var xd : array 1 .. 4 of int := init (380, 380, 400, 400)
var yd : array 1 .. 4 of int := init (330, 235, 230, 340)
drawpolygon (xd, yd, 4, black)

%Drawing two towers on the castle:
drawfillbox (420, 340, 460, 410, 30)
drawbox (420, 340, 460, 410, black)
drawfillbox (530, 340, 570, 410, 30)
drawbox (530, 340, 570, 410, black)

%Drawing two roofs over the towers:
var xe : array 1 .. 3 of int := init (410, 440, 470)
var ye : array 1 .. 3 of int := init (410, 425, 410)
drawfillpolygon (xe, ye, 3, red)
var xf : array 1 .. 3 of int := init (410, 440, 470)
var yf : array 1 .. 3 of int := init (410, 425, 410)
drawpolygon (xf, yf, 3, black)
var xg : array 1 .. 3 of int := init (520, 550, 580)
var yg : array 1 .. 3 of int := init (410, 425, 410)
drawfillpolygon (xg, yg, 3, red)
var xh : array 1 .. 3 of int := init (520, 550, 580)
var yh : array 1 .. 3 of int := init (410, 425, 410)
drawpolygon (xh, yh, 3, black)

%The bricks over the castle:
drawfillbox (400, 340, 430, 360, 8)
drawbox (400, 340, 430, 360, black)
drawfillbox (440, 340, 470, 360, 8)
drawbox (440, 340, 470, 360, black)
drawfillbox (480, 340, 510, 360, 8)
drawbox (480, 340, 510, 360, black)
drawfillbox (520, 340, 550, 360, 8)
drawbox (520, 340, 550, 360, black)
drawfillbox (560, 340, 590, 360, 8)
drawbox (560, 340, 590, 360, black)

var xi : array 1 .. 4 of int := init (595, 595, 610, 610)
var yi : array 1 .. 4 of int := init (338, 360, 350, 330)
drawfillpolygon (xi, yi, 4, 8)
var xj : array 1 .. 4 of int := init (595, 595, 610, 610)
var yj : array 1 .. 4 of int := init (338, 360, 350, 330)
drawpolygon (xj, yj, 4, black)

var xk : array 1 .. 4 of int := init (380, 380, 395, 395)
var yk : array 1 .. 4 of int := init (331, 352, 360, 339)
drawfillpolygon (xk, yk, 4, 8)
var xl : array 1 .. 4 of int := init (380, 380, 395, 395)
var yl : array 1 .. 4 of int := init (330, 352, 360, 338)
drawpolygon (xl, yl, 4, black)

%Drawing windows on the castle:
drawfillarc (425, 301, 20, 25, 360, 180, 56)
drawarc (425, 300, 20, 25, 360, 180, black)
drawline (405, 301, 445, 301, black)
drawfillarc (560, 301, 20, 25, 360, 180, 56)
drawarc (560, 300, 20, 25, 360, 180, black)
drawline (540, 301, 580, 301, black)

%Drawing windows on the towers:
drawfillarc (440, 390, 10, 13, 360, 180, 56)
drawarc (440, 390, 10, 13, 360, 180, black)
drawfillbox (430, 380, 450, 390, 56)
drawbox (430, 380, 450, 390, black)
drawfillarc (550, 390, 10, 13, 360, 180, 56)
drawarc (550, 390, 10, 13, 360, 180, black)
drawfillbox (540, 380, 560, 390, 56)
drawbox (540, 380, 560, 390, black)

%CASTLE GATE
%Purple part of the gate:
drawfillarc (490, 280, 50, 35, 360, 180, 128)
drawarc (490, 280, 50, 35, 360, 180, black)
drawfillbox (440, 230, 540, 280, 128)
drawbox (440, 230, 540, 280, black)

%Lines on the gate:
drawbox (440, 230, 540, 235, black)
drawbox (440, 230, 540, 240, black)
drawbox (440, 230, 540, 245, black)
drawbox (440, 230, 540, 250, black)
drawbox (440, 230, 540, 255, black)
drawbox (440, 230, 540, 260, black)
drawbox (440, 230, 540, 265, black)
drawbox (440, 230, 540, 270, black)
drawbox (440, 230, 540, 275, black)
drawbox (440, 230, 540, 280, black)
drawline (441, 285, 539, 285, black)
drawline (442, 290, 538, 290, black)
drawline (445, 295, 535, 295, black)
drawline (448, 300, 532, 300, black)
drawline (455, 305, 526, 305, black)
drawline (463, 310, 517, 310, black)

%Inside the gate:
drawfillbox (450, 230, 530, 280, 149)
drawbox (450, 230, 530, 280, black)
drawfillarc (490, 280, 40, 25, 360, 180, 149)
drawarc (490, 280, 40, 25, 360, 180, black)

%The bars on the gate:
drawline (460, 230, 460, 297, black)
drawline (470, 230, 470, 301, black)
drawline (480, 230, 480, 305, black)
drawline (490, 230, 490, 305, black)
drawline (500, 230, 500, 305, black)
drawline (510, 230, 510, 301, black)
drawline (520, 230, 520, 297, black)
drawline (450, 280, 530, 280, black)

end for

%EXPLOSION
drawfillarc(480,30,160,120,360,180,66)
drawfillarc(480,30,80,60,360,180,68)
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Mon May 22, 2006 10:33 am   Post subject: (No subject)

sure there is,
set the screen to "offscreenonly"
setscreen ("offscreenonly") (with quotes)
and put "View.Update", before you end the loop Smile (without quotes)
skyler




PostPosted: Mon May 22, 2006 11:32 am   Post subject: (No subject)

Thank you MysticVegeta for ur help , but what if i have more than one object moving, one after the other , and each object ends with "end for" statement , can i still use what you mentioned.
Cervantes




PostPosted: Mon May 22, 2006 11:42 am   Post subject: (No subject)

You can use as many View.Update's as you want. However, you should not use more than one View.Update per (for) loop. In this case, you're alright, since the movement of your 'objects' are each within their own for loops.
skyler




PostPosted: Mon May 22, 2006 12:05 pm   Post subject: (No subject)

Thank you Cervantes for ur reply, now i did that, i got another problem, every time i run the program , some objects which r not moving , r supposed to appear at the end but they dont until you click outside the window i.e: on the desktop here is the code. i uploaded the program , please choose the 2nd choice to see what i'm talking about. THANK YOU VERY MUCH.


ccc.t
 Description:

Download
 Filename:  ccc.t
 Filesize:  60.84 KB
 Downloaded:  76 Time(s)

Cervantes




PostPosted: Mon May 22, 2006 1:19 pm   Post subject: (No subject)

skyler wrote:
every time i run the program , some objects which r not moving , r supposed to appear at the end but they dont until you click outside the window i.e: on the desktop

That's probably a missing View.Update. When a Turing program is finished executing and if the Turing run window becomes inactive [minimized, another window is selected...] (or something like that), the backbuffer is copied to the frontbuffer. That is, a View.Update automatically occurs at the end of the program. If you insert your own View.Update just before the end of the program, this problem should be solved.
skyler




PostPosted: Mon May 22, 2006 9:19 pm   Post subject: (No subject)

hi Cervantes, thank you for ur help , but i really got confused , so if you dont mind can u help me figure out where to put the View.Update in the program that i attached please , i really need ur help because i have to present the program tomorrow for the teacher, i'd be really grateful if u just tell me the place where it needs the View.Update in the program to prevent the problem i have. THANK YOU.
skyler




PostPosted: Mon May 22, 2006 9:24 pm   Post subject: (No subject)

Cervantes never mind my last reply, i figured out how to do it , of course with your great help , and i guess i'll get a good mark hopefully. THANK YOU
Sponsor
Sponsor
Sponsor
sponsor
skyler




PostPosted: Mon May 22, 2006 9:54 pm   Post subject: (No subject)

by the way do you know why the truck in the following program is flickering ????????
even though i used View.Update but it didn't solve the problem , can you help me with that.
thank you.

code:

setscreen ("graphics:640,480")
setscreen ("graphics:v256")


for move : 0 .. 250

    drawfillbox (640 - move, 100, 810 - move, 130, 127)
    drawbox (640 - move, 100, 810 - move, 130, 254)
    drawfillbox (680 - move, 130, 750 - move, 160, 127)

    %Moving the tires:
    drawfilloval (675 - move, 65, 40, 40, 26)
    drawoval (675 - move, 65, 40, 40, 254)
    drawfilloval (675 - move, 65, 20, 20, gray)
    drawoval (675 - move, 65, 20, 20, 254)

    drawfilloval (775 - move, 65, 40, 40, 26)
    drawoval (775 - move, 65, 40, 40, 254)
    drawfilloval (775 - move, 65, 20, 20, gray)
    drawoval (775 - move, 65, 20, 20, 254)

    %Moving the windows:
    drawfillbox (680 - move, 131, 730 - move, 155, 100)

    %Moving the front lights:
    drawfillbox (640 - move, 119, 660 - move, 128, 11)
    drawbox (640 - move, 119, 660 - move, 128, 254)
    drawfillbox (640 - move, 121, 658 - move, 126, gray)
    drawbox (640 - move, 121, 658 - move, 126, 254)
    drawfilloval (646 - move, 110, 4, 4, yellow)
    drawoval (646 - move, 110, 4, 4, 254)

    %Moving the back lights:
    drawfillbox (803 - move, 115, 810 - move, 130, brightred)
    drawbox (803 - move, 115, 810 - move, 130, 254)

    delay (10)

    %COVERING
    %Truck Body:
    drawfillbox (640 - move, 100, 810 - move, 130, 91)
    drawbox (640 - move, 100, 810 - move, 130, 91)
    drawfillbox (680 - move, 130, 750 - move, 160, 91)

    %Tires:
    drawfilloval (675 - move, 65, 40, 40, 91)
    drawoval (675 - move, 65, 40, 40, 91)
    drawfilloval (675 - move, 65, 20, 20, 91)
    drawoval (675 - move, 65, 20, 20, 91)

    drawfilloval (775 - move, 65, 40, 40, 91)
    drawoval (775 - move, 65, 40, 40, 91)
    drawfilloval (775 - move, 65, 20, 20, 91)
    drawoval (775 - move, 65, 20, 20, 91)


    %Path:
    var x222 : array 1 .. 4 of int := init (300, 370, 470, 490)
    var y222 : array 1 .. 4 of int := init (0, 80, 80, 0)
    drawfillpolygon (x222, y222, 4, 90)
    var x223 : array 1 .. 4 of int := init (370, 400, 490, 470)
    var y223 : array 1 .. 4 of int := init (80, 160, 160, 80)
    drawfillpolygon (x223, y223, 4, 90)

    %REDRAWING STATIONARY CRAB:
    %Body:
    drawfilloval (413, 50, 11, 10, 222)

    %Eyes:
    drawfilloval (415, 45, 1, 1, yellow)
    drawfilloval (421, 48, 1, 1, yellow)

    %Legs:
    drawline (397, 44, 401, 48, blue)
    drawline (400, 40, 397, 44, blue)

    drawline (400, 42, 405, 46, blue)
    drawline (404, 38, 400, 42, blue)

    drawline (422, 57, 428, 57, blue)
    drawline (428, 57, 427, 52, blue)

    drawline (424, 53, 431, 52, blue)
    drawline (431, 52, 428, 47, blue)

    drawarc (415, 40, 6, 5, 150, 270, blue)
    drawarc (425, 43, 6, 5, -45, -270, blue)

    View.Update
end for

%DRAWING STATIONARY TRUCK
%Body:
drawfillbox (390, 100, 560, 130, 127)
drawbox (390, 100, 560, 130, 254)
drawfillbox (430, 130, 500, 160, 127)

%Tires:
drawfilloval (425, 65, 40, 40, 26)
drawoval (425, 65, 40, 40, 254)
drawfilloval (425, 65, 20, 20, gray)
drawoval (425, 65, 20, 20, 254)

drawfilloval (525, 65, 40, 40, 26)
drawoval (525, 65, 40, 40, 254)
drawfilloval (525, 65, 20, 20, gray)
drawoval (525, 65, 20, 20, 254)

%Windows on the truck:
drawfillbox (430, 131, 480, 155, 100)

%Front lights:
drawfillbox (390, 119, 410, 128, 11)
drawbox (390, 119, 410, 128, 254)
drawfillbox (390, 121, 408, 126, gray)
drawbox (390, 121, 408, 126, 254)

drawfilloval (396, 110, 4, 4, yellow)
drawoval (396, 110, 4, 4, 254)

%Back lights:
drawfillbox (553, 115, 560, 130, brightred)
drawbox (553, 115, 560, 130, 254)
MysticVegeta




PostPosted: Mon May 22, 2006 10:08 pm   Post subject: (No subject)

ok first of all you dont need the crab and path (which are constants, meaning have nothing to do with the loop counter) inside the loop, just remove them from the loop.

Second: you put View.Update below the delay(10) instead the end.

Third: you should have setscreen("offscreenonly")
skyler




PostPosted: Mon May 22, 2006 10:23 pm   Post subject: (No subject)

WOW , thank alot that really made my program alot smoother , i dont know what to say but u guys are geniuses and this is the best forum ever. THANK YOU
MysticVegeta




PostPosted: Mon May 22, 2006 10:36 pm   Post subject: (No subject)

If you are wondering that View.Update makes the truck go slower then you could just put "by 5" or whatever #, "by 6", "by 7", etc, eg:
"for move : 0 .. 250 by x" where x is any natural #. what that does is that it makes the loop goes by x, ok that didnt make sense. like if x is 5 then the loop will go
0
5
10
15
20
etc.

if 6 then
0
6
12
18
etc.

that makes the truck move faster since move is incrementing faster.
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  [ 12 Posts ]
Jump to:   


Style:  
Search: