Computer Science Canada Police Car |
Author: | dabbuji [ Wed Jun 06, 2007 4:53 pm ] |
Post subject: | Police Car |
Hello people, I am drawing a police car for my project and i have to blink the police light. I have to blink the blue and the red light on the siren; so how would i do that ? How do i particularly blink 2 colors on the siren? |
Author: | crump3ts [ Wed Jun 06, 2007 7:31 pm ] |
Post subject: | Re: Police Car |
Assuming that you are going to use images, I would create a seperate image for each version of the police car: An image for the car with no blinkers on, an image for the red siren and an image for the blue, etc... Then display them so that it looks like the lights are flashing; draw the image of the car with the red light, then the blue light, then red, then blue, etc... As to how to animate it this way, it will take some work. |
Author: | DIIST [ Wed Jun 06, 2007 8:42 pm ] | ||
Post subject: | Re: Police Car | ||
Is this what you are talking about
I know, bad choice of variables, but im assuming you want something like this to occur with the lights right? Just use boolean variable to hold the value of true or false if one of the lights is on or off. |
Author: | dabbuji [ Sun Jun 10, 2007 10:15 am ] |
Post subject: | Re: Police Car |
ty man for the help, it works now |
Author: | dabbuji [ Sun Jun 10, 2007 10:22 am ] |
Post subject: | Re: Police Car |
yo, i made new dimensions for the siren so it fits on the police car, but the siren doesn't blink anymore and the car doesn't move as well. So help me out as my project is due tomorrow drawfillbox (0,0,maxx,maxy,black) var y1 : array 1 .. 8 of int := init (2,5,69,74,74,69,5,2) var y2 : array 1 .. 8 of int := init (305,312,312,305,276,269,269,276) drawfillpolygon (y1,y2,8,white) drawfillbox (21,304,55,278,blue) var y3 : array 1..8 of int := init (6,10,14,18,18,14,10,6) var y4 : array 1..8 of int := init (306,308,308,306,276,274,274,276) drawfillpolygon (y3,y4,8,black) var y6 : array 1..8 of int := init (58,62,66,70,70,66,62,58) var y5 : array 1..8 of int := init (306,308,308,306,276,274,274,276) drawfillpolygon (y6,y5,8,black) drawfillarc (76,281,2,4,0,360,yellow) drawfillarc (76,303,2,4,0,360,yellow) drawfillarc (4,303,2,4,0,360,red) drawfillarc (4,281,2,4,0,360,red) var redLight : boolean := false loop drawbox (31,313,45,291,7) drawbox (31,291,45,269,7) if redLight then drawfillbox (32,314,44,290,12) drawfillbox (32,292,44,268,1) else drawfillbox (32,314,44,290,12) drawfillbox (32,292,44,268,1) end if View.Update delay (100) redLight := not redLight end loop var cary: int cary := Pic.New (1,268,75,313) for car3move : 1..400 Pic.Draw (cary,car3move,268,picCopy) delay (5) end for |
Author: | jrblast [ Sun Jun 10, 2007 11:12 am ] |
Post subject: | RE:Police Car |
First of all, use the code tags when posting code. Second, the car doesn't move because you have an infinite loop before it (an infinite loop is one that will never exit either because there is no exit condition, or it can never be made true). Third, your draw colours in the else are wrong. DIIST had 4 and 9 which were working well, but you have then as 12 and 1... The same colours your using in the if part. Fourth, you are moving the car and flashing the siren seperately. You have to do them simoultaneously. Simple solution - move the flashing code into the for loop (get rid of the other loop) and find a way to make the siren change every few times the loop runs instead of every time. Btw, you will need to add car3move to the x value of the drawbox and drawfillboxes. Good luck |
Author: | dabbuji [ Sun Jun 10, 2007 12:00 pm ] |
Post subject: | Re: Police Car |
Ok the siren is blinking now, but i am unclear on your last part about the moving car as well as the blinking siren. My coordinates are already up there so can u paste that on your turing program and help fix the problem. |
Author: | DifinityRJ [ Sun Jun 10, 2007 3:29 pm ] |
Post subject: | Re: Police Car |
Take the X coord's and Y coord's for your siren and put them into variable(s), then fix that loop problem as explained before, and when your increasing your car's x position do the same to the siren's x position. Other possible ideas, get 2 pictures 1 of your car with the Red light, and the other with the blue light, and add a counter to change between them ( much easier for you ). |
Author: | dabbuji [ Mon Jun 11, 2007 6:52 am ] |
Post subject: | police car |
ohhh, ty man, it's finally working now. I moved both the car and the siren at the same time and removed the loop. |