Posted: Sat Apr 13, 2013 7:47 pm Post subject: RE:Simulate a 100 times?
Why are you using two different images for when you move left and right? Is that so that the character faces left and right?
As for choppyness, the character will move 100 pixels at a time unless you do something like this:
CODE:
if Rand.Int (0, 1) = 1 then
for i : 1 .. 100
center := center - 1
Pic.Draw(left1, center, maxy div 2 _ 30, picMerge)
View.Update
delay(10)
end for
end if
Thats just an idea to make the character move smoothly. As for your other problem, I don't really see why its happening. Maybe post your full code, and I might see something.
Sponsor Sponsor
adrianr2z
Posted: Sat Apr 13, 2013 8:05 pm Post subject: Re: Simulate a 100 times?
OK it actually works now. I added the View.Update at the end of the if statement and the else statement and now it is much better as well as adding a delay on both. Don't get how this fixed it though :/
Nathan4102
Posted: Sat Apr 13, 2013 8:10 pm Post subject: RE:Simulate a 100 times?
What View.Update does is it draws the buffer to the screen, as opposed to you drawing directly to the screen. It helps reduce flashy or choppy animations, and makes it easier to organise your animation.
For the animated part, I've rewritten it a bit, this version runs a little faster I believe.
CODE:
center1 := 0
loop
step1 := Rand.Int (0, 1)
if step1 = 0 then
center1 := center1 + 1
else
center1 := center1 - 1
end if
counter := counter + 1
if center1 = 5 or center1 = -5 then
center1 := 0
counter1 := counter1 + 1
end if
exit when counter1 = 100
put counter1
end loop