Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Car game help: Moving forward relative to the direction changes.

Guest
Apr 02, 2013 Apr 02, 2013

Hey,

Just wondering how I can determine what coordinates my car needs to when I press up on my keyboard relative to the directions the car steers to.

Basically, when I steering the car I want it to still go forward after I've steered.

Here's the function I have prepared already:



public function actions(event:Event):void {



if (upKeyDown) {








}



if (rightKeyDown) {




this.rotation+=steering;



}



if (leftKeyDown) {




this.rotation-=steering;



}


}
TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Apr 02, 2013 Apr 02, 2013

Look for the line where its says:

velocityX = Math.sin (this.rotation * Math.PI / 180) * speed;

this velocityX (and velocityY) is used in the enter_frame function to set the cars position on stage

Translate
Guru ,
Apr 02, 2013 Apr 02, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 02, 2013 Apr 02, 2013

I've already been to that website, my problem was I don't understand where those variables were being used on the car x and y coordinates. I can only see them being set and not used. Care to explain how they are being used on the car object?

Thanks for the reply.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 02, 2013 Apr 02, 2013
LATEST

Look for the line where its says:

velocityX = Math.sin (this.rotation * Math.PI / 180) * speed;

this velocityX (and velocityY) is used in the enter_frame function to set the cars position on stage

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines