
-----------------------------------
asianrandy
Fri Oct 17, 2008 4:12 pm

help with animation to move the car into the garage.
-----------------------------------
i trying to move the car into the garage. but i dont know where to put the code  delay (500).  and what the background code lol serious... 



setscreen ("graphics:1024;720")

% house
drawfillbox (60, 10, 250, 300, 9)

% Garage
drawfillbox (251, 20, 500, 180, black)
drawfillbox (251, 20, 260, 180, gray)
drawfillbox (500, 20, 510, 180, gray)
drawfillbox (510, 190, 251, 180, gray)


%
drawline (110, 380, 90, 380, black)
drawline (110, 380, 110, 345, black)
drawline (90, 380, 90, 329, black)

% window
drawfillbox (70, 210, 150, 280, 4)
drawline (70, 250, 150, 250, black)
drawline (112, 210, 112, 280, black)

% door
drawfillbox (240, 20, 150, 180, 10)

%door knob
drawoval (165, 100, 5, 5, 9)

% right line
drawline (60, 300, 150, 380, 10)
% left line
drawline (250, 300, 150, 380, 10)

% Ground
drawfillbox (1, 20, 1000, 1, green)

%door knob
drawoval (165, 100, 5, 5, 9)

% sun
drawoval (990, 660, 50, 50, black)
drawfill (990, 660, yellow, black)


% smoke
drawoval (110, 400, 10, 5, black)
drawfill (110, 400, gray, black)
drawoval (120, 425, 10, 6, black)
drawfill (120, 425, gray, black)

% Car
drawfillbox (560, 50, 760, 100, black)
drawoval (600, 35, 15, 15, black)
drawfill (600, 35, gray, black)
drawoval (710, 35, 15, 15, black)
drawline (600, 130, 700, 130, black)
drawline (600, 130, 560, 90, black)
drawline (700, 130, 760, 90, black)


-----------------------------------
Tony
Fri Oct 17, 2008 4:49 pm

RE:help with animation to move the car into the garage.
-----------------------------------
delays, typically, go inside animation loops.

-----------------------------------
Insectoid
Fri Oct 17, 2008 4:55 pm

RE:help with animation to move the car into the garage.
-----------------------------------
Your animation needs to be in a loop, with a modification to the car's X value to make it move. The very last part of the animation should be a View.Update (check the Turing Walkthrough), followed by a delay and then a 'cls'.

-----------------------------------
asianrandy
Fri Oct 17, 2008 7:37 pm

Re: help with animation to move the car into the garage.
-----------------------------------
k i got this example from view,update (tutorial) and i just need to take out  the y or radius.  and put the car's X value. so my car can move?


  View.Set ("graphics,offscreenonly")
var x, y, xChange, yChange : int := 1
const RADIUS : int := 5
Draw.Box (0, 0, maxx, maxy, black)
x := maxx div 2
y := maxy div 2
loop
    Draw.Cls
    Draw.Box (0, 0, maxx, maxy, black)
    Draw.FillOval (x, y, RADIUS, RADIUS, green)
    View.Update
    Time.Delay (5)
    x += xChange
    y += yChange
    if View.WhatDotColor (x, y + RADIUS) = black then
        yChange *= -1
    elsif View.WhatDotColor (x, y - RADIUS) = black then
        yChange *= -1
    end if
    if View.WhatDotColor (x + RADIUS, y) = black then
        xChange *= -1
    elsif View.WhatDotColor (x - RADIUS, y) = black then
        xChange *= -1
    end if
end loop  

-----------------------------------
Insectoid
Fri Oct 17, 2008 7:47 pm

RE:help with animation to move the car into the garage.
-----------------------------------
Uh, no. This is for character control. You need to make your own. Yes, you do only manipulate yor car's X value. The important thing is that you understand View.Update. I hope.

-----------------------------------
asianrandy
Fri Oct 17, 2008 10:17 pm

Re: help with animation to move the car into the garage.
-----------------------------------
lol i don't , so that means l'm screwed. i need like more examples on view.update. so what should i do then.

-----------------------------------
andrew.
Fri Oct 17, 2008 11:55 pm

RE:help with animation to move the car into the garage.
-----------------------------------
Well, basically View.Update just draws everything onscreen at once. So if you don't use it, then nothing on your screen is drawn. Think of it like this: the computer draws what you want in it's head, but will only display that on your screen when you call View.Update. Hope that helps with your View.Update dilemma. 

Now about moving the car. Think about what you want it to do. You want it to move sideways. That means you're doing something to the X values, right? Well you know that when you drew the car, you used X and Y values to locate the pieces. So to move the car left, you would subtract from those X values. And you would add to those X values to move to the right. Well, how would you keep adding on to the X values? With a variable of course.

I think I will stop there and let you figure out the rest ;).

-----------------------------------
Ktomislav
Sat Oct 18, 2008 8:39 am

Re: help with animation to move the car into the garage.
-----------------------------------
setscreen ("graphics:1024;720")
View.Set ("offscreenonly")

var background: int;

% house
drawfillbox (60, 10, 250, 300, 9)

% Garage
drawfillbox (251, 20, 500, 180, black)
drawfillbox (251, 20, 260, 180, gray)
drawfillbox (500, 20, 510, 180, gray)
drawfillbox (510, 190, 251, 180, gray)


%
drawline (110, 380, 90, 380, black)
drawline (110, 380, 110, 345, black)
drawline (90, 380, 90, 329, black)

% window
drawfillbox (70, 210, 150, 280, 4)
drawline (70, 250, 150, 250, black)
drawline (112, 210, 112, 280, black)

% door
drawfillbox (240, 20, 150, 180, 10)

%door knob
drawoval (165, 100, 5, 5, 9)

% right line
drawline (60, 300, 150, 380, 10)
% left line
drawline (250, 300, 150, 380, 10)

% Ground
drawfillbox (1, 20, 1000, 1, green)

%door knob
drawoval (165, 100, 5, 5, 9)

% sun
drawoval (990, 660, 50, 50, black)
drawfill (990, 660, yellow, black)


% smoke
drawoval (110, 400, 10, 5, black)
drawfill (110, 400, gray, black)
drawoval (120, 425, 10, 6, black)
drawfill (120, 425, gray, black)

View.Update

background := Pic.New (0,0,maxx, maxy)
for i : 0 .. 50
    cls
    Pic.Draw (background, 0, 0, picCopy)
    % Car
    drawfillbox (560-i*3, 50, 760-i*3, 100, black)
    drawoval (600-i*3, 35, 15, 15, black)
    drawfill (600-i*3, 35, gray, black)
    drawoval (710-i*3, 35, 15, 15, black)
    drawline (600-i*3, 130, 700-i*3, 130, black)
    drawline (600-i*3, 130, 560-i*3, 90, black)
    drawline (700-i*3, 130, 760-i*3, 90, black)
    View.Update
    delay (50)
end for

You probably don't understand this but maybe it can help you.

Pic.New (x1, y1, x2, y2) is saving a picture from screen into a variable so you can just draw that picture as a background.
Pic.Draw (backgroung, 0, 0, picCopy) - it draws that background picture - 0, 0 are coordinates and picCopy just picCopy you don't need anything else.
drawfillbox (560-i*3, 50, 760-i*3, 100, black)  -> 560-i*3 that means that that box's x coordinate will go smaller so it will move from right to left side.
:mrgreen:  :mrgreen:  :mrgreen:

If you don't understand this than you should take a look at some tutorial.

-----------------------------------
asianrandy
Tue Oct 21, 2008 12:19 pm

RE:help with animation to move the car into the garage.
-----------------------------------
setscreen ("graphics:1010;670")
View.Set ("offscreenonly")
var background : int;

% house
drawfillbox (60, 10, 250, 300, 9)

% Garage
drawfillbox (251, 20, 500, 180, black)
drawfillbox (251, 20, 260, 180, gray)
drawfillbox (500, 20, 510, 180, gray)
drawfillbox (510, 190, 251, 180, gray)


%
drawline (110, 380, 90, 380, black)
drawline (110, 380, 110, 345, black)
drawline (90, 380, 90, 329, black)

% window
drawfillbox (70, 210, 150, 280, 4)
drawline (70, 250, 150, 250, black)
drawline (112, 210, 112, 280, black)

% door
drawfillbox (240, 20, 150, 180, 10)

%door knob
drawoval (165, 100, 5, 5, 9)

% right line
drawline (60, 300, 150, 380, 10)

% left line
drawline (250, 300, 150, 380, 10)

% Ground
drawfillbox (1, 20, 1000, 1, green)

% smoke
drawoval (110, 400, 10, 5, black)
drawfill (110, 400, gray, black)
drawoval (120, 425, 10, 6, black)
drawfill (120, 425, gray, black)

% sun
drawoval (950, 610, 50, 50, black)
drawfill (950, 610, yellow, black)

% flag
drawfillbox (410, 190, 400, 350, gray)
drawfillbox (510, 290, 400, 350, gray)

View.Update

background := Pic.New (0, 0, maxx, maxy)
for i : 0 .. 50
    cls
    Pic.Draw (background, 0, 0, picCopy)
    % Car
    drawfillbox (560 - i * 6, 50, 760 - i * 6, 100, red)
    drawoval (600 - i * 6, 35, 15, 15, red)
    drawfill (600 - i * 6, 35, gray, red)
    drawoval (710 - i * 6, 35, 15, 15, red)
    drawfill (710 - i * 6, 35, gray, red)
    drawline (600 - i * 6, 130, 700 - i * 6, 130, red)
    drawline (600 - i * 6, 130, 560 - i * 6, 90, red)
    drawline (700 - i * 6, 130, 760 - i * 6, 90, red)
    View.Update
    delay (90)
    end for

        background := Pic.New (0, 0, maxx, maxy)
        for i : 0 .. 50
            cls
            Pic.Draw (background, 0, 0, picCopy)
            % sun
            drawoval (950 - i * 6, 610 - i * 6, 50, 50, black)
            drawfill (950 - i * 6, 610 - i * 6, yellow, black)
            View.Update
            delay (90)
        end for

lm trying to make the sun go left, and i don't no where to put the loop. and does loop make the program keep going.

-----------------------------------
copthesaint
Sat Nov 08, 2008 5:20 pm

Re: help with animation to move the car into the garage.
-----------------------------------
If you use process you can do multiple things at one time

for example:

var num:=1
%the line that travels to the right
process box1
for i:1..maxx+10

    drawfillbox (0,(maxy div 2)-5,i+10,(maxy div 2)+5,white)
    View.Update
    delay(5)
    
end for
num:=1
end box1
%the box that travels to the left
process box2
for i:1..maxx+10

    drawfillbox (maxx,(maxy div 2)-15,(maxx-10)-i,(maxy div 2)-5,white)
    View.Update
    delay(5)
    
end for
num:=1
end box2
%the box that expands
process box3
for i:1..maxx+10

    drawfillbox ((maxx div 2)-i,(maxy div 2)-i,(maxx div 2)+i,(maxy div 2)+i,black)
    View.Update
    delay(5)
    
end for
num:=1
end box3
loop
if num=1 then
cls
fork box3
fork box1
fork box2

delay(1) 
num:=0
end if

end loop

so useing a process you could move then sun at the same time

-----------------------------------
syntax_error
Sat Nov 08, 2008 5:30 pm

RE:help with animation to move the car into the garage.
-----------------------------------
Never fork. Never.
