BOUNDARY PROBLEM PLEASE HELP :(

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   BOUNDARY PROBLEM PLEASE HELP :(
ale_geo
CZ Newbie
ale_geo has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Dec 05, 2005
0.00 posts per day
Posts: 2
Points: 73
   
hi all

i have managed to get the top right and left boundaries to work but the bottom boundary allows my car to drive straight thru it into nothingness and out of the game;

im a reveltive begginer to flash, i have pasted my script for the car below so maybe someone can help and tell me where i am going wrong, my stage size is 550 by 400 if that helps. i have tried some different combinations, but they just didnt work!!

onClipEvent (enterFrame) {
//When key UP is pressed, speed is increased
if (Key.isDown(Key.UP)) {
speed += 1;
} else {
//When key DOWN is pressed, speed is decreased
if (Key.isDown(Key.DOWN)) {
speed -= 1;
} else {
//If UP or DOWN aren't pressed then the speed decreases
speed *= .9
}
}
//The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .6;
}
//Turns the car left
if (Key.isDown(Key.LEFT)) {
_rotation -= speed;
}
//Turns the car right
if (Key.isDown(Key.RIGHT)) {
_rotation += speed;
}
//Moves the car
speed *= .9;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.3;
}
}
onClipEvent(enterFrame) {
if (_y>550) {
_y=550;
}
if (_y<0) {
_y=0;
}
if (_x>550) {
_x=550;
}
if (_x<0) {
_x=0;
}
}

p.s. i need to add a boundary to split the screen because i am making a 2 player game, how do i add a single line boundary??

your help will be much appriciated, thanks again, Georgie



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum