Algorythms for patterns

A place for people with an interest in developing new shmups.
Post Reply
zebdal
Posts: 10
Joined: Thu Nov 12, 2009 1:13 pm

Algorythms for patterns

Post by zebdal »

I think it could be interesting to have a topic talking about algorythms.
The idea is to post some good algorythms to make good patterns on a shmup.

for example:

init:

Code: Select all

angleleft=0
angleright=0
at each step:

Code: Select all

for (int i=0; i<6; i++)
{
create bullet at 0,0:
angle=angleleft + 60*i
speed=6
create bullet at 0,0:
angle=angleright + 60*i
speed=6
}
angleleft=angleleft + 10
angleright=angleright - 10
it's an easy code and doesn't look bad if you use it with extra patterns
User avatar
Udderdude
Posts: 6277
Joined: Thu Feb 16, 2006 7:55 am
Location: Canada
Contact:

Re: Algorythms for patterns

Post by Udderdude »

Hardcoding is one thing, but for a real game you are going to need some "bullet engine" or script generation thing.
zebdal
Posts: 10
Joined: Thu Nov 12, 2009 1:13 pm

Re: Algorythms for patterns

Post by zebdal »

Udderdude wrote:Hardcoding is one thing, but for a real game you are going to need some "bullet engine" or script generation thing.
If I want to make my own bullet engine, what do I do?

No, this topic is for those who don't use bullet engines or who wants to understand how do we do the patterns.
I don't think that's a bad idea.

If you want to post some good bullet engines that you know, you can.
But this topic is done for coders that they want to understand, and not only to press a button and have all the script done by himself.
And the bullet engines are coded in some languages, and it doesn't work with another language.
User avatar
TMR
Posts: 163
Joined: Thu May 14, 2009 10:29 pm
Location: Leeds, U.K.
Contact:

Re: Algorythms for patterns

Post by TMR »

zebdal wrote:
Udderdude wrote:Hardcoding is one thing, but for a real game you are going to need some "bullet engine" or script generation thing.
If I want to make my own bullet engine, what do I do?
Work out what it needs, then code it. i'm quite pleased with mine because although it's not exactly complicated and i haven't actually added all the functionality i want yet, it was only started about two weeks ago (i had a writing deadline in the middle of that period) and the results are pretty cool so far; it reads a text file in which contains "commands" to control enemy movement and firing patterns and was already doing stuff like this yesterday...

Image

...with the extra features i added today allow for a lot more variation.
zebdal
Posts: 10
Joined: Thu Nov 12, 2009 1:13 pm

Re: Algorythms for patterns

Post by zebdal »

something I made there is some months for my shmup:

Image

I create like 15 bullets at the same time with an angle a little different and with a speed different.
the one who is at the top-left is faster and the nexts to the right are slower.
a few time after, i create again new bullets but this time, the speed in inversed.
the ones who are at the right are faster.

I did this code on the 2 canons of the ship.
I have lowed the power of this pattern since this shot have been done, because it was obviously impossible to dodge.
User avatar
Rozyrg
Posts: 918
Joined: Wed Feb 11, 2009 12:03 am
Location: Southeast USA

Re: Algorythms for patterns

Post by Rozyrg »

Very impressive!

I've had to rewrite my bullet scripts recently, so I'm going through some of this process again, too. *groan*

Basically, I like to make a set number of variables that works for every pattern (bullet speed, number of bullets in a spread, number per burst, space between bullets, angle variations, etc.) and make one script that contains all the pertinent variations of each for every enemy like a list, with the enemy object itself only needing the numbered identifier for their particular one.
Odessi
Posts: 4
Joined: Sun Jan 10, 2010 9:10 pm

Re: Algorythms for patterns

Post by Odessi »

I actually wrote an entire scripting language for dealing with bullets, and also beam/bomb-type weapons. It was a lot of work, but ended up being extremely flexible. The page for it is here, and there's some videos of it, including bizarre effects such as zooming Mandelbrot bullets. :D
User avatar
null1024
Posts: 3811
Joined: Sat Dec 15, 2007 8:52 pm
Location: ʍoquıɐɹ ǝɥʇ ɹǝʌo 'ǝɹǝɥʍǝɯos
Contact:

Re: Algorythms for patterns

Post by null1024 »

In my game, Bisus, I mostly had it create a bullet each step, and shoot it off based on a couple of LFOs [can't think of a better term, especially not after playing with VST synths in Renoise for the 2 hours prior to posting this]. I'd just change the ranges.

So, for example, I'd have

Code: Select all

r.direction=270-(drc_*mod_*sne_)
for the direction after creating the bullet, where sne_ was whether to shoot left or right essentially [-1 or 1], mod_ was my primary LFO, and drc_ was my secondary LFO that I'd change to different values to get different spreads.

I had several different variations on this first formula, like

Code: Select all

r.direction=270-(drc_*mod_*sne_)+(sne_*6)
to get different kinds of spreads as well.

The actual pattern changing was done with a bunch of alarms out of sheer stupidity [was just testing, and it stuck], and each part went like so:

Code: Select all

opt_=0
modres=8
alarm[3]=60
modres was the upper and lower bound for mod_, and opt_ changed which generation formula to use.
I need to put this stuff in an external file though, and it wouldn't even be too hard. But I'm lazy as hell.

Making patterns like this worked surprisingly well, and I got the idea from how I did the player bullet generation [got tired of random spreads] in Dzufu Tomorrow, which is just a much simpler version of what was described.
Come check out my website, I guess. Random stuff I've worked on over the last two decades.
User avatar
Sasupoika
Posts: 471
Joined: Sat Nov 15, 2008 11:44 am

Re: Algorythms for patterns

Post by Sasupoika »

http://www.mediafire.com/?gmz2nor3wom

It is bit too fast in the video. I have nerfed the speed. Hahaha.
ImageImage
User avatar
Spiderift
Posts: 15
Joined: Sun Jan 17, 2010 7:10 pm
Location: London

Re: Algorythms for patterns

Post by Spiderift »

Sine function's my favourite. You can get some funky things going on by applying them for different calculations. A simple one would be to determine the turn acceleration of your firing angle.
User avatar
WHARXOR3
Posts: 13
Joined: Fri Jan 29, 2010 3:18 am

Re: Algorythms for patterns

Post by WHARXOR3 »

Incredible, it has very good aspect zebdal!!

Cheers.
Post Reply