Help with bullets please?

iamEvoiamEvo Member Posts: 6
edited November -1 in Working with GS (Mac)
I need help getting my guy to fire bullets in all directions. I have looked at the shoot um up template and all i can do is get them to fire right.
What i want is for them to fire left "when my guy looks left" and "right when he looks" right

Comments

  • jb15jb15 Member Posts: 602
    I'm sure there are better ways out there--but here's one way:

    I assume you have rules like this:

    When <- is down, move left.
    When -> is down, move right.

    What you need to do is add a self.attribute that is left or right:
    1 = facing right
    0 = facing left

    Then set it so that:

    When <- is down, move left, and set self.attribute to 0.
    When -> is down, move right, and set self.attribute to 1.

    Then, when space is down:
    If self.attribute = 0, spawn bullet at (whatever x and y position) direction 180.
    If self.attribute = 1, spawn bullet at (whatever x and y position) direction 0.
  • iamEvoiamEvo Member Posts: 6
    im still having a hard time. do i need to add a integer attribute? or should i just change it in the rule?
  • jb15jb15 Member Posts: 602
    Yeah, and integer would work. It could be a global attribute, or a self attribute. I'd suggest self, just to keep things clean--or if you have multiple characters.
Sign In or Register to comment.