A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Making a shooting game

Hybrid View

  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    82
    Can anyone help!??

  2. #2
    Modulator Katnap Kaos's Avatar
    Join Date
    Nov 2003
    Location
    A shoebox outside of SM Megamall
    Posts
    149
    Since your Bullet is moving, I'm assuming you've put in an element of speed. So lets see here:

    Code:
    vel = the speed you want the bullet to travel
    if it's going:

    Code:
    UP
    speedY = -vel;
    speedX = 0;
    
    DOWN
    speedY = vel;
    speedX = 0;
    
    LEFT
    speedY = 0;
    speedX = -vel;
    
    RIGHT
    speedY = 0;
    speedX = vel;
    and so on and so forth (I hope you don't need me to explain the other 4 directions)

    So, all you need to do is get the direction the man is facing:

    Code:
    function getFacing(){
    	you should be able to
    	figure something out
    	here, otherwise just email
    	me, or just say so.
    	
    	return x, y; /*tell us whether x is going to be positive,
    	negative or zero, and do the same for y. That should send
    	our projectiles in the right direction.
    	*/
    }
    Now that you know which direction the man is facing, you should know what the x and y components of speed are going to be (in other words, is the bullet going left, right or neither. Is it going up, down or neither).

    Now all you need to do is shoot the bullet in that direction e.g.

    Actions for an MC named bullet_034, where vel = 5 or whatever, and the man is facing LEFT:
    Code:
    onClipEvent(load){//You don't really need this onClipEvent(load).
    	speedX = -vel;//When you create your bullet using attachMovie(),
    	speedY = 0;//You can tell it these properties anyways.
    }
    onClipEvent(enterFrame){
    	this._x += speedX;
    	this._y += speedY;
    }
    Hope this helps.
    As a Gamer, you play by the rules.
    As a Programmer, you play as God.

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