A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: need help with enemies

  1. #1
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160

    need help with enemies

    ok this is my game "most of you know it "
    http://magnetos.lazoom.com/FullSpace.html

    as you can see the enemies come just on a straight line i would like some randomness (assuming randomness its a word)
    you know like on squize delta game where the enemies come in groups turn around the player and then go or something like that

    can anybody give me some advvices ?

    thanks guys


  2. #2
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    I'm really tired, but if you want, tomorrow I'll explain all the delta attack waves and stuff ?

    Squize.

  3. #3
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    Originally posted by Squize
    I'm really tired, but if you want, tomorrow I'll explain all the delta attack waves and stuff ?

    Squize.

    thanks squize i'd love that
    now go take some rest or a cool beer :-)

  4. #4
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,180

    :)

    Hey magnetos


    I got inspired by your post
    I've made a pathfinder/pathmaker wich can beused in types of games like yours...

    It's not bug-free (sometimes the char just keeps on moving), but still useable...

    I've gotta mow the grass now , and will try to fix the bugs later (shouldn't be to hard to do yourself though)...

    Greetz,
    SaphuA


    I forgot to add a line of code in the pathfinder...
    Under:
    Code:
    char._y = startY;
    Add:
    Code:
    char._x = startX;
    Last edited by SaphuA; 08-23-2003 at 06:38 AM.

  5. #5
    Senior Member MiSSenLinX's Avatar
    Join Date
    Jan 2003
    Location
    Perth, Australia
    Posts
    260
    Hey that game is nice, but too easy ships should take more hits before exploding,

  6. #6
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    mag,
    why not use that helicopter code you got way back when you were doin that tank thingy. i reckon it would work great!
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  7. #7
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    The beer worked a treat

    *Takes huge deep breath* Here we go...

    I didn't get to use the following approach as much as I would have liked in Delta, but if you want a lot of attack waves without a stupid amount of effort or cpu usage, give this a try:

    Whose old enough to remember logo ? It was a lisp based programming language which used to move a little robot turtle around. Cutting edge at the time kids, honestly!
    Well the logo language was really simple, basically it was "Up 4, left 3" and the little turtle would trundle off. The beauty of this is that all the movement is relative, which is what we want to create a near infinite number of attack waves for our kick ass blaster.

    Let's say at the moment you want a simple baddie movement just coming from the right hand side of the screen and going over to the left. Nice and simple.
    In our version of logo it would look like:
    "L",384
    So we are moving "L"eft and for 384 pixels ( Our stage is 384 in this game ). Cool, but it's a bit limited, so let's go for...

    "L",4,96
    So now we've got direction, speed ( 4 pixels a frame ) and we only have to move 96 times ( That's 384 / speed = 384/4=96 ).
    Getting there. How 'bout this

    "L",4,96,"N",0,0
    There we've got the vertical movement as well, in this case "N"ull 'cause we are only moving right to left.

    This is going to be called a segment and it's the building block for all our movement.
    Now this seqment is really limited, it only allows for a complete fly pass across the screen, so let's break it down again...

    "L",4,24,"N",0,0
    So this now flies for a count of 96/4=24 at a speed of 4 pixels per second.
    To re-create our original attack wave, we just repeat it four times, ie

    "L",4,24,"N",0,0,"L",4,24,"N",0,0,"L",4,24,"N",0,0 ,"L",4,24,"N",0,0

    And that's a complete attack wave!

    Now I guess you're thinking "Squize, although i wouldn't mind you watching me in the bath, why mess around breaking the segments up ? It was smaller before and worked a treat, now you've gotta have 4 segments just for a really easy attack wave".
    But that's the whole beauty of using lot's of little segments, you can create really complex waves very easily by just mixing and matching the segments. That one little segment can be used over and over again, whereas the segment with the 96 count can only be used once because it will only ever fly right across the screen.

    So just create lot's of little segments, slightly different speeds, all the different directions etc. and then you can link them together in attack waves.

    You've got two options then:
    1. Do it the way I did it in Delta. Each attack wave is "complete", ie the baddie will fly all the way across the screen after performing it's funky moves.
    2. Each attack wave is in effect a master segment. The attack wave isn't complete, it only contains a few segments. This way you just string attackwaves together to make it totally random everytime you play it.

    For a R-Type game I'd go for option 1, people like to learn the waves in relation to the scrolling background, for just an all out blaster option 2 will be way sexy ( And quicker to do, 'cause everything is random )

    Nearly there...sorry I seem to write a novel everytime

    Let's say we are doing option 1 above, the R-Type attack patterns.
    Pull the first segment from the first attack wave. Move the baddie using the data in that segment and simply count down until it's done ( The counter in our example is 24 ). Once it's done, move onto the next segment in the attack wave, until it's all done. The baddie will now be either off screen, or you'll have shot it.
    If you are running 8 baddies at a time ( 8 is just a nice computer number ), then you'll need 8 attack wave arrays for each baddie, so they can all do their own thing ( Some waves will be identical, some will differ. You'll find there is a fair bit of duplication, but by using segments this will be cut down a lot ).

    For option 2, just randomly pick a attack wave, and start position ( Remember that using our pretend logo all the movements are relative, which allows for a lot more scope ). Once the baddie has completed it's attack wave, pick a new one randomly.

    The option 2 approach is a lot, lot easier to do. You don't have to mess around creating really complex waves, the random element will do that for you. Also you won't need as many attack waves. You may have to do some additional checks to see if the baddie has flown off the top of the screen or something ( 'Cause you have very little control over where they fly ) but that's no big deal, you can just kill it off.

    Phew. I'm spent. Hope that's some help, and sorry it's theory heavy, but code wise it's just a case of pulling out values from arrays. There are other things missing, like baddie type, number of hits, points for a kill etc. but they can easily be added to the start of the attack wave data or pulled from an array randomly.

    Feel free to question me about this, I promise the reply won't be as long

    Squize.

  8. #8
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Sorry just thought a more visual example may help ?

    segment1=("L",4,24,"N",0,0)
    segment2=("L",2,48,"N",0,0)
    segment3=("L",1,96,"N",0,0)
    segment4=("N",0,0,"U",4,24)
    segment5=("N",0,0,"U",2,48)
    segment6=("N",0,0,"U",1,96)

    attackWave1=new Array(segment1,segment5,segment1,segment1)

    etc.

    Squize.

  9. #9
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    thanks saphua for that pathfind thing very cool
    blink dont know if that elicopter thing would work for this kind of game infact all the chopper do is following the hero around in a circular motion ...

    hey suize i think i got the concept but i am afraid it would be too hard for me to translate it into code but i am not gonna ask you for a little small tiny mini fla

    thanks a lot squize

  10. #10
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,180
    Originally posted by Squize
    The beer worked a treat

    *Takes huge deep breath* Here we go...

    Bla bla bla bla...
    Bla bla bla bla...
    Bla bla bla bla...
    Bla bla bla bla...

    Squize.
    Hehe... isn't that the same as mine, only waaaaay more code?

  11. #11
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Dunno to be honest, didn't look

    Squize.

  12. #12
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    Originally posted by SaphuA
    Hehe... isn't that the same as mine, only waaaaay more code?
    no saphua i think squize method is more structured and also takes in account multiple waves

    yours its nice but the movement its too herratic to be used in a game like mine "i think"


  13. #13
    for the win Asclepeos's Avatar
    Join Date
    Dec 2000
    Posts
    388
    they look like they are going left in sin waves..

  14. #14
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Yo magneto,
    http://www.mad-sci.lazoom.com

    check out the sineAlien..

    ms

    PS..

    you can make different containers having different aliens inside. then just rotate the container to look and move towards the hero..
    on my page look for the prototypes like LookAt and MoveTo..

    ms
    Last edited by Mad-Sci; 08-23-2003 at 05:31 PM.

  15. #15
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    Originally posted by Mad-Sci
    Yo magneto,
    http://www.mad-sci.lazoom.com

    check out the sineAlien..

    ms

    PS..

    you can make different containers having different aliens inside. then just rotate the container to look and move towards the hero..
    on my page look for the prototypes like LookAt and MoveTo..

    ms
    thanks mad and congrats for your site its cool
    did you use the same protos to move the galaxian enemies on your game?

  16. #16
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    actually no the move is preaty stupid...just:

    1. get a random number to change the direction else keep the old one.
    2. if the changing the direction
    A) get a random number for left or right
    B) get a random number for speed

    and voila..

    ms

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center