ANimation with stairs
Author |
Message |
enimirahi
|
Posted: Sun Apr 19, 2009 4:22 pm Post subject: ANimation with stairs |
|
|
Hey how do i make these stairs even so they all look the same and follow the same patter cuz some of my stairs are bigger then others
Turing: | Draw.Line (0, 320, 66, 320, blue)
Draw.Line (65, 320, 65, 220, blue)
Draw.Line (66, 220, 200, 220, blue)
Draw.Line (199, 220, 199, 100, blue)
Draw.Line (200, 100, 340, 100, blue)
Draw.Line (339, 44, 339, 100, blue)
Draw.Line (200, 100, 340, 100, blue)
Draw.Line (44, 400, 44, 400, blue)
Draw.Line (390, 44, 340, 44, blue)
Draw.Line (390, 44, 390, 0, blue) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Sun Apr 19, 2009 5:17 pm Post subject: RE:ANimation with stairs |
|
|
that would be because there are different values between your x1 and x2, i suggest making your life easier and doing something like
in a pattern like that, it'll eliminate a lot of headaches |
|
|
|
|
![](images/spacer.gif) |
enimirahi
|
Posted: Sun Apr 19, 2009 5:33 pm Post subject: RE:ANimation with stairs |
|
|
ok thnx |
|
|
|
|
![](images/spacer.gif) |
enimirahi
|
Posted: Sun Apr 19, 2009 6:01 pm Post subject: RE:ANimation with stairs |
|
|
so i did the stairs but how do I make the ball bounce down those stairs cuz i thought it was like the bottem code but it doesn't work plz its due tommorow this thing
Turing: | %Stairs
Draw.Line (50, 0, 50, 50, 1)
Draw.Line (50, 50, 100, 50, 1)
Draw.Line (100, 50, 100, 100, 1)
Draw.Line (100, 100, 150, 100, 1)
Draw.Line (150, 150, 150, 100, 1)
Draw.Line (200, 150, 150, 150, 1)
Draw.Line (200, 200, 200, 150, 1)
Draw.Line (200, 200, 300, 200, 1)
%Bouncing Ball
for i: 1.. 30
Draw.FillOval (800 +i, 400 + i, 9, 9, blue)
delay(10)
Draw.FillOval (100 + i, 400 + i, 9, 9, 0)
end for
for i: 1.. 50
Draw.FillOval (150 +i, 300 +i, 9, 9, blue)
delay(10)
Draw.FillOval (150 + i, 300 + i, 9, 9, 0)
end for
for i: 1.. 50
Draw.FillOval (350 +i, 200 +i, 9, 9, blue)
delay(10)
Draw.FillOval (350 + i, 200 + i, 9, 9, 0)
end for
for decreasing i: 50.. 1
Draw.FillOval (550 +i, 100 +i, 9, 9, blue)
delay(10)
Draw.FillOval (350 + i, 100 + i, 9, 9, 0)
end for |
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Sun Apr 19, 2009 6:46 pm Post subject: RE:ANimation with stairs |
|
|
here, I did the first bounce for you, just continue this pattern
Turing: |
setscreen ("graphics")
%Stairs
proc drawstairs % calls a draw procedure so stairs don't get wiped by cls
Draw.Line (50, 0, 50, 50, 1)
Draw.Line (50, 50, 100, 50, 1)
Draw.Line (100, 50, 100, 100, 1)
Draw.Line (100, 100, 150, 100, 1)
Draw.Line (150, 150, 150, 100, 1)
Draw.Line (200, 150, 150, 150, 1)
Draw.Line (200, 200, 200, 150, 1)
Draw.Line (200, 200, 300, 200, 1)
end drawstairs
%Bouncing Ball
for decreasing i : 200.. 155
drawstairs
drawfilloval (1 + i, 1 + i, 9, 9, blue)
delay (20)
cls
View.Update
end for
for j : 1.. 5
drawstairs
drawfilloval (155 - j, 155 + j, 9, 9, blue)
delay (20)
cls
View.Update
end for
for decreasing i : 165.. 115
drawstairs
drawfilloval (- 15 + i, 1 + i, 9, 9, blue)
delay (20)
cls
View.Update
end for
|
you call a procedure to draw the stairs over and over so they don't get wiped by the cls[/syntax] |
|
|
|
|
![](images/spacer.gif) |
enimirahi
|
Posted: Sun Apr 19, 2009 7:21 pm Post subject: RE:ANimation with stairs |
|
|
omg wow thanks ur awsume |
|
|
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Sun Apr 19, 2009 8:42 pm Post subject: RE:ANimation with stairs |
|
|
lol no, Tony and Dan are awesome. I'm just bored :p |
|
|
|
|
![](images/spacer.gif) |
DifinityRJ
![](http://compsci.ca/v3/uploads/user_avatars/1665843594662f4952a669.jpg)
|
Posted: Mon Apr 20, 2009 11:13 am Post subject: Re: ANimation with stairs |
|
|
You can put the stairs into a for statement to make it more efficient.
Change the variable 'number_of_stairs' to add more stairs, without doing extra work.
Also add some basic physics, along with some sort of collision (I did whatdotcolor because I didn't track the x and y values of the stairs, so its a bit difficult to do math based collision)
Turing: |
setscreen ("graphics,offscreenonly")
%Stairs
var x, y, vy, vx : real := 0
var number_of_stairs := 8
var platform : boolean := false % checks to see if the ball is hitting stairs
const grav := 0. 098
const bounce := 0. 65
x := 300
y := 400
vx := - 0. 5
proc drawstairs
for a : 1 .. number_of_stairs
Draw.ThickLine (50 * a, 50 * a, 50 + 50 * a, 50 * a, 10, black)
Draw.ThickLine (50 * a, 0 + 50 * (a - 1), 50 * a, 50 * a, 10, black)
end for
end drawstairs
proc drawball
Draw.FillOval (round (x ), round (y ), 5, 5, red)
end drawball
proc collision
if whatdotcolor (round (x + 5), round (y - 5)) not= black and platform = false then
vy - = grav
end if
if whatdotcolor (round (x + 5), round (y - 5)) = black then
vy := -vy
vy * = bounce
end if
if whatdotcolor (round (x + 5), round (y - 7)) = black then
y + = 0. 5 % makes sure ball doesn't fall into the stairs
platform := true
else
platform := false
end if
end collision
proc moveball
y + = vy
x + = vx
end moveball
%Bouncing Ball
loop
cls
drawstairs
drawball
collision
moveball
View.Update
delay (10)
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
enimirahi
|
Posted: Tue Apr 21, 2009 3:58 pm Post subject: RE:ANimation with stairs |
|
|
wowo thanks |
|
|
|
|
![](images/spacer.gif) |
|
|