A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [Problem] 3D space shooter game

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    47

    [Problem] 3D space shooter game

    Hello there.
    I'm working on a 3D engine for a space dog-fighting game is AS3. It's in its very early stages and I'm in the process of adding a central star which I'll position planets around. Up until now I've been drawing the star as a circle - its size dependent on the player's distance. But I want to put a glow filter on the star, so I need to draw the circle inside a movie clip.
    Problem is, as soon as I do that the circle gets drawn in bizarre places. I've traced the coordinates where it SHOULD be drawn and they are correct. I've even added back in the code to draw the circle straight to the screen so that I can see both where it SHOULD be and where the centralStar movieClip is drawing it.
    Here is the draw function in my Sun class. The parameters passed to it are your ship's facing (as a Vector3D), your ship's x,y,z coordinates (a Vector3D) and the matrix3D of your ship's rotation.
    'distanceTo' is your ship's direct distance from the central star and 'rad' is the radius of the central star.

    Code:
    public function drawObject(shipFacing:Vector3D, shipCoordinates:Vector3D, playerMatrix:Matrix3D):void {
    	graphics.clear();
    	inverseCoordinates = shipCoordinates.clone();
    	inverseCoordinates.negate();
    	inverseCoordinates = playerMatrix.deltaTransformVector(inverseCoordinates);
    	inverseCoordinates.w=inverseCoordinates.z/500;
    	inverseCoordinates.project();
    	graphics.beginFill(0xFFFF66);
    	graphics.drawCircle(inverseCoordinates.x, inverseCoordinates.y, (500/distanceTo)*rad);
    	graphics.endFill();
    }
    Is there any reason the drawCircle line would draw the circle in weird places? Is there something I'm not getting about drawing inside MovieClips?
    I'll try and attach the current version. The yellow star with the glow is the errant star. The red one is the non-MovieClip version getting drawn where the yellow one SHOULD be.
    If you want to move around in the space for the moment you'll have to click your mouse then roll the mouse wheel up to power up your thrust. Space is move forward, shift is move back, A,W,D and S are strafe - in their respective directions.
    If anyone has any clue, please let me know!
    Cheers.
    Attached Files Attached Files

  2. #2
    Title? Am I King or something?
    Join Date
    Jul 2009
    Location
    Ponyville, Happytown on the continent Nowhereland
    Posts
    26
    Sorry, but please explain what you are trying to do in much more detail. I don't know what inverseCoordinates actually is--a movieclip or a variable? Once you have done so I'll take a look and see what could be wrong.

    Good luck

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center