Jump to content


Photo

another image_angle code problem


  • Please log in to reply
5 replies to this topic

#1 matthewberry23

matthewberry23

    GMC Member

  • New Member
  • 45 posts
  • Version:Unknown

Posted 12 July 2012 - 01:18 PM

i was using this code to determine the image angle of a rocket.

image_angle = point_direction(x,y,mouse_x,mouse_y) +270

it works perfectly, but im currently changing the way my game works. instead of the rocket moving towards the mouse, it now moves in the direction the plane is travelling. I would like the image angle to be the direction of travel and have tried a few codes, but just cant figure it out.
  • 0

#2 TsukaYuriko

TsukaYuriko

    GMC Member

  • GMC Member
  • 510 posts
  • Version:GM:Studio

Posted 12 July 2012 - 01:20 PM

image_angle = direction;
Simple enough, right? :)
Also, about that +270 part... I suggest you rotate your rocket sprite to make it point to the right by default, so you won't have to add +270 every time.

Edited by TsukaYuriko, 12 July 2012 - 01:20 PM.

  • 0

#3 matthewberry23

matthewberry23

    GMC Member

  • New Member
  • 45 posts
  • Version:Unknown

Posted 12 July 2012 - 01:29 PM

image_angle = direction;
Simple enough, right? :)
Also, about that +270 part... I suggest you rotate your rocket sprite to make it point to the right by default, so you won't have to add +270 every time.


i tried image_angle=direction and it didnt seem to work, maybe i did something wrong. i'll try it again.

EDIT

i dont know what im doing wrong, but image_angle=direction doesnt work

Edited by matthewberry23, 12 July 2012 - 01:32 PM.

  • 0

#4 TsukaYuriko

TsukaYuriko

    GMC Member

  • GMC Member
  • 510 posts
  • Version:GM:Studio

Posted 12 July 2012 - 01:51 PM

Provide the code you use to make the rocket move, then. (e.g. if you're not using direction, setting image_angle to direction won't work, obviously.)
  • 0

#5 matthewberry23

matthewberry23

    GMC Member

  • New Member
  • 45 posts
  • Version:Unknown

Posted 12 July 2012 - 02:03 PM

Provide the code you use to make the rocket move, then. (e.g. if you're not using direction, setting image_angle to direction won't work, obviously.)


if can_shoot=1
if global.rocket1=1
{ID=instance_create(x,y,rocket_obj)
with (ID) motion_set(global.angle,20)
alarm[0]=global.spd
can_shoot=0}

the code shoots the rocket in the direction the plane is travelling.
  • 0

#6 TsukaYuriko

TsukaYuriko

    GMC Member

  • GMC Member
  • 510 posts
  • Version:GM:Studio

Posted 12 July 2012 - 02:12 PM

Then the code I posted above will work. Depending on where you use it, of course - it was meant to go in the rocket's step event, so if it's not there, there's the problem. However, since the rocket doesn't seem to change direction, change the following line:
with (ID) motion_set(global.angle,20)
...to this:
with (ID) {
    motion_set(global.angle, 20);
    image_angle = direction; 
    } 
...so you don't repeatedly set the variable although it always stays the same.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users