PDA

View Full Version : Need help new to game design in flash



Ebreezesoccer
September 13th, 2006, 12:54 PM
I am wanting to create a flash game that involves driving and shooting of a tank. I want to be able to drive the tank down a road that has a movie clip in the background that moves while you are moving the tank and stops when you stop moving the tank. I want to also be able to shot the objects in the background as they pass by. I have no idea how to do this so any help would be greatly appreciated or any tutorials that relate to this type of game would help as well.

Thank you

Ebreezesoccer
September 13th, 2006, 03:36 PM
I know how to create the tank and make it move and shoot, i already have this done. I dont know however how to create the background that moves along with the movement of the tank. I also dont know how to make some of the background things that move by able to be hit by the tank when it shoots at them. That is what i need help on, and yes i have looked on this forum. Any help would be greatly appreciated.

LittleFenris
September 13th, 2006, 03:47 PM
One thing people will need to know is if you are doing a tile-based or art-based game.

Joppe
September 13th, 2006, 04:25 PM
Well if you move the tank._x += 5; you could have map._x -= 5;

same thing really ;)

Ebreezesoccer
September 14th, 2006, 09:37 AM
I am going to be creating an art-based game

Joppe
September 14th, 2006, 09:45 AM
Do a search for character movement in this forum. Basically instead of moving your character around the screen, you will move the background to it looks as if the character is moving, but he's staying in the middle of the scene (you'll take a character movement setup and reverse the + and - symbols cause the background will have to go the opposite way to look like the character is going in the right direction. I ended up giving up on that movement idea for my art-based project because it was using way too much CPU power. I'm sure this is why people go w/ tile-based games a lot of times but I don't have a clue where to begin to make a tile-based engine.

Here is all the code from my art based project that moves the background (a movieclip called "scene_mc"). There is some collision detecting in this script to so the character doesn't walk over things they aren't supposed to like walls and such. I just used a movieclip called "hitSpot1_mc" "hitSpot2_mc" etc...for the spots the character can't go past.


var characterDirection = "down";
var speed:Number = 4;
var run:Number = 0;
var standing = 1;
var totalHitSpots:Number = 12;
//SCENE CONTROLS
scene_mc.onEnterFrame = function() {
if (Key.isDown(Key.SHIFT)) {
speed = 6;
run = 1;
} else {
speed = 4;
run = 0;
}
if (Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
characterDirection = "up";
this._y += speed;
} else if (Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
characterDirection = "down";
this._y -= speed;
} else if (Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) {
characterDirection = "left";
this._x += speed;
} else if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
characterDirection = "right";
this._x -= speed;
} else if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
characterDirection = "upleft";
this._y += speed;
this._x += speed;
} else if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
characterDirection = "upright";
this._y += speed;
this._x -= speed;
} else if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
characterDirection = "downright";
this._y -= speed;
this._x -= speed;
} else if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
characterDirection = "downleft";
this._y -= speed;
this._x += speed;
}
};
//CHARACTER CINTROLS
character_mc.onEnterFrame = function() {
if (characterDirection == "up") {
this.gotoAndStop("up");
}
if (characterDirection == "upright") {
this.gotoAndStop("upright");
}
if (characterDirection == "right") {
this.gotoAndStop("right");
}
if (characterDirection == "downright") {
this.gotoAndStop("downright");
}
if (characterDirection == "down") {
this.gotoAndStop("down");
}
if (characterDirection == "downleft") {
this.gotoAndStop("downleft");
}
if (characterDirection == "left") {
this.gotoAndStop("left");
}
if (characterDirection == "upleft") {
this.gotoAndStop("upleft");
}
//STOP CHARACTER FROM GOING OVER OBJECTS
for (i=1; i<=totalHitSpots; i++) {
if ((characterDirection == "right") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x += speed;
foreGround_mc._x += speed;
}
if ((characterDirection == "upright") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x += speed;
scene_mc._y -= speed;
foreGround_mc._x += speed;
foreGround_mc._y -= speed;
}
if ((characterDirection == "left") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x -= speed;
foreGround_mc._x -= speed;
}
if ((characterDirection == "upleft") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._x -= speed;
scene_mc._y -= speed;
foreGround_mc._x -= speed;
foreGround_mc._y -= speed;
}
if ((characterDirection == "down") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
foreGround_mc._y += speed;
}
if ((characterDirection == "downleft") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
scene_mc._x -= speed;
foreGround_mc._y += speed;
foreGround_mc._x -= speed;
}
if ((characterDirection == "downright") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y += speed;
scene_mc._x += speed;
foreGround_mc._y += speed;
foreGround_mc._x += speed;
}
if ((characterDirection == "up") && (this.characterHitArea_mc.hitTest(scene_mc["hitSpot"+i+"_mc"]))) {
scene_mc._y -= speed;
foreGround_mc._y -= speed;
}
//MAKE ALL HITSPOTS INVISIBLE TO VIEWER
scene_mc["hitSpot"+i+"_mc"]._visible = false;
this.characterHitArea_mc._visible = false;
foreGround_mc._visible = false;
}
};
//SHOW DIRECTION OF CHARACTER FOR TESTING PURPOSES
this.onEnterFrame = function() {
if (!Key.isDown(Key.DOWN) && !Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
standing = 1;
} else {
standing = 0;
}
trace(characterDirection);
trace("run ="+run);
trace("standing ="+standing);
};

Hopefully this helps you some.

Quoting little Fenris a bit hehe :)