Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Questions About Random Character Movement And Hit Detection For Game [renamed]



Hey every one i was thinking of making a new game where there are rebel smiley men( because i love smileys) and you just kill them and get as high a score as you can.What i need to know is how i can make them have random movement.Not just normal random movment but when it decides to walk up it will change to a different frame within the rebel and make it face the direction of its movment.i also ened to know if when a mc moves into a invisable barrier or the rebels sight that it will try and kill the mc.Thanks in advance



KirupaForum > Flash > Game/AI Programming
Posted on: 10-12-2005, 06:42 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Game - Character Movement Problems [renamed]
Hello.

I thought i would have a go at making a platform game in Flash MX 2004.

However i can't get my charecter move
I have tried so much, however, i'm just stupid!

I am trying to script my movie clip so that:

When the key 'E' is pressed the charecter moves right.
When the key 'Q' is pressed the charecter moves left.

When the key 'W' is pressed the charecter jumps.
When the key 'S' is pressed the charecter crouches (either changses to crouching movie clip or squashes current movie script if this is possible.).

When the key 'D' is pressed the charecter moves right while crouched.
When the key 'A' is pressed the charecter moves left while crouched.


I have a charecter that is a movie clip. This is what i want to move.
When the charecter jumps or is in the air i want my charecter to fall down until it reaches a movie clip with the instance name of 'platform'
When the charecter crouches i either want it to change movieclip or sqaush the current movie clip.

The charecter must alwaysbe touching a platform unless if it is jumping


Please can someone help me?

My File
This is what i have. I have removed the actionscript that i had because it didn't work Please can someone tell me what i should put, or even better alter the file for me

Thank You

[F8] Help With Character Movement In Game
I am trying to make a game in flash 8 but i got somewhat stuck now. The thing is the character is a movie clip with various animations inside of walking, atacking, jumping, etc...
So i am using the following code:


Code:

onClipEvent (load)
{
speed = 10;
}

onClipEvent (enterFrame)
{
if (Key.isDown(Key.SPACE))
{
this.gotoAndStop(2);
}

if (Key.isDown(39))
{
this.gotoAndStop(3);
_xscale = +100;
this._x = this._x + speed;
} // end if
if (Key.isDown(37))
{ _xscale = -100;
this.gotoAndStop(3);
this._x = this._x - speed;
} // end if
if (Key.isDown(Key.CONTROL))
{
this.gotoAndStop(4);
} // end if
if (Key.isDown(Key.SHIFT))
{
this.gotoAndStop(5);
} // end if

onClipEvent (enterFrame)
{
if (Key.isDown(Key.SPACE) && !jumping)

{
vel_y = 36;
jumping = true;
} // end if
if (jumping == true)
{
vel_y = vel_y - 2;
if (vel_y <= -15)
{
vel_y = -15;
} // end if
this._y = this._y - vel_y;
} // end if
if (_root.ground.hitTest(this._x, this._y + 35, true))
{
vel_y = 0;
jumping = false;
} // end if
}
onClipEvent (enterFrame)
{
this._y = this._y + 16;
if (_root.ground.hitTest(this._x, this._y + 1, true))
{
this._y = this._y - 16;
} // end if
}
onClipEvent(enterFrame) {
//change dimensions for document width
if(this._x >= 750) {
_root.ken._x = 750;
}
if(this._x <= 10) {
_root.ken._x = 15;
}
}
Ok everything works perfectly except when i jump diagonally cause as i do that i am pressing both walk and jump button and the animation gets stuck on the first frame of the walk animation. What i want to happen is that as soon as i press space (jump) the jump animation will play the hole way through untill it finishes, even if i press any other button.

Another minor problem that is not very important is the walk animation. I want the walk animation to imediatly stop as soon as i let go of the directional buttons.
i tried using:

onClipEvent(keyUp) {
_root.character.gotoAndStop(1);
walkSpeed = 10;
But that cut all my animations as soon as i released any button, when i just want it to happen when i released the left or right button.

Any help will be greatly apreciated.

Game Character Movement Code
I am trying to make an action style game. I have the main character set up as an MC with other MCs inside it on the different frames. These are the graphics for crouching, walking right, etc. So frame 5 of the main MC is the graphic for walking right.

I have coded it so when right is pressed then the MC jumps to frame 5, but when i add in the code for walking left, nothing happens.

The current set up is 4 dynamic text boxes that display 0 or 1 depending on whether UP, DOWN, LEFT or RIGHT are pressed. The main MC then looks at these and then plays the appropriate frame. I don't know why I didn't just use straight forward

if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(5);
}

I have the FLA file ready to send via email cos its too big to fit on the forum. Please say so here or email me if you would like it. The fla has little explanations all over it to make it clearer.

I'm in flash 5 so if you do anything in MX please convert it to flash 5 format.

============
TiMo

Game Character Movement Question.
I'm making a game with a top down view like in The Legend of Zelda for SNES (not directly top down but at an angle). I want my character 'hero' to go to the walk cycle for the appropriate direction nested in the hero timeline when the arrow keys are pressed. Then, when that key is released I want him to stay facing that direction but go to the frame of him standing still. I can successfully do this with the "right" arrow key and but will play the first frame of the correct walk cycle when the other keys are pressed but when the keys are released it jump to the facing right standing still frame. The right key's code comes first so I think it's a compatibility issue with the other keys. Here is my code for the right key and it's the same for the other keys.

onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x = this._x+speed;
gotoAndPlay("WalkRight");
}
if (!Key.isDown(Key.RIGHT)) {
gotoAndStop("StandRight");
}

It makes sense that adding a variable "heroPosition" would work if when the key's are pressed have the variable be that key (ex. if right key is pressed heroPosition = "Right") and then make the second if statement for the key if (heroPosition = "Right" && !Key.isDown... etc. This doesn't work. P.S. First time poster.

Game Actionscript - Character Movement
hi guys i have this AS code and am no sure what i would need to add/change to allow the character to fall from a platform if they're no longer on it... currently the character stays at the same _y position even when its no longer on thew platform

can any1 help me out with the changes i need

heres the code i currently have


Code:
onClipEvent (load) {
y_start = _y;
jumping = false;
jumpspeed = 0;
speed = 5;

}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("Walking Left");
this._x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("Walking Right");
this._x += speed;
}
if (jumping) {
this.gotoAndStop("Jumping");
_y += jumpspeed;
jumpspeed += 1;
if (_y>=y_start) {
_y = y_start;
jumping = false;
}
} else {
if (Key.isDown(Key.SPACE)) {
jumping = true;
jumpspeed = -10;
}
}
if (_root.Platform.hitTest(this._x, this._y, true)) {
jumping = false;

}
}

Random Character Movement
I need to create something of a virtual town, it will be from the perspective of above looking down (GTA 1 style) in 2D. On one layer i have the buildings etc and on a layer beneath that i want some people to randomly be moving around.

I have some script in a controller mc that controls some random movement using three frames:

frame1:

code:
// set number of steps to reach target
loops = 0;

// create a random target
_root.target_x = Math.random()*550;
_root.target_y = Math.random()*400;

// find the difference and divide by 20 : will be distance of each step
_root.xdiv = (_root.target_x-_root.circle._x)/20;
_root.ydiv = (_root.target_y-_root.circle._y)/20;


frame2:

code:
// increment loop and step
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;


Frame3
code:
// increment loop and step again distance of single step
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;

// if 20 steps then we are at target so set a new one in Frame 1
// if not then go back to frame 2 and step again
if (loops<20) {
gotoAndPlay(2);
} else {
gotoAndPlay(1);
}


This works okay but for realism i need some changes, firstly as the mc will be a small human i need for them to be facing the direction they are travelling. I presume this will be worked out using trajectories or something but i'm useless with maths.

I also would like for them to have a set speed rather than using a set number of steps, they will move at this speed to the target until they reach it at which point a new target is set.

would really appreciate some help on this, thanks.

Random Character Movement
I need to create something of a virtual town, it will be from the perspective of above looking down (GTA 1 style) in 2D. On one layer i have the buildings etc and on a layer beneath that i want some people to randomly be moving around.

I have some script in a controller mc that controls some random movement using three frames:

frame1:


ActionScript Code:
// set number of steps to reach target
loops = 0;

// create a random target
_root.target_x = Math.random()*550;
_root.target_y = Math.random()*400;

// find the difference and divide by 20 : will be distance of each step
_root.xdiv = (_root.target_x-_root.circle._x)/20;
_root.ydiv = (_root.target_y-_root.circle._y)/20;

frame2:


ActionScript Code:
// increment loop and step
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;

Frame3

ActionScript Code:
// increment loop and step again distance of single step
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;

// if 20 steps then we are at target so set a new one in Frame 1
// if not then go back to frame 2 and step again 
if (loops<20) {
    gotoAndPlay(2);
} else {
    gotoAndPlay(1);
}

This works okay but for realism i need some changes, firstly as the mc will be a small human i need for them to be facing the direction they are travelling. I presume this will be worked out using trajectories or something but i'm useless with maths.

I also would like for them to have a set speed rather than using a set number of steps, they will move at this speed to the target until they reach it at which point a new target is set.

would really appreciate some help on this, thanks.

Game Character Movement Action Script
I have a character in a movieclip with contains movieclips on the timeline which I've applied behavior to but I have problems when I try to use any of the letter characters to apply a key press comand. Could some one please check out the attached file and see if they can offer a solution. Also can someone please provide an answer to the problem of a character returning to it's orginal position. rather than staying in the last position used.

The file can be found here -
Problem File

Flash Game Help? Multi Key Tapping For Character Movement?
Hello, im creating a racing game in flash where 3 people run along a race track the the finish line. One character will be controlled by the user in which they have to rapidly press 2 button keys as fast as they can to make the racer move. The faster they press the keys, the faster the player will run.

How do i do this? I dont know where to begin, here is an image of my game below, its very basic at the moment.
http://img503.imageshack.us/img503/1...ackraceua5.jpg

Random Movement + Collision Detection
I'm trying to make a map of my office with people (circles) moving around randomly and need a code that will tell them to move around and not run into the walls. I understand the collision detection .fla file (hittest_example) and the random movement file (randommx) but don't know how to put the two together. I also need the people to be somewhat contained within their offices and walking down the hallways... here's my .fla file if someone can help!

Random Movement + Collision Detection
I'm trying to make a map of my office with people (circles) moving around randomly and need a code that will tell them to move around and not run into the walls. I understand the collision detection .fla file (hittest_example) and the random movement file (randommx) but don't know how to put the two together. I also need the people to be somewhat contained within their offices and walking down the hallways... here's my .fla file if someone can help!

Flash 8 Racing Game Question Part1: Muti Tapping Keys For Character Movement?
Hello, im creating a racing game in flash where 3 people run along a race track the the finish line. One character will be controlled by the user in which they have to rapidly press 2 button keys as fast as they can to make the racer move. The faster they press the keys, the faster the player will run.

Question: How do i do this? I dont know where to begin, here is an image of my game below, its very basic at the moment.

How To Generate Random Questions For A Game?
HI... i'm trying to make a "Who wants to be millionaire" flash game. but the questions are allways the same and in the same order. I had an idea: let Actionscript choose 1 question out of 100... so the question DONT repeat.
But the problem is: I dont know how to generate random questions... i just know how to generate random Numbers. plz help

Movement With Acceleration [renamed]
Heyo!

Ok, i have this kinda difficult question (i think it is..) :


Let's say i have a button, and a movie, when i click on the button, i want the movie to move to another position with an accelerating effect ! How would i achieve this?


For the putton i have this code:

on (release){
instanceNameOfMovie._y = a value;
}


How can i modify it so that it will move to that value smoothly? i mean with an accelerating effect...

Movement With Acceleration [renamed]
Heyo!

Ok, i have this kinda difficult question (i think it is..) :


Let's say i have a button, and a movie, when i click on the button, i want the movie to move to another position with an accelerating effect ! How would i achieve this?


For the putton i have this code:

on (release){
instanceNameOfMovie._y = a value;
}


How can i modify it so that it will move to that value smoothly? i mean with an accelerating effect...

Menu Questions [renamed]
Hi everyone, I'm here just to ask for some little help, I have a menu with 8 buttons, I could made my buttons move with some actionscript, but all moved together and I want to insert a little delay between the buttons when animation start, could anyone knows how to achieve this.

Thank's in advanced


Mictlantecuhtli

Menu Questions [renamed]
How do I create a easy script for vertical links, which when pressed, the link moves up and content comes inbetween the link and the rest of the links. I also need it so if another link is clicked the previous returns to its original position... pleeease help...

Mouse Trail Questions [renamed]
on this mouse trail . I have two questions:

1. how can I change the color of the text?
2. how can I replace the text to gif ?

Thanks in advance !

bum

Questions About Site Tracking And Customization [renamed]
HI,
i am creating an Php mysql database driven articles site but i have

facing some problems
so that i can't continue creating my site i will very thankfulll to any

body who answer my questions,My questions are on this link

http://information-world.110mb.com/index.html

any reply will be appreciated,
thanks

[F8] String Character Detection
hi,

is there a way to detect second a and b in the following code? I want to compose code to omit first a and b and detect only second. At the moment it detects both first and second. Here is the code:


Code:
// there are 2 "a" and "b" letters in the string
var star:String = "a b c d e f a b";
for (var l = 0; l<15; l++) {
switch (star.charAt(l)) {
case "a" :
case "b" :
trace("detected:"+star.charAt(l));
break;
}
}


thanks

String Character Detection
hi,

Can anyone help me?
I would like to know if there is a way to detect from star variable second a and b in the following code? I want to compose code to omit first a and b and detect only second a and b. At the moment it detects both - first and second. And once the second a and b is detected I want it to be replaced by g and h so the star variable will have following string: "a b c d e f g h". Here is the code:


Code:
// there are 2 "a" and "b" letters in the string
var star:String = "a b c d e f a b";
for (var l = 0; l<15; l++) {
switch (star.charAt(l)) {
case "a" :
case "b" :
trace("detected:"+star.charAt(l));
break;
}
}
thanks a lot

Hittest In Rpg Game [renamed]
hey i'm kudey. i need a actionscript for a wall in a rpg game
so wat do i do first(note:i'm a bigginer)

Help With Character Movement
what I am looking for is some help with making my Character
face in the right Direction. I not to sure were to start
so if you could take a look at this fla it would probible help

http://www.mac-10.net/man1.fla

hope you can help


mac

Character Movement...
Ok, ive got 4 diff. animations of my character, each going in the respective direction. How can I change the animation for the correct direction he is heading in.. IE, If left key pressed: Left_run animation is played. This is the code I have so far for general movement:

onClipEvent (load) {
inc = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += inc;
}
if (Key.isDown(Key.LEFT)) {
this._x -= inc;
}
if (Key.isDown(Key.UP)) {
this._y -= inc;
}
if (Key.isDown(Key.DOWN)) {
this._y += inc;
}
}
onClipEvent (load) {
}

thanks guys,
Tman

Character Movement
I am currently making a game where you controll a character with you arrow keys you know the usual thing.

Well I was wondering if there is a better way to stop the movement if you encounter a wall or a object.
//this is my charachter controll(it's a semi 3d perspective so thats why the x is larger then the y//

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.slide._x = _root.slide._x+5.5;
}
if (Key.isDown(Key.LEFT)) {
_root.slide._x = _root.slide._x-5.5;
}
if (Key.isDown(Key.UP)) {
_root.slide._y = _root.slide._y-4;
}
if (Key.isDown(Key.DOWN)) {
_root.slide._y = _root.slide._y+4;
}
}

//this is the code in each object that stops the movement(slide is the character)//

onClipEvent (enterFrame) {
/:status = hitTest(_root.slide._x, _root.slide._y, true);
}
onClipEvent (enterFrame) {
if (/:status==true&&Key.isDown(Key.RIGHT)) {
_root.slide._x = _root.slide._x-5.5;
}
if (/:status==true&&Key.isDown(Key.LEFT)) {
_root.slide._x = _root.slide._x+5.5;
}
if (/:status==true&&Key.isDown(Key.UP)) {
_root.slide._y = _root.slide._y+4;
}
if (/:status==true&&Key.isDown(Key.DOWN)) {
_root.slide._y = _root.slide._y-4;
}
}

Well that works fine but it's not that smooth with that code in each object.

Character Movement
Is there any way to detect if both the up key and left key are down? I am making an animation where a character walks and I want to have a frame for each direction up, down and right and left is no problem but to detect if both the up and left keys are down doesn't work! Any suggestions?

Character Movement? Ne1 Pls
Hi,
I am really strugglin to find a solution.. ne help is much appreciated. I am using MX, I am trying to make a man walk around the screen using the arrow keys from a birdseye view. That all works but when no keys are pressed i would like the script to jump to a frame where there is a movie clip where the character looks up as if to say (i'm waiting) i can get this to work by telling the script to jump to frame label stop. The problem with this is that the stop label animation only faces one way so (say the stop animation movieclip is facing up) if you are walking down and then release the down key, the clip flicks to the up position and looks messy. How can i get the stop movie clip to face the way of the last key press?

I hope i have made myself clear?
here is the script i am using which is attached to the 'man' movieclip

onClipEvent (load) {
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.man.gotoAndStop("right");
this._x += moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
_root.man.gotoAndStop("left");
this._x -= moveSpeed;
} else if (Key.isDown(Key.DOWN)) {
_root.man.gotoAndStop("down");
this._y += moveSpeed;
} else if (Key.isDown(Key.UP)) {
_root.man.gotoAndStop("up");
this._y -= moveSpeed;

} else {
_root.man.gotoAndStop ("stop");
}
}

Character Movement
I have a character that has a walking animation and I want that animation to play when the person presses left or right, along with ther character moving left or right this is what i have so far

__________________________________________
onClipEvent (enterFrame) {
speed = 5;
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
}
on (keyPress "<Left>") {
_root.character.gotoAndPlay(6);
}
on (keyPress "<Right>") {
_root.character.gotoAndPlay(2);
}
___________________________________
this works, the character moves from left to right and the walking animation goes, but after a while the walking animation seems to repeat the first frame or two, also how would i make it stop when he button isnt being pressed

Character Movement
Hey ive started on a little flash game, its just a 2D top down thing.

What im trying to do is being able to rotate and then walk in that direction.

I had up, down, left, right turning before but its not really what im after.
I have the rotation stuff working but it never moves in the exact direction your facing its normaly like 20 degrees off.
I know why this is but not how to fix it, and to fix it I need a different method of calculating the next x,y position.

Ok and the other thing to do with this is the hit detection to go with it, it needs to then calculate 3 points for left center and right positions of the character.

Character Movement
hie.. i'm still very new in flash...especially actionscript. I would like to ask about the actionscript. Currently, I'm developing an adventure game. I have design several characters already. How can I make them react to the key I press? (up - move up). I had created several layers of different movement so that it will look like a real walking. I really need your help, guys. Thanks~

Character Movement
should i combine all the movements using different layers in a single .fla or combine all of them in different frames in a single layer? please help...

Character Movement
Here is how i coded for the character to move:
-----------------------------------------------------------------

1.am clear how i want to navigate the character to the desired spot

2.am also able to initialise the walk animation once clicked.

3.my problem is am not able to stop walking animation of the guy once he reached the spot.

-----------------------------------------------------------------------------------------------
onClipEvent(load){
_x=0;
_y=200;
}
onClipEvent(mouseDown){
//jump to clicked location
targetx=_root._xmouse;
_root.man_mc.man.gotoAndStop("right")
if(distx==_root._xmouse){
_root.man_mc.man.gotoAndStop("idle")
}
}
onClipEvent(enterFrame){
//the amount of distance to travel to click spot
distx=targetx-_x
//speed and easing factor character to reach the spot
movex=distx/20
_x+=movex;
}


-----------------------------------------------------------------------------------------------------
and more over i need to make him walk facing left side, when he need to
travel left side from his current position.

I have attached the file for your reference.
thanks in advance.
da_hammer

Character Movement
Hi,

I'm putting together a simple game for a client and I've come across a small problem.

I have a simple character, which moves upon key presses (cursor keys).

This is the code I have so far. (keyspeed is defined as 5)

onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-keyspeed;
}
if (Key.isDown(38)) {
_y=_y-keyspeed;
}
if (Key.isDown(39)) {
_x=_x+keyspeed;
}
if (Key.isDown(40)) {
_y=_y+keyspeed;
}
}

This works fine. What I need to happen now is, say, when key 37 (left) is pressed, the character (movieclip called character) should goto and play a new part which shows the character walking left. When key 39 (right) is pressed, character should goto and play a new part which shows the character walking right. And so on. If no key is pressed, then I want the character to play another part of it's movieclip where the character stand still This is the new code I therefore have:

onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-keyspeed;
_root.character.gotoAndStop("walkleft");
}
else if (Key.isDown(38)) {
_y=_y-keyspeed;
_root.character.gotoAndStop("walkup");
}
else if (Key.isDown(39)) {
_x=_x+keyspeed;
_root.character.gotoAndStop("walkright");
}
else if (Key.isDown(40)) {
_y=_y+keyspeed;
_root.character.gotoAndStop("walkdown");
}
}
else {
_root.character.gotoAndStop("standstill");
}
}

But this doesn't work. The character won't jump to the designated frame labels.

Can anyone suggest why this is happening? I'm know is something really, really simple and I'm going mad. I have every other aspect of the game working (health, collectables, hittest etc) just not this damn simple thing.

Any help would be gratefully received.

Thanks In Advance

Steve

Help With Character Movement
Sorry if this is in the wrong catagory. This is my first time to the forums here.

I've been searching all around the web, trying to find help for something that seemed so simple; the action code for making a character jump.

I'm able to move the character left and right just fine, but I can't figure out exactly how to make it jump up into the air.

If you could help, I'd greatly appreciate it.

Character Movement
Hey guys I am fairly new to flash and I have been having a bit of trouble with a game I am trying to make so I need a little help.

What I am trying to do is to get the little character in the middle of my screen to move in different directions using the arrow keys. I have gone through many different tutorials on the subject but I can't seem to get it to work. I uploaded my .fla in hope that some of you might be able to help me out and show me the right way to do this.

I am always open to learning anything so just tell me if it was something dumb that I overlooked. Thanks so much for the help guys.

[MX] Character Movement?
ok I have this character, that I want to go left, and I want it to change to another movie clip that appears to being going left. using this code I am able to go left but the removeMovieClip(); and attachMovie() doesn't work...please help


Code:
onClipEvent (enterFrame) {
if (Key.isDown(KEY.LEFT)) {
this._x -=10;
removeMovieClip(this);
attachMovie(charleft,charleft,_parent.getNextHighestDepth());
}
}

[F8] Character Movement
Hi, i created a flash game. I have my character moving and everything, but i want where i paint to be a boundary that rolls over and resets screen to frame 1. what is the code for this?

Character Movement
hello there, i just wanna ask if there someone who can help me in creating this kind of effect,
http://www.ff0000.com/
i like to know how to make those characters move, and i think there is also a physics there bec the character movement is slow decreasing when you stop clicking the arrow button

hope you guys to help me in here.

Help With Character Movement
I heave been working very hard to get a character to walk around and jump. I cannot get this to work for the life of me.

I got the solution from here: :http://www.rit.edu/~ndr0470/game_physics/

and I have this following code in my program but it will not work. My movie clips name is player and the bottom of my clip is 450 pixels, can anyone help me? I have been working on making a juimping guy for a day or two, this is starting to get sad. Thanks

//variables

var gravity = 3;
var moving = false;
var jumping = false;

function GameLoop() {
if(jumping == false && Key.isDown(Key.SPACE) == true ){
dy = 20;
jumping = true;
}
if (jumping == true){
if( player._y + dy > 450 ){
player._y = player._y + dy;
dy = dy - gravity;
}
else {
jumping = false;
}
}
if(moving == false && Key.isDown(Key.LEFT) == true){
moving = true;
dx = -10;
}

else if(moving == false && Key.isDown(Key.RIGHT) == true){
moving = true;
dx = 10;
}

else {
moving == false;
}

if (moving == true){
player._x = player._x + dx;
}
}

Character Movement.
I need a script within actionscript that will make an MC called CAR move with the key pads, does anyone have a script I could use.

Thanks sephers181

Random Variables [renamed]
I've been working on a deal or no deal game (my first game) and I'm stuck. I just need a script to make 22 variables that are randomly equal to numbers 1 - 22, so I get a result like this:

box01 = side09;
box02 = side12;
box03 = side19;
...
...
box22 = side04;

thanks


EDIT: I should probably clarify that all 22 numbers need to be different.

Code For Character Movement Please.
I have certain codes that I picked up and even tried my own, but how can i make the character move in the same direction as the arrow. You know like so when you press the left arrow it turns left instead of going backwards. Your replies will be very apreciated.

Thanks all who at least review this,

Character Animation And Movement Help
My charcter has 7 frames. The first one is the still one which I put stop() on. Then when it gets to frame 7, I have gotoAndPlay(2). For my movement code I used:

Code:
onClipEvent(enterFrame){
if (Key.isDown(Key.DOWN)) {
move(0, 4);
_parent.gotoAndPlay(4);
}
}
//
onClipEvent (keyUp) {
if (!Key.isDown(Key.DOWN)) {
_parent.gotoAndStop(1);
}
}
The problem is that it only plays the first frame of the animation.

Character Movement + Actions
I am making a flash game based off of the playstation game castlevaniaL symphony of the night (view what i made so far at www.coreyisgod.com/sotn.html) but it has hence become really tedious and confusing with only the basic buggy movement i still have. here is the action controlling the movement
onClipEvent (load) {
move = 10;
}
onClipEvent (enterFrame) {
{
if ((Key.isDown(Key.RIGHT)) or (Key.isDown(Key.DOWN)) or (Key.isDown(Key.LEFT)) or (Key.isDown(Key.CONTROL))) {
{
if ((Key.isDown(Key.RIGHT))) {
this._xscale = 175;
gotoAndStop (1);
move = 10;
//cant move while ducking
if (Key.isDown(Key.DOWN)) {
move = 0;
}
this._x = this._x+move;
}
// code for left key press
if ((Key.isDown(Key.LEFT))) {
this._xscale = -175;
gotoAndStop (1);
move = 10;
//cant move while ducking
if (Key.isDown(Key.DOWN)) {
move = 0;
}
this._x = this._x-move;
}
// code for down key press
if ((Key.isDown(Key.DOWN))) {
gotoAndStop (2);
move = 0;
}
} else {
// display standing still
gotoAndStop (4);
}
}

the movie clip contains movie clips that activate when certain buttons are pressed... but this is getting monotonous

is there a better way to control characters for attacking, jumping, walking, ducking, etc, and play the animation of each? (flash 5 or mx)

Character Movement And Actions
I am making a flash game based off of the playstation game castlevaniaL symphony of the night (view what i made so far at www.coreyisgod.com/sotn.html) but it has hence become really tedious and confusing with only the basic buggy movement i still have. here is the action controlling the movement
onClipEvent (load) {
move = 10;
}
onClipEvent (enterFrame) {
{
if ((Key.isDown(Key.RIGHT)) or (Key.isDown(Key.DOWN)) or (Key.isDown(Key.LEFT)) or (Key.isDown(Key.CONTROL))) {
{
if ((Key.isDown(Key.RIGHT))) {
this._xscale = 175;
gotoAndStop (1);
move = 10;
//cant move while ducking
if (Key.isDown(Key.DOWN)) {
move = 0;
}
this._x = this._x+move;
}
// code for left key press
if ((Key.isDown(Key.LEFT))) {
this._xscale = -175;
gotoAndStop (1);
move = 10;
//cant move while ducking
if (Key.isDown(Key.DOWN)) {
move = 0;
}
this._x = this._x-move;
}
// code for down key press
if ((Key.isDown(Key.DOWN))) {
gotoAndStop (2);
move = 0;
}
} else {
// display standing still
gotoAndStop (4);
}
}

the movie clip contains movie clips that activate when certain buttons are pressed... but this is getting monotonous

is there a better way to control characters for attacking, jumping, walking, ducking, etc, and play the animation of each? (flash 5 or mx)

Character Movement With Mouse
Okay, i want to make a character and have him move to the spot where you clicked. so when you move your mouse in a direction he looks that way, and when u click somewhere like here -------------> he moves there!
If you can help please help!
Thank-u Codien Flame #1

[F5] Character Movement With Acceleration
onClipEvent (enterFrame) {

moveSpeed = 0;
_root.maincharacter._y += moveSpeed;

}

How would I alter this code so that when the 'maincharacter' falls, starting at moveSpeed = 0, it starts to gain more speed (as time or frames pass, whichever is easier). I would think it would be something like (_root.maincharacter._y += moveSpeed+acceleration*time), but I don't know exactly how to pull it off. Thanks!

Character Movement Problem
ok, so i'm working on making a game, and in this first part, i'm trying to play an animation and move the character when i press one button. Problem is, the character does not go through the entire, it goes through part of it once and just repeats, even if the key is off. I know the problem, but not how to fix it. I need to come up with an alternative to "onEnterFrame", because i think that makes it restart each time i go through the frame. here's my code:

this.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
this._y -= 5;
gotoAndPlay(2);
} else if (Key.isDown(Key.DOWN)) {
this._y += 5;
gotoAndPlay(7);
} else if (Key.isDown(Key.LEFT)) {
this._x -= 5;
gotoAndPlay(20);
} else if (Key.isDown(Key.RIGHT)) {
this._x += 5;
gotoAndPlay(14);
}
};

if anyone knows how to make it stop when i don't hit a key, and make it go through the entire animation, it would be great. thanks ^^

Character Movement + Rotation
Hello,
I am currently working on a car racing game but I am new to designing the engine for my game such as the physics for my car. So, I took help from a tutorial but could'nt quite understand the trigonometry part, can you explain it.
The part I did not understand was,
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.hit.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
Hope you can help me out,
Thanking You,
Chinmaya

P.S. I know how to convert degrees to radians and know a little about unit circles. The main part I dont understand is that why do we multiply the sin of angle(in radians) to the speed!







Attach Code

onClipEvent (load) {
speed = 0;
}
onClipEvent (enterFrame) {
// make the car go forward
speed += 0.1;
// tells the car to slow down after the speed of 20
if (Math.abs(speed)>20) {
speed *= .7;
}
// you can change the rotation of the car to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
// here is where the hittest is for the boundary
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.hit.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}

Copyright © 2005-08 www.BigResource.com, All rights reserved