Using spawners to generate complex bullet patterns

edited November 2011 in Help request
Hello. I have another question about using spawners. I asked previously if I could use spawners to create something like the bullet patterns in modern curtain fire/danmaku games, like Touhou and games that play similarly. We are getting ready to create some bullet patterns in our game, and we would like to know how to generate some patterns. Would we have to spawn bullets and then alter their trajectory in the code? Is there any way to spawn bullets that move based on mathematical equations (like how FX can do sine/cosine waves on movement)?

EDIT: How come links are broken when you use the URL tags? That's weird. Anyway, here is a link to a wikipedia page about Touhou for those who don't know what it is:

EDIT: Mmh, I added the URL tag to your post and it looks like it's working fine to me. :) Will reply to your question tonight from home though.


  • edited November 2011
    It all depends on your patterns. In most bullet hell shooters, patterns are very simple (often based on sine curves). If your game needs similar pattern, you can achieve all this by using orxFXs and defining everything in config.
    When defining an orxFX, you can combine different types of curve: sine, smooth (very similar to a half sine but much cheaper to compute), triangle, linear and square.
    In addition to basic controls over the curve such as the period or starting phase, you can also have simple modificators on those curves like controlling the amplitude over time or expanding/compressing the curve's period with the Acceleration property.

    Note that you can combine many FX curves to obtain more complex patterns and that those curves can be applied to different aspects of your object such as position, speed, scale, rotation, color, alpha, ...
    You can also have more than one FX applied on an object simultaneously (I think the limit is 4, but I'd need to check before affirming it).
    That means you can stage evolutive patterns (like something scaling up when fading in, then rushing outside and finally disappearing in a spiral, for example).

    There are some basic examples in the FX tutorial and a list of all the properties in the CreationTemplate.ini file.

    If you need more complex equations which curve can't be made by combining the curves orx propose, you'll then need to write your own code and apply the result to your object.

    Does it answer your question?
  • edited November 2011
    Mostly. I was afraid to use FX because I thought that messed up the physics module's processing of collision. Was I wrong about that? If we can use the physics and FX modules and still have hit detection be near-perfect then that solves our problem perfectly.
  • edited November 2011

    Maybe Iarwain can answer better than me, but I try ^^

    I'm not sure to understand your problem about collision detection.

    If you want a collision detection, you have to add a body in your object (this object can have a Fx or not).

    If your object has no body, nothing is sent to the physical module, so no collision.

    But be carefull, the physics module doesn't really appreciate to modify the position of an object. Instead of that, you can move your object by setting a speed.

    So FX with the type 'position' will probably not work properly on your object (if your object has a body). You have to wrote a FX of type 'speed' instead.

    When you do a setposition on an object, it's like a teleportation for the physics module, so it's not the best way to achieve a good collision detection.

    Hope this help ^^
  • edited November 2011
    Yep, what faistoiplaisir said! =)

    Small precision: in the case of bullets where you'll probably destroy them upon contact, updating position shouldn't matter much. Box2D can't track collisions over time when you update the position instead of the speed, but for instant contact that are reported only once I think it should be fine.
  • edited November 2011
    Really? Well, that opens up our options quite a bit. Thank you! I'll let you know if simply setting the position causes issues in our program but this sounds promising.

    Thanks to the both of you. See you later!
Sign In or Register to comment.