Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 14 of 14

Thread: particle engine 2 - starShip

  1. #1

    particle engine 2 - starShip

    and another entry by NiñoScript, Hooray!

    CONTROLS:

    _root._ymouse = affects the speed of the spaceShip;

    Key.SPACE = creates a hi gravity point in the middle of the universe (aka blackhole), atracting the stars to it, but in this fake world, stars can scape that atraction after some fighting.[/size]


    i hope you like it



    edit:
    it looks weird when i see it in my browser, maybe becouse of the "noScale", dunno... if u want it to look like it should, just make a new document in flash and paste my code

    another edit:
    ok, i removed the "noScale" to add it to the forum, now it works ok
    Attached Files Attached Files
    Last edited by NiñoScript; January 20th, 2006 at 03:02 PM.

  2. #2

    CODE 'TILL NOW:

    Code:
    Stage.scaleMode = "noScale";
    //1
    //{speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50}
    starArray = [{speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50}];
    //2
    function drawStar(p) {
    	_root.change({func:"moveTo", value:[p.p.x-p.old.x*2, p.p.y-p.old.y*2]}).change({func:"lineTo", value:[p.p.x, p.p.y]});
    	//3
    }
    Object.prototype.change = function(what:Object, who) {
    	/*
    	.change({property:"", value:})
    	or
    	.change({func:"", value:[]})
    	*/
    	what.func == undefined ? this[what.property]=what.value : this[what.func](what.value[0], what.value[1]);
    	//4
    	return !who ? this : who;
    	//5
    };
    function moveStar(p, i) {
    	p.speed.change({property:"x", value:p.speed.x+Math.cos(Math.atan2(p.y-Stage.height/2, p.x-Stage.width/2))*speed/100}).change({property:"y", value:p.speed.y+Math.sin(Math.atan2(p.y-Stage.height/2, p.x-Stage.width/2))*speed/100}, p).change({property:"oldx", value:p.x}).change({property:"oldy", value:p.y}).change({property:"x", value:p.x>Stage.width+20 or p.x<-20 ? starArray[i]={speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50} : p.x+p.speed.x}).change({property:"y", value:p.y>Stage.height+20 or p.y<-20 ? starArray[i]={speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50} : p.y+p.speed.y});
    	//6
    	return {old:{x:p.x-p.oldx, y:p.y-p.oldy}, p:p};
    	//7
    }
    onEnterFrame = function () {
    	speed = Key.isDown(Key.SPACE) ? -150 : _ymouse;
    	//8
    	starArray.length<30 ? starArray.push({speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50}) : null;
    	//9
    	_root.change({func:"clear", value:null}).change({func:"lineStyle", value:[0]});
    	for (var i = 0; i<starArray.length; i++) {
    		//10
    		drawStar(moveStar(starArray[i], i));
    		//11
    	}
    };

  3. #3
    i'm definitely liking this! nice one, ninoscript!

  4. #4
    nifty
    Member #2 of the "I wont critique Timmytot's designs anymore" club.

  5. #5
    now it reacts to the FPS, and the number of lines hasn't changed

    that means that in each computer, the number of stars will adapt so the FramesPerSecond dont go down from 36 app


    Code:
    var fps = {variable:0, fps:100, constant:36, starArray:[{speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50}]};
    //1
    function drawStar(p) {
    	_root.change({func:"moveTo", value:[p.p.x-p.old.x*2, p.p.y-p.old.y*2]}).change({func:"lineTo", value:[p.p.x, p.p.y]});
    	//2
    }
    Object.prototype.change = function(what:Object, who) {
    	/*
    	.change({property:"", value:})
    	or
    	.change({func:"", value:[]})
    	*/
    	what.func == undefined ? this[what.property]=what.value : this[what.func](what.value[0], what.value[1]);
    	//3
    	return !who ? this : who;
    	//4
    };
    function moveStar(p, i) {
    	p.speed.change({property:"x", value:p.speed.x+Math.cos(Math.atan2(p.y-Stage.height/2, p.x-Stage.width/2))*speed/100}).change({property:"y", value:p.speed.y+Math.sin(Math.atan2(p.y-Stage.height/2, p.x-Stage.width/2))*speed/100}, p).change({property:"oldx", value:p.x}).change({property:"oldy", value:p.y}).change({property:"x", value:p.x>Stage.width+20 or p.x<-20 ? (fps.fps<fps.constant*2/3 ? (fps.starArray.splice(i, 1), fps.fps += 2) : (fps.starArray[i]={speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50})) : p.x+p.speed.x}).change({property:"y", value:p.y>Stage.height+20 or p.y<-20 ? (fps.fps<fps.constant*2/3 ? (fps.starArray.splice(i, 1), fps.fps += 2) : (fps.starArray[i]={speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50})) : p.y+p.speed.y});
    	//5
    	return {old:{x:p.x-p.oldx, y:p.y-p.oldy}, p:p};
    	//6
    }
    onEnterFrame = function () {
    	fps.fps>fps.constant ? fps.starArray.push({speed:{x:0, y:0}, x:Stage.width/2-random(100)+50, y:Stage.height/2-random(100)+50}) : null;
    	//7
    	fps.change({property:"variable", value:fps.variable+1}, _root).change({property:"speed", value:Key.isDown(Key.SPACE) ? -150 : _ymouse}).change({func:"clear", value:null}).change({func:"lineStyle", value:[0]});
    	//8
    	for (var i = 0; i<fps.starArray.length; i++) {
    		//9
    		drawStar(moveStar(fps.starArray[i], i));
    		//10
    	}
    };
    setInterval(function () {
    	fps.change({property:"fps", value:fps.variable}).change({property:"variable", value:0});
    	//11
    }, 1000);
    //12?
    Attached Files Attached Files
    Last edited by NiñoScript; January 20th, 2006 at 03:09 PM.

  6. #6
    Nice!

  7. #7
    Mines looks better..

    http://www.kirupa.com/forum/showthread.php?t=205315



    we used similar concept..

    What? My english sucks... well I know that... sorry..

  8. #8
    im a copycat,

    but, only mine makes you feel like if you were goin' fast

    edit: only mine has a black hole in the middle of the universe too
    Last edited by NiñoScript; January 21st, 2006 at 11:03 AM.

  9. #9
    bah..

    its all for fun for me anywhay..

    do your best and good luck..!
    What? My english sucks... well I know that... sorry..

  10. #10
    this two have nothing in common
    one is profesional
    but why do you have so many vertical and horizontal lines on upper and right edge of SWF file?

  11. #11
    Quote Originally Posted by gvozden
    why do you have so many vertical and horizontal lines on upper and right edge of SWF file?
    i don't know... that's a bug
    Quote Originally Posted by gvozden
    this two have nothing in common
    one is profesional
    which one?

  12. #12
    8
    posts
    Scripted life it may seem
    wow... nice one.. i dont even know how to use prototype! can some one teach me!!!???

  13. #13
    of course, i can
    just pm me

  14. #14

    Robot1

    Quote Originally Posted by gvozden View Post
    this two have nothing in common
    one is profesional
    but why do you have so many vertical and horizontal lines on upper and right edge of SWF file?
    btw... almost 2 years later, i still would like to know which one is the proffesional one

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012