
-----------------------------------
enimirahi
Sun Apr 19, 2009 4:22 pm

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

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)

-----------------------------------
saltpro15
Sun Apr 19, 2009 5:17 pm

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


Draw.Line (50,0,50,50)
Draw.Line (50,50,100,50)
Draw.Line (100,50,100,100)


in a pattern like that, it'll eliminate a lot of headaches

-----------------------------------
enimirahi
Sun Apr 19, 2009 5:33 pm

RE:ANimation with stairs
-----------------------------------
ok  thnx

-----------------------------------
enimirahi
Sun Apr 19, 2009 6:01 pm

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

%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 Here

-----------------------------------
saltpro15
Sun Apr 19, 2009 6:46 pm

RE:ANimation with stairs
-----------------------------------
here, I did the first bounce for you, just continue this pattern

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]

-----------------------------------
enimirahi
Sun Apr 19, 2009 7:21 pm

RE:ANimation with stairs
-----------------------------------
omg wow thanks ur awsume

-----------------------------------
saltpro15
Sun Apr 19, 2009 8:42 pm

RE:ANimation with stairs
-----------------------------------
lol no, Tony and Dan are awesome.  I'm just bored :p

-----------------------------------
DifinityRJ
Mon Apr 20, 2009 11:13 am

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)


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


-----------------------------------
enimirahi
Tue Apr 21, 2009 3:58 pm

RE:ANimation with stairs
-----------------------------------
wowo thanks
