|
-
XRave
Car boundary lines HELP!!! It drives outta screen
I got a car game but when i drive the car, it can go outta my screen! What should i do to prevent that?
Please give me the script as i am a newbie and do not understand how variables worked...
thanks if you can give me the answer
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Didn't do it.
Hey, Tongxn.
Please take a few minutes and read through the guide sticky at the top of the forums; note especially the section on providing all necessary information for your question.
From the information you have provided, there is little that I or anyone else can do to help; is this a side-view or top-view game? what code are you using to move the car?
If you can cut and paste the code you are using, we might be able to help.
Hush child. japangreg can do what he wants. - PAlexC
That was Zen - this is Tao.
-
XRave
I am using the code from the turtorial Car movement from FK, but the tutorial didn't say what to do to stop the car running out of the boundary lines of the screen. someone told me to do hittest but their information's not complete either...
Anyway, i got this frontpage saying which car do u want, and then there's 4 scenes each containing a car and the background is the same. but i found out that the car just drive out of the screen and it drives me mad!
Any ideas would be appreasiated.
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
magnetologicus
hello tongx think in terms of _x and _ys you dont really need hittest() for keeping your car within the screen boundaries
for left to right just check if _x is less or greater then the stage width if so stop car
for up and down check if _ y is less or greater then stage hieght if so stop car
also posting your fla or some code would be good
hope it helps
-
Script kiddie
If you can understand a car script, it should be bloody easy for you to add boundaries. Here's the pseduo-script, you'll use it after the movement script:
if car's _x is more than the max x boundary,
set car's _x to max x boundary.
else if car's _x is less than min x boundary,
set car's _x to min x boundary.
if car's _y is more than the max y boundary,
set car's _y to max y boundary.
else if car's _y is less than min y boundary,
set car's _y to min y boundary.
It doesn't take an expert to figure this out. Hell, you should've been able to do it without any help if you understood the tutorial...
-
XRave
Alright I get the point, but how do you stop the car from moving?
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Script kiddie
If it's constantly being moved back to the furthest place it will go, it will appear as if it isn't moving at all. For instance, if it's 25 pixels away from the left border, and moves 100 pixels to the left (a bit unrealistic, but still), it gets moved back 75 pixels. Now it's right on the border. If it continues moving at that speed next frame, it will move 100 pixels left, and be pushed back 100 pixels to the right. This will happen again the next frame, and the next frame, and so on, until it changes direction.
-
XRave
sorry, I didn't get that, i am rubbish at guessing ASs...
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Style Through Simplicity
Basicly, if you set boundrys to the game e.g.
Code:
minX = 0
maxX = 500
minY = 0
maxY = 500
where you change the numbers to whatever space you want you car to be able to drive in, then when you detect that the car has gone outside one of these boundrys
Code:
if (car._x > maxX) {
Then you can place the car ON the boundry
This will make it look like the car isnt moving because it all happens in 1 frame.
Ali
-
Style Through Simplicity
-
XRave
wow man, u got that going on!
THANKS
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Hey, I know! Delete the car MC and then it can't drive out of the boundries! Damn, I'm a genius...
-
 Originally Posted by bloghogger1
Hey, I know! Delete the car MC and then it can't drive out of the boundries! Damn, I'm a genius...
Or a dumb spammer.
-
no, i would go with smart ass. that's A S S! not ass with some stupid stars. @$$! i can beat the system!
other options with walls:
Code:
if (land.hitTest(car._x, car._y, true)) {
car.speed *= -.7;
}
-
-
XRave
no thanks, i think the original post by alillm's better
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Spaghetti-Code Extraordinaire
nevermind...
I must have been in a real bad mood when I posted this.
Last edited by hippofungus; 10-21-2005 at 11:16 AM.
"You teach a child to read, and he or her will be able to pass a literacy test."
Source: United Press International, "Bush Proposes Increase in Education Funds," Mark Kukis, Feb. 21, 2001
-
Honestly, I didn't post that. I'm guessing my friend did, seeing as how he was looking around flashkit when I was in the bathroom.
Sorry 'bout that!
-
XRave
Never Mind.... We all need a laugh sometimes...
:P
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|