
-----------------------------------
Homer_simpson
Wed Dec 03, 2003 9:26 pm

basic tutorial on simple projectle movement(a bit advanced)
-----------------------------------
View.Set ("offscreenonly")
%%%%%%%%%%Declaring projectile type as an object%%%%%%%%%%5
type projectile_t :
    record
        startx, starty, x, y, angle, weight, velocity : real
    end record

var projectile_1 : projectile_t

%set start point to 0,0
projectile_1.startx := 0
projectile_1.starty := 0
%setting the velocity(the throw power to 80
projectile_1.velocity := 80
%The angle that the projectile's thrown in
projectile_1.angle := 60
%how heavy the object is...
projectile_1.weight := 10
%setting the initial time to 0
var time1 := 0.0

procedure Projectile (var obj : projectile_t, t : real)
    obj.x := (obj.velocity * cosd (obj.angle) * t) + obj.startx
    obj.y := (obj.velocity * sind (obj.angle) * t - (obj.weight) * t ** 2 / 2) + obj.starty
end Projectile

loop
    time1 += .1 %The time and how fast it is moving
    Projectile (projectile_1, time1) %applying movements to the projectile
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, 12) %draw the projectile
    View.Update
    delay (10)
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, white) %erase the projectile
end loop


-----------------------------------
Homer_simpson
Wed Dec 03, 2003 9:38 pm


-----------------------------------
here's one a bit more advanced...
View.Set ("offscreenonly")
%%%%%%%%%%Declaring projectile type as an object%%%%%%%%%%5
type projectile_t :
    record
        startx, starty, x, y, angle, weight, velocity, bounciness : real
    end record

var projectile_1 : projectile_t

%set start point to 0,0
projectile_1.startx := 0
projectile_1.starty := 200
%setting the velocity(the throw power to 80
projectile_1.velocity := 60
%The angle that the projectile's thrown in
projectile_1.angle := 80
%how heavy the object is...
projectile_1.weight := 10
%setting the bounciness
projectile_1.bounciness := 10
%setting the initial time to 0
var time1 := 0.0

procedure Projectile (var obj : projectile_t, t : real)
    obj.x := (obj.velocity * cosd (obj.angle) * t) + obj.startx
    obj.y := (obj.velocity * sind (obj.angle) * t - (obj.weight) * t ** 2 / 2) + obj.starty
end Projectile

procedure Bounce (var obj : projectile_t, var t : real)
    if obj.y  0 then
            t := 0
            obj.startx := obj.x
            obj.starty := obj.y
            obj.velocity -= obj.bounciness
        end if
        if (obj.velocity) < 0 then
            obj.velocity := 0
        end if
    end if
end Bounce
loop
    time1 += .1 %The time and how fast it is moving
    Projectile (projectile_1, time1) %applying movements to the projectile
    Bounce (projectile_1, time1)%Detect ground and bounce back
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, 12) %draw the projectile
    View.Update
    delay (10)
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 5, 5, white) %erase the projectile
    exit when projectile_1.velocity 