In this battle/game you post something and then someone works out the AS for that effect okay they then post what they want the others to work out.
First challenge: Work out how to throw something and make them land back on the ground again. like in defen your castle (BTW I already know how to do this but I want yous to give it a go)
system
October 19, 2003, 7:58pm
2
does it have to be reflected from anywher, does it have to fly in x and y direction, or simply accellerate the ball with your cursor and make it come with gravity? AS only or predrawn flash allowed?
system
October 19, 2003, 8:07pm
3
ground_pos = 300 ;
this.createEmptyMovieClip("canon", -50) ;
canon.lineStyle(1, 0, 100) ;
canon.beginFill(0, 100) ;
canon.lineTo(50, 0) ;
canon.lineTo(50, 50) ;
canon.lineTo(0, 50) ;
canon.endFill() ;
canon._y = ground_pos - 50 ;
this.createEmptyMovieClip("projectile", -49)._visible = 0 ;
projectile.lineStyle(10, 0, 100) ;
projectile.lineTo(.45, .15) ;
gravity = 2 ;
function throwProjectile () {
var dx = _xmouse - start_x ;
var dy = _ymouse - start_y ;
var force = Math.sqrt (dx*dx+dy*dy) ;
var angle = Math.atan2 (dy, dx) ;
dep ++ ;
var mc = projectile.duplicateMovieClip ("p"+dep, dep) ;
mc._x = canon._x ;
mc._y = canon._y ;
mc.vx = -dx / 3 ;
mc.vy = -dy / 3 ;
mc.onEnterFrame = function () {
this._x += this.vx ;
this._y += this.vy ;
trace(this.vy); this.vy += gravity ;
if (this._y > ground_pos) {
this._y = ground_pos ;
delete this.onEnterFrame ;
}
}
}
canon.onPress = function () {
start_x = _xmouse ;
start_y = _ymouse ;
}
canon.onRelease = canon.onReleaseOutside = throwProjectile ;
Click the canon, and release.
system
October 19, 2003, 8:08pm
4
OK, so I want the next one to set up a target that you have to reach, horizontal or vertical, with an accurate collision test if possible
And I want planes to fly over, dropping bombs occasionally, , and people running on the ground, and… :trout:
system
October 19, 2003, 9:03pm
5
@dencioust : was that what you intended?
system
October 20, 2003, 10:56am
6
Yeah, I wasn’t too sure either, I don’t know that ‘Defend your castle’ thing :-\
system
October 20, 2003, 2:05pm
7
hey, this sounds like fun. I’m in.
system
October 20, 2003, 6:24pm
8
ouch! (to myself:"…remember: always google first if you find something you don’t know…")
I guess he meant that
http://www.ebaumsworld.com/castle.html
(anyway I guessed something like that before (only the castle thing was irritating)
@pom : you’d better be fast now!
system
October 20, 2003, 7:11pm
9
I felt free to add some features like boucing
[AS]yarray = [];
xarray = [];
createEmptyMovieClip(“ball”, 100);
_root.ball.lineStyle(40,0, 100);
_root.ball.moveTo(19.5, -20);
_root.ball.lineTo(20.5, -20);
_root.ball._x = 255;
createEmptyMovieClip(“earth”, 50);
earth.lineStyle(1, 0x009900, 100);
earth.lineTo(800, 0);
earth.lineTo(800, -1000);
earth.moveTo(0, 0);
earth.lineTo(0, -1000);
earth._y = 600;
_root.ball.onPress = function() {
_root.ball.startDrag(false, 0, -1000, 800-_root.ball._width/2, earth._y);
drag = true;
};
_root.ball.onRelease = _root.ball.onReleaseOutside=function () {
_root.ball.stopDrag();
drag = false;
};
_root.onEnterFrame = function() {
if (drag != true) {
yarray = [_root.ball._y];
xarray = [_root.ball._x];
_root.ball._y += _root.ball.vy;
_root.ball._x += _root.ball.vx;
_root.ball.vy = (_root.ball.vy49)/50+1;
_root.ball.vx = (_root.ball.vx 49)/50;
if (_root.ball._y>earth._y) {
_root.ball._y = earth._y;
_root.ball.vy = -Math.floor(_root.ball.vy/3)
_root.ball.vx=_root.ball.vx9/10
}
if (_root.ball._x>_root.earth._width-_root.ball._width/2) {
_root.ball._x = _root.earth._width-_root.ball._width/2;
_root.ball.vx = -Math.floor(_root.ball.vx/3)
_root.ball.vy=_root.ball.vy 9/10
}
if (_root.ball._x<0) {
_root.ball._x = 0;
_root.ball.vx = -Math.floor(_root.ball.vx/3)
_root.ball.vy=_root.ball.vy*9/10
}
}
};
_root.onMouseMove = function() {
if (drag == true) {
xarray.unshift(_root.ball._x);
yarray.unshift(_root.ball._y);
if (xarray.length>3) {
xarray.splice(3, xarray.length-3);
yarray.splice(3, yarray.length-3);
}
_root.ball.vx = (xarray[0]-xarray[2])/3;
_root.ball.vy = (yarray[0]-yarray[2])/3;
}
};[/AS]
too late pom
system
October 20, 2003, 7:34pm
10
I think bit101 is always a good inspiration for things you want others to do :azn:
try redo the privot point thing
http://www.bit-101.com/lab.html
11. oktober 02
@pom : asking bit is NOT allowed!
system
October 21, 2003, 8:36am
11
That’s not what I had in mind… All right!
system
October 21, 2003, 11:43am
12
confused me too.
btw: how about a new rule:
if no one get’s one fitting to the demanded task, the person who set up the task has to offer an own one, within 2 days.
If he is abled to do that, he earns one point.
after that anyone availible dan take over and set up a new task.
system
October 21, 2003, 5:08pm
13
Played around with pom’s code a bit …
walls = [];
gravity = 2;
bulletsize = 10;
wallStickyNess = 1.7;
ground = {x:350, y:300};
bounce = gravity-(gravity/9);
MovieClip.prototype.makeCannon = function(sze, x) {
with (this) {
lineStyle(1, 0, 100);
moveTo(-sze, -sze);
beginFill(0, 100);
lineTo(sze, -sze);
lineTo(sze, sze);
lineTo(-sze, sze);
lineTo(-sze, -sze);
endFill();
_x = x;
_y = ground.y-sze+bulletsize/2;
}
};
MovieClip.prototype.makeBullet = function() {
with (this) {
_visible = 0;
lineStyle(bulletsize, 0, 100);
lineTo(.45, .15);
}
};
MovieClip.prototype.makeWall = function(w, h, x, y) {
walls.push(this);
with (this) {
lineStyle(0, 0, 100);
moveTo(-w/2, -h/2);
beginFill(0, 100);
lineTo(w/2, -h/2);
lineTo(w/2, h/2);
lineTo(-w/2, h/2);
lineTo(-w/2, -h/2);
endFill();
_x=x, _y=y;
}
};
this.createEmptyMovieClip("canon", -50).makeCannon(25, ground.x);
this.createEmptyMovieClip("leftWall", -49).makeWall(10, 50, ground.x-200, ground.y-200);
this.createEmptyMovieClip("rightWall", -48).makeWall(10, 50, ground.x+200, ground.y-200);
this.createEmptyMovieClip("projectile", -47).makeBullet();
function throwProjectile() {
dep++;
var dx = _xmouse-start_x;
var dy = _ymouse-start_y;
var force = Math.sqrt(dx*dx+dy*dy);
var angle = Math.atan2(dy, dx);
var mc = projectile.duplicateMovieClip("p"+dep, dep);
mc._x = canon._x;
mc._y = canon._y;
mc.xi = 3;
mc.yi = 3;
mc.vx = -dx/mc.xi;
mc.vy = -dy/mc.yi;
mc.hazHitWall = 0;
mc.onEnterFrame = function() {
this._x += this.vx;
this._y += this.vy;
this.vy += gravity;
for (all in walls) {
if (this.hitTest(walls[all])) {
this.xi *= wallStickyNess;
this.hazHitWall = 1;
walls[all]._x>kanon._x ? this.vx=dx/this.xi : this.vx=-dx/this.xi;
}
}
if (this._y>ground.y) {
this.yi *= bounce;
this.xi *= bounce;
this._y = ground.y;
this.vy = -dy/this.yi;
this.hazHitWall ? this.vx=dx/this.xi : this.vx=-dx/this.xi;
if (this.vy>-1) {
delete this.onEnterFrame;
}
}
};
}
canon.onPress = function() {
start_x = _xmouse;
start_y = _ymouse;
};
canon.onRelease = canon.onReleaseOutside=throwProjectile;
system
October 21, 2003, 5:57pm
14
Hehe, I used hazHitWall (z is a s), but it got filtered … I’ll change it to hazHitWall.
system
October 23, 2003, 1:17pm
15
is there no one abled to do it, or just no one willing to do it?
system
October 23, 2003, 6:39pm
16
I am in too
but… who had the last turn??? Voetsjoeba?
did he meet pom turms?
Voetsjoeba: then say the next challenge
system
October 23, 2003, 7:10pm
17
well, i just anounced myself to be the winner
(denacioust didn’t say anything more, Pom’s was a nice one, but he misunderstood the task (I did so too, until I found the game dena referred to) and Voetsjoeba’s was a change of Pom’s with some pinball elements added)
so if nobody else claims to be the winner , I do
the task:
try redo the privot point thing
http://www.bit-101.com/lab.html
11. oktober 02
system
October 24, 2003, 7:40pm
18
Well I can’t test your codes coz I’m working on Flash 5.
system
October 24, 2003, 8:14pm
19
system
October 24, 2003, 8:36pm
20
Although Pom and VoetsJebas were good McGivers was the one I wanted so he wins. Next Go.Easy one. Try figure out how I done my footer