Bullets In Gamesalad!?

EminemEminem Member Posts: 667
edited November -1 in Working with GS (Mac)
I have a actor and i want it to release / spawn an actor (Bullet) anyway i can do this ? and the way i want this is when the user taps on the enemy the bullet will then goto the actor that is pressed

any clue how i can do this?

Many Thanks!

Comments

  • chosenonestudioschosenonestudios Member Posts: 1,714
  • EminemEminem Member Posts: 667
    ?
  • EminemEminem Member Posts: 667
    i need bullets not a d-pad control
  • quantumsheepquantumsheep Member Posts: 8,188
    Tshirtbooth made this demo for me almost a year ago:

    http://gamesalad.com/game/play/24892

    It forms the basis for my next game :D

    Thing is, that I've found it works great for 90% of the time. Which is obviously a problem. It needs to work ALL the time.

    Still, unless someone like Tshirt or FMG come up with something better (hint hint) this is probably your best bet.

    Cheers,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Your question makes me think you may want to crawl before you sprint. :)

    Let's start with the easier part. Spawning a bullet:

    create a bullet actor.
    Put a move behavior in this actor. Set the speed to whatever and the direction to 0 to actor.

    Create a shooter actor
    For now try this - Rule - when spacebar is pressed
    spawn bullet
    0 to actor.

    Assuming your image for the shooter actor is facing to the right (as it should be in GS) the bullet will come out of the front of the actor no matter which way you have rotated it. So this is good to use with a joystick or d pad or tilt controls that cause your shooter to rotate.

    Now, to have the bullet go directly to an actor that has been selected could be trickier. You will need to have a game attribute for the X and the Y of the enemy actor. An easier way of doing this would be to have one boolean attribute called game.fire.

    Rule (in the enemy)
    when touch is pressed change game.fire to true (1)

    in shooter
    Rule when game.fire is true
    spawn bullet

    in bullet
    move - for the direction you will need to use VectorToAngle(game.touch.1.X-sef.positionX,game.touch.1Y-self.positionY)
    speed to whatever you want

    (you could try move to instead in the bullet and just put the two touch coordinates in for x and y but I have found "move to" to be buggy.

    good luck!
  • EminemEminem Member Posts: 667
    Thx Guys Worked perfectly thank you , quantumsheep and scitunes
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Here you go QS:

    http://gamesalad.com/game/play/76515

    Makes me think of this



    CHALLENGE! I couldn't resist a chance to out do the mighty TSB!
  • quantumsheepquantumsheep Member Posts: 8,188
    Hehehe!

    Nice try, sunshine, but if you click multiple times the bullets all go to one place!

    CHALLENGE!!!!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Ahh, now I see what you mean!

    Let me get me tap shoes on and see what I can do...
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Do you need ti stop at a certain point?
  • quantumsheepquantumsheep Member Posts: 8,188
    You do know this isn't really important and you don't have to do any of this, right?

    Right???

    ;)

    Yep - what happens is you tap on the screen - and the bullet goes to that point and is then destroyed.

    Unless it hits something along the way - in which case it hits the object and the bullet is destroyed then.

    Like I said, it works 90% of the time. I *was* going to send CodeMonkey a video of a crying sheep with my gameproject.

    Can you spare him the guilt?

    :D

    QS :D

    Edit: And what I mean by 90% of the time is you can play through a level just fine, and everything works great when you play through it a few times.

    *THEN* - sometimes what happens is that the first bullet doesn't go to where you tap it, but off by quite a bit. Say you tapped to the right, it would go straight up for example.

    Not good! :(

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • ORBZORBZ Member Posts: 1,304
    Challenge did you say? I think I win ;) Not to sound cocky but this is the fastest and simplest way to do this, it's better than t-shirt's method. (no offense t-shirt)

    It uses no game level variables and can spawn multiple bullets at once and they all act independent of each other.

    Sorry I've been gone so long, I had to move houses and I've been feeling anti-computer for a while. I'm back! :)

    Did I win the prize? :)

    http://gamesalad.com/game/play/76525
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    IDK but I just updated mine.

    check it out.
  • quantumsheepquantumsheep Member Posts: 8,188
    Honestly, you're both bloody stars! :D

    Both work, though your one, Scitunes, has some 'strays' in it that won't stop :(

    Also, orbz used particles for trails, which is what my game does. But that's just icing, right? ;)

    I'll have a look at them and see what I can do.

    You both get a free copy of the game regardless. I'm not sure you'll like it. But hey, it's free!

    And considering t-shirt got me started down this road, the same applies for him, obviously.

    Mail me at quantumsheepinfo at googlemail dot com and let me know if you want your nickname here, or your real name, in the credits ;)

    Thank you both! I'll test out how these solutions work on a device - which is the clincher! :D

    Cheers!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Well ,clearly I'm Bill Cosby in this challenge.

    Orbz, can you explain the time < target distance/maxspeed

    how does this stop the bullet?

    I understand magnitude but don't see what the division problem is all about.
  • ORBZORBZ Member Posts: 1,304
    Ya, sorry scitunes... Mine is much simpler. It uses only two actors (a bullet and a spawner) and only a single actor variable on the bullet, no global game variables, and only two rules shoot and stop, and no timers. Have a look :)

    It's based on the concept that a bullet travels in a strait line for a duration, that duration = distance over speed. The angle is calculated on touch and then the bullet just travels in a strait line for a given duration then stops. Simple.

    @QS, yes the trails are icing :)
  • ORBZORBZ Member Posts: 1,304
    R=D/T ... like miles per hour is a rate. Miles / Hours .. Rate is Speed.

    So we can use some basic algebra to say:

    T = D / R

    So we say the bullet moves for a given duration T, that T is calculated as the distance to move D, divided by the velocity that the object is moving at, it's speed, R.

    When that duration T is up, it stops. This simple formula only works for linear motion, calculus is needed for acceleration and such.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    @Orbz - Awesome! Thanks for the clear explanation.

    @QS - don't use mine! Orbz's is way better!

    :)
  • quantumsheepquantumsheep Member Posts: 8,188
    ORBZ said:
    R=D/T ... like miles per hour is a rate. Miles / Hours .. Rate is Speed.

    So we can use some basic algebra to say:

    T = D / R

    So we say the bullet moves for a given duration T, that T is calculated as the distance to move D, divided by the velocity that the object is moving at, it's speed, R.

    When that duration T is up, it stops. This simple formula only works for linear motion, calculus is needed for acceleration and such.

    You lost me at 'R'

    ;)

    But! Thank you - I'm trying to just copy these actors over and I'll see how it works!

    Again, thanks to you and Bill (!) - you've helped two people with, er, two examples... :D

    I'll let you know how I get on!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • ORBZORBZ Member Posts: 1,304
    Thanks :) Glad I could help!

    You guys both get a free copy of my game when it's done too! ;) Oct 15th!

    PS, anyone want to help with art? I have no extra cash yet but I'll put your name in the credz. Let me know in a private email if you are interested. joel a t orbz d o t com
  • quantumsheepquantumsheep Member Posts: 8,188
    Project 'S' is a go! :D

    I couldn't get it to work straight away because, you know, it's almost 5am here and I'm stupid!

    Orbz very kindly did some email troubleshooting, and now it works.

    PERFECTLY!!!

    Thanks Orbz!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • chosenonestudioschosenonestudios Member Posts: 1,714
    ORBZ said:
    Thanks :) Glad I could help!

    You guys both get a free copy of my game when it's done too! ;) Oct 15th!

    PS, anyone want to help with art? I have no extra cash yet but I'll put your name in the credz. Let me know in a private email if you are interested. joel a t orbz d o t com

    Any teasers? :)
Sign In or Register to comment.