PDA

View Full Version : part of game not working....


hobbes_and_me
03-03-2003, 09:12 PM
Can someone familiar with actionscript please tell me what's wrong with this codes:

function moveStuff() {
if (Key.isDown(Key.LEFT)) {
dr = 1;
}
if (Key.isDown(Key.RIGHT)) {
dr = 2;
}
if (Key.isDown(Key.UP)) {
dr = 3;
}
if (Key.isDown(Key.DOWN)) {
dr = 4;
}

if (dr=1) {
this._x -= 5;
}
if (dr=2) {
this._x += 5;
}
if (dr=3) {
this._y += 5;
}
if (dr=4) {
this._y -= 5;
}
}
ball.onEnterFrame = moveStuff;

This is part of my game i am programming. I have done this game in True Basic and it works out totally fine but I am totally sucky at Flash Actionscripting cause i don't know a thing about how it works, loops, continuous checking of variables and moving stuff continuously.

By the way, i'm not trying to make a dot move when you press the directional keys, i'm trying to make it move continuously in a direction, like in the game "Snake".

hobbes_and_me
03-03-2003, 09:27 PM
LoL i realized my mistake.

Unlike other programming languages, "if then" statements had to use "==" to compare variables not "=". I was setting the variables instead!!

OMG i don't believe i didn't realize that earlier. I'm so blind...:p

hobbes_and_me
03-05-2003, 02:57 AM
I have a problem with my code again!

function addtail() {
tail.duplicateMovieClip("t" add i, 5);
if (dr == 1) {
setProperty (t add i, _x, ctailx+20);
setProperty (t add i, _y, ctaily);
} else if (dr == 2) {
setProperty (t add i, _x, ctailx-20);
setProperty (t add i, _y, ctaily);
} else if (dr == 3) {
setProperty (t add i, _x, ctailx);
setProperty (t add i, _y, ctaily-20);
} else if (dr == 4) {
setProperty (t add i, _x, ctailx);
setProperty (t add i, _y, ctaily+20);
}
i += 1;
}

What is wrong with it?? When i use trace ((t add i)._x); i get a result of "Undefined" in the output window!

RGG i'm so fed up with this new language. Can anyone help me before i go insane?:mad: