Artillery V2

Discuss scenes and videos made with Algodoo.

Artillery V2

Postby Ivanlul » Fri Jan 08, 2010 11:39 am

Bigger, badder version of my first artillery, includes explosive ammo.

ETA - how long it will take for the shells to get there.
Distance - The distance away from the cannon, max is 3000 meters/1.86 miles.
Angle - Whether the angle is low or high.

Controls:
Enter - fire.
1 - Switch between low and high angle.
Arrow keys - control test car.

Notes:
Position tracker is the red thing on the test car. It can be detached and moved by different methods (airplane, rocket, etc).

After you shoot the projectile zoom out all the way and follow it to see where it lands.

It's accuracy is within 2 meters.

Rating: rated 6
Filesize: 29.91 kB
Comments: 0
Ratings: 3
download


Technical Info
variables wrote:Scene.my.distance := 0;
Scene.my.pos1 := [-978.2004, 3.7807689];
Scene.my.pos2 := [978.2004, -3.593469];
Scene.my.typeangle := 1;
Scene.my.angle1 := 1.4117056;
Scene.my.typeangle1 := "High";

Angle code wrote:onHitByLaser = (e)=>{
{scene.my.typeangle == 1} ? {scene.my.angle1 = (math.Atan((30625 + (937890625 - 96.04 * scene.my.pos2(0) * scene.my.pos2(0) - 600250 * scene.my.pos2(1)) ^ 0.5) / (9.8 * scene.my.pos2(0))))} : {scene.my.angle1 = (math.Atan((30625 - (937890625 - 96.04 * scene.my.pos2(0) * scene.my.pos2(0) - 600250 * scene.my.pos2(1)) ^ 0.5) / (9.8 * scene.my.pos2(0))))};
scene.my.pos1 = e.pos;
scene.my.time = (scene.my.pos2(0)) / (175 * math.cos(scene.my.angle1))
};

spawn code wrote:onHitByLaser = (e)=>{
{{controllerAcc + 5} < sim.time} ? {
Scene.addcircle({
pos := e.pos;
buttonDestroy = "l";
attraction := 0;
vel := ([math.cos(scene.my.angle1), math.sin(scene.my.angle1)]) * 175;
radius := 0.5;
collideset := 1;
drawcake := true;
heteroCollide := true;
drawborder := false;
color := [0, 0, 0, 1];
density := 100;
friction := 0.0;
onCollide := (e)=>{
density = 0;
for(30, (n)=>{
scene.addcircle({
pos := e.pos;
buttonDestroy = "l";
attraction := 0;
vel := ([math.cos(n * 0.20943952), math.sin(n * 0.20943952)]) * 75;
radius := 0.09;
collideset := 1;
drawcake := true;
heteroCollide := true;
drawborder := false;
color := [0, 0, 0, 1];
density := 100;
friction := 0.0;
restitution := 0.5;
airFrictionMult := 0
});
scene.addpen({
pos := e.pos;
fadetime := 0.2;
size := 0.18;
color := [1, 1, 1, 1]
});
textcolor = [e.pos(0), e.pos(1), 1, 1]
})
};
restitution := 0.5;
airFrictionMult := 0
});
scene.addpen({
pos := e.pos;
fadetime := 0.2;
size := 1;
color := [1, 1, 1, 1]
});
textcolor = [e.pos(0), e.pos(1), 1, 1];
controllerAcc = sim.time
} : {}
};
Last edited by Ivanlul on Fri Jan 08, 2010 4:50 pm, edited 1 time in total.
Registered: 2008-10-16
Image
User avatar
Ivanlul
 
Posts: 763
Joined: Mon Aug 31, 2009 11:19 pm
Location: US

Re: Artillery V2

Postby Kilinich » Fri Jan 08, 2010 1:58 pm

I prefer not use such big code in onCollide. You can hide it in scene.my.explosion = (pos) => {} function. This makes code looks understandable and easy to use.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Artillery V2

Postby RA2lover » Fri Jan 08, 2010 2:29 pm

you can alternatively use the for() function, to avoid such long pseudoexplosion scripts.
Rating: rated 5.8
Filesize: 29.12 kB
Comments: 2
Ratings: 7
download


this one used the for() function to spawn more without a scene.my variable or extremely long scripts
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil


Return to Scenes

Who is online

Users browsing this forum: No registered users and 0 guests