deviant art

Deviant Login Shop  Join deviantART for FREE Take the Tour
[x]
Download File
SWF, 3.0 KB
more ▶

More from *SophieHoulden

Featured in Groups:

Details

December 16, 2008
3.0 KB
550×400
Thumb

Statistics

Comments: 19
Favourites: 9 [who?]

Views: 266 (0 today)
Downloads: 4 (0 today)
[x]
:iconsophiehoulden:
not really a challenge for you, theres no dying or objective, just exploring space :)

arrows to steer
spacebar for LUDACRIS SPEED!

made in 65 mins for #Flashers challenge

Edit: Heres the code :)
stage.quality = "low"

var keyLEFT = false
var keyRIGHT = false
var keySPACE = false
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKP)
function onKP(evt:KeyboardEvent){
switch(evt.keyCode){
case 37:
keyLEFT = true
break;
case 39:
keyRIGHT = true
break;
case 32:
keySPACE = true
break;
}
}

stage.addEventListener(KeyboardEvent.KEY_UP,onKR);
function onKR(evt:KeyboardEvent){
switch(evt.keyCode){
case 37:
keyLEFT = false
break;
case 39:
keyRIGHT = false
break;
case 32:
keySPACE = false
break;
}
}


var xMove = 0;
var yMove = 0;

var shipSpeed = 4;

var pArray = new Array();
for (var i=0;i<400;i++){
var parti = new Star()
parti.x=Math.random()*550
parti.y=Math.random()*400
pArray.push([parti,1]);
thing.addChild(pArray[pArray.length-1][0])
pArray[pArray.length-1][1]=Math.random()+1
pArray[pArray.length-1][0].width= 2*pArray[pArray.length-1][1]
pArray[pArray.length-1][0].height = pArray[pArray.length-1][0].width
}


var jetArray = new Array();

var astArray = new Array();
for (i=0;i<100;i++){
var asty = new Aster();
asty.x=(Math.random()*10000)-5000
asty.y=(Math.random()*10000)-5000
asty.width =(Math.random()*70)+150
asty.height = asty.width
asty.rotation = Math.random()*360
astArray.push(asty)
thing.addChild(astArray[astArray.length-1]);
}

stage.addEventListener(Event.ENTER_FRAME,onTick);
function onTick(evt:Event){
if (keySPACE){
shipSpeed = 16
}else{
shipSpeed = 4
}
if (keyLEFT){
spaceship.rotation-=5
}
if (keyRIGHT){
spaceship.rotation+=5
}
xMove = -Math.cos((spaceship.rotation/180)*Math.PI)
yMove = -Math.sin((spaceship.rotation/180)*Math.PI)

jetArray.push([275+(xMove*7),200+(yMove*7)])

thing2.graphics.clear()
thing2.graphics.moveTo(275,200)
var lineWidth = 15
var lineAlpha = 1
for (i=jetArray.length-1;i>jetArray.length-15;i--){
if (i>0){
jetArray[i][0]+=xMove*4*shipSpeed
jetArray[i][1]+=yMove*4*shipSpeed
lineWidth--
lineAlpha-=0.04
thing2.graphics.lineStyle(lineWidth,0xFF00FF,lineAlpha);
thing2.graphics.lineTo(jetArray[i][0],jetArray[i][1])
}
}

for (i=0;i<;pArray.length;i++){
pArray[i][0].x+= xMove * pArray[i][1] * shipSpeed
pArray[i][0].y+= yMove * pArray[i][1] * shipSpeed

if (pArray[i][0].x<0){
pArray[i][0].x+=550
}
if (pArray[i][0].x>550){
pArray[i][0].x-=550
}
if (pArray[i][0].y<0){
pArray[i][0].y+=400
}
if (pArray[i][0].y>400){
pArray[i][0].y-=400
}
}

for (i=0;i<astArray.length;i++){
astArray[i].x+= xMove * 3 * shipSpeed
astArray[i].y+= yMove * 3 * shipSpeed

if (astArray[i].x<-5000){
astArray[i].x+=10000
}
if (astArray[i].x>5000){
astArray[i].x-=10000
}
if (astArray[i].y<-5000){
astArray[i].y+=10000
}
if (astArray[i].y>5000){
astArray[i].y-=10000
}
}

}
Add a Comment:
 
:iconnapzter:
I've been orbiting around a planet for half an hour now.
Reply
:iconsophiehoulden:
*SophieHoulden Dec 18, 2008  Professional General Artist
any hostile life forms there? you may need to send the captain down for fisticuffs :)
Reply
:iconnapzter:
Nope. No hostile lifeforms. It's full of =GirlFlashes.
Reply
:iconsophiehoulden:
*SophieHoulden Dec 18, 2008  Professional General Artist
holy shit get out of there, that stuff is contagious!!! :ohnoes:
Reply
:iconpsycho-toaster:
If you added some calm music this would be quite relaxing.

Or maybe as a screensaver or something
Reply
:iconjohnjensen:
Awesome. o:

I was wondering, how did you make the fire out of the rocket?
Reply
:iconsophiehoulden:
*SophieHoulden Dec 17, 2008  Professional General Artist
I just there the source into the comment :)

basically its an array of points that move from the ships, and I use the graphics drawing stuff to join the dots :)
Reply
:iconjohnjensen:
so it's like on dot2:

onClipEvent(enterFrame) {
myParent = "dot1";
_x = _root[myParent]._x + Math.cos(((Math.atan2(_y-_root[myParent]._y,_x-_root[myParent]._x)*Math.PI)/180));
_y = _root[myParent]._y + Math.sin(((Math.atan2(_y-_root[myParent]._y,_x-_root[myParent]._x)*Math.PI)/180));
}

or something like that?
Reply
:iconsophiehoulden:
*SophieHoulden Dec 17, 2008  Professional General Artist
well the Math stuff is just for working out where it is, I guess this should be the simplest example of how it works:

for the init:
var lineArray = new Array();

then every frame:
//add mouse position to the array
lineArray.push(new Point(mouseX,mouseY));

//clear the last frames graphics
myMovieClip.graphics.clear();

//set up the graphics for a new line
myMovieClip.graphics.lineStyle(1,0x000000);
myMovieClip.graphics.moveTo(lineArray[0].x,lineArray[0].y);

//go through each point in the array and draw between them
for (var i=0;i<lineArray.length;i++){
myMovieClip.graphics.lineTo(lineArray[i].x,lineArray[i].y)
lineArray[i].x++
}


the 'lineArray[i].x++' bit is just to show you can move the points together in the loop, as with my spaceship one, the ship isnt moving, everything else is :)

also, sorry its in AS3 but its just what I'm used to now, it shouldnt be too hard to convert to AS2 I dont think, its just preperty names that have changed, and I dont think you need the .graphics subobject ^^;
Reply
Add a Comment: