Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics
Author |
Message |
Godess The Hyper Fangirl
|
Posted: Sat Apr 25, 2009 9:42 pm Post subject: Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
Alright, so I'm working on my summative assignment. What I want to do is have my stars blink, as well as the flames from the engine. However, the ship will be also going up. I don't know if I can achieve the flames blinking at the same time as the shop moving, however. That's a totally different issue. If no one can help me with that, or if it's not able to be done, that's fine.
The main problem I'm having is that I can get the oval to go up, but I can't get the rest of the components of the ship to go up. I've tried applying the same method I did with the ship to the rest of the components(using a 'for count' loop), however it either doesn't do anything or it doesn't do what I'd like it to do.
Here is what I have of the code, including the portions which don't work. I have tried several methods, such as putting the counts in different spots and changing coordinates but this is just where I left it. Please keep in mind that I'm only in a 10th grade Turing course, so when commenting keep in mind I may or may not be able to use certain things quite yet. ><
Turing: |
%Chapters 7 and 8 Summative Assignment
%"Space" Program
%This program depics a space shittle flying through space.
setscreen ("graphics")
%Make background black
drawfillbox (0, 0, maxx, maxy, black)
%Where the fire comes out
drawline (325, 130, 300, 50, yellow)
drawline (425, 130, 300, 50, yellow)
drawline (325, 130, 430, 130, yellow)
drawfill (375, 100, grey, yellow)
%The stars in the sky
loop
drawfillstar (23, 45, 67, 74, yellow)
drawfillstar (600, 250, 500, 300, yellow)
drawfillstar (150, 300, 50, 200, yellow)
delay (1000)
drawfillstar (23, 45, 67, 74, black)
drawfillstar (600, 250, 500, 300, black)
drawfillstar (150, 300, 50, 200, black)
delay (1000)
%Flames from the engine
drawline (maxx div 2, 0, 315, 50, brightred)
drawline (350, 0, 335, 50, yellow)
drawline (375, 0, 355, 50, brightred)
drawline (390, 0, 375, 50, yellow)
delay (1000)
drawline (maxx div 2, 0, 315, 50, black)
drawline (350, 0, 335, 50, black)
drawline (375, 0, 355, 50, black)
drawline (390, 0, 375, 50, black)
delay (1000)
%The shuttle
for count: 100 .. 600
drawfilloval (325, count, 75, 150, brightred)
delay (100)
drawfilloval (325, count, 75, 150 , black)
drawfillbox (400, count, 350, 300, yellow)
delay (100)
drawfillbox (400, count, 350, 300, brightred)
drawfillbox (275, count, 325, 340, yellow)
delay(100)
drawfillbox (275, count, 325, 340, brightred)
drawfillarc (420, 250, 50, 50, 0, 50, brightblue)
delay(10)
drawfillarc (420, count, 50, 50, 0, 50, black)
drawfillarc (175, 250, 50, 50, 0, 50, brightblue)
delay(10)
drawfillarc (175, count, 50, 50, 0, 50, black)
end for
end loop
|
Unfortunately, I don't know which version of Turing we use. If it's extremely important, I can let you know on Monday when I have my class. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Euphoracle
|
Posted: Sat Apr 25, 2009 11:12 pm Post subject: RE:Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
I have no idea what you're trying to do with that code. Have they taught you nothing? |
|
|
|
|
|
Tony
|
Posted: Sun Apr 26, 2009 12:57 am Post subject: RE:Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
animation comes down to a frame loop
Turing: |
for frame : 1 .. 1000
draw (frame )
delay(some_delay )
end for
|
where 1000 is the number of frames in your full animation (~33 seconds at 30 FPS); some_delay is a delay required to set the FPS (technically this should be Delay.SinceLast, but delay should do for simple animations), and draw is a procedure that draws a particular frame. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Godess The Hyper Fangirl
|
Posted: Sun Apr 26, 2009 6:34 pm Post subject: Re: RE:Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
Tony @ Sun Apr 26, 2009 12:57 am wrote: animation comes down to a frame loop
Turing: |
for frame : 1 .. 1000
draw (frame )
delay(some_delay )
end for
|
where 1000 is the number of frames in your full animation (~33 seconds at 30 FPS); some_delay is a delay required to set the FPS (technically this should be Delay.SinceLast, but delay should do for simple animations), and draw is a procedure that draws a particular frame. I have absolutely no idea what this is, so I have a feeling I shouldn't be using it ^^;; We've been taught right now to have it in a for loop, and then re-draw the item in the colour of the background or whatever it happens to be on. It says right in the textbook(just showing you so you know what we've been doing):
"The effect of the animation can be achieved with the Pow program by erasing each circle after a delay before plotting the next circle. To erase a circle you can re-plot it using the background colour, number 0. The predefined procedure delay can be called to waste time between the plot of each circle in magenta and the plot of the same circle in black."
You can see where I've done this in the portion with the stars. There, it will blink. The same can be applied to the shuttle, except you need to use 'for count' so that way the y-coordinate will change and appear to go upward. However, when I try to use that method with the drawfillbox, drawarc, and drawline it doesn't seem to work. We may learn that way, but we haven't yet. The teacher approved my design, so it must be able to be done this way. Your way is probably easier, but I don't want to get it wrong simply because I used things that weren't in the chapter. |
|
|
|
|
|
saltpro15
|
Posted: Sun Apr 26, 2009 8:09 pm Post subject: RE:Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
Quote: This program depics a space shittle flying through space.
hehehe
your code makes no sense btw |
|
|
|
|
|
Godess The Hyper Fangirl
|
Posted: Mon Apr 27, 2009 10:46 am Post subject: Re: RE:Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
saltpro15 @ Sun Apr 26, 2009 8:09 pm wrote: Quote: This program depics a space shittle flying through space.
hehehe
your code makes no sense btw Whoops, that was an interesting typo.
And you're the second person to say that, so perhaps you could tell me how it makes no sense? That could help me find the problem. |
|
|
|
|
|
DifinityRJ
|
Posted: Mon Apr 27, 2009 11:06 am Post subject: Re: Summative Assignment Assistance - Basic Animation w/ Basic Pixel Graphics |
|
|
Turing: |
var shuttle_x, shuttle_y : int
var starcounter, flamecounter : int := 0
%"Space" Program
%This program depics a space shittle flying through space.
setscreen ("graphics,offscreenonly")
shuttle_x := 325
shuttle_y := 130
proc drawstars
starcounter + = 1
% stars
if starcounter >= 0 and starcounter <= 25 then
drawfillstar (23, 45, 67, 74, black)
drawfillstar (600, 250, 500, 300, black)
drawfillstar (150, 300, 50, 200, black)
drawfillstar (23, 45, 67, 74, yellow)
drawfillstar (600, 250, 500, 300, yellow)
drawfillstar (150, 300, 50, 200, yellow)
end if
if starcounter > 50 then
starcounter := 0
end if
end drawstars
proc drawshuttle
% shuttle
drawline (shuttle_x, shuttle_y, shuttle_x - 25, shuttle_y - 80, yellow)
drawline (shuttle_x + 100, shuttle_y + 2, shuttle_x - 25, shuttle_y - 80, yellow)
drawline (shuttle_x, shuttle_y, shuttle_x + 95, shuttle_y, yellow)
flamecounter + = 1
% flames
if flamecounter >= 0 and flamecounter <= 10 then % if the flamecounter is between that range, it will draw the flames, if it isn't it won't draw it
drawline (shuttle_x, shuttle_y - 130, shuttle_x - 10, shuttle_y - 80, brightred)
drawline (shuttle_x + 25, shuttle_y - 130, shuttle_x + 10, shuttle_y - 80, yellow)
drawline (shuttle_x + 50, shuttle_y - 130, shuttle_x + 30, shuttle_y - 80, brightred)
drawline (shuttle_x + 65, shuttle_y - 130, shuttle_x + 50, shuttle_y - 80, yellow)
end if
if flamecounter > 20 then
flamecounter := 0
end if
end drawshuttle
proc moveshuttle
% moves the shuttle
shuttle_x - = 1
shuttle_y + = 1
end moveshuttle
loop
cls % clears the screen so the new frame gets drawn.
colorback (black) % sets the background to black, don't use drawfillbox to make the background black...
drawstars
drawshuttle
moveshuttle
View.Update
delay (10)
end loop
|
You need to keep track of your shuttle's x position and y position in order to move the shuttle and the flames.
shuttle_x is for the x-position
shuttle_y is for the y-position
Use those variables when drawing, and that way you can track of its position and draw the flames below the shuttle by subtracting whatever amount is needed.
For blinking, you can use something as simple as a 'counter'
There is a tutorial on that in the tutorial section, but I think its self-explanatory.
counters work by adding any amount (for example '1') to a variable such as 'starcounter'. Every time it loops, it adds 1 to that variable, and you can set up an if-statement saying:
if counter is between 0 and 20 then
draw whatever
end if
Good luck. |
|
|
|
|
|
|
|