Dodonpachi-style lasers in Game Maker 8

A place for people with an interest in developing new shmups.
Post Reply
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Dodonpachi-style lasers in Game Maker 8

Post by BPzeBanshee »

Get the example here: http://www.mediafire.com/?0gq0jyf1rbjprxy

This is by and large the fruit of S20-TBL's efforts to come up with a Dodonpachi-style laser after some discussions with me via private message. It was originally implemented as Xonochrome's focus shot for GMOSSE MK-VI but upon discovering its performance issues I decided to take it out and with his permission post a public demo of the function itself here.

The performance issues come partly from the drawing of part of this laser as far as the laser head, and partly from collision checking every spot from the spawn of the laser to however far the laser tip goes. It also doesn't handle on-the-fly rotation very well at all, so unless someone figures out a way to bypass draw_sprite_general's ignoring of the origin values of the sprite to center the laser properly on the fly for every possible direction, you can't really use this for DFK-style rotating lasers either.

So this being said, does it look convincing? Well yes it does:
Image

An additional note: I used this test GMK to figure out implementation of image-based scanlines, which have now been implemented into GMOSSE for its MK-VI release. Press 0 on the keypad (with num lock on of course) to disable scanlines, 1 to do horizontal, 2 to do vertical, 3 to do moving horizontal and 4 to do moving vertical.

Also, don't ask me for help because this is way beyond my level of code/maths knowledge. :lol:
User avatar
Atomhead
Posts: 70
Joined: Mon Sep 26, 2011 1:08 am
Location: Belgium
Contact:

Re: Dodonpachi-style lasers in Game Maker 8

Post by Atomhead »

Pretty damn cool!! Keeping this on the side, thanks! :)
Hyperspace Invaders II: Pixel Edition - Available on STEAM NOW!
User avatar
Rozyrg
Posts: 918
Joined: Wed Feb 11, 2009 12:03 am
Location: Southeast USA

Re: Dodonpachi-style lasers in Game Maker 8

Post by Rozyrg »

Brilliant results! Great work, guys! ;)
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Dodonpachi-style lasers in Game Maker 8

Post by BPzeBanshee »

Like I said, the bulk of it's S20's work. I was more like the guinea pig, which is great because one of the purposes of GMOSSE is to serve as exactly that for experiments in Game Maker. Glad yous like it!
Rozyrg wrote:Brilliant results! Great work, guys! ;)
I knew you'd like this, as you've been trying to come up with something similar for some time now. Beware that this is a performance hog if you still care about that side of the spectrum though. :P
User avatar
S20-TBL
Posts: 440
Joined: Mon Jan 18, 2010 6:48 am
Location: Frying over a jungle and saving the nature
Contact:

Re: Dodonpachi-style lasers in Game Maker 8

Post by S20-TBL »

Glad you folks liked it. :D

As for laser rotation, let me explain. Drawing the laser uses the draw_sprite_general function, which allows you to draw portions of a sprite in a specific area marked by width and height. However, for some strange reason the function completely negates the sprite's specified origin in GM's Sprite Editor tool, and instead draws it from (0, 0), or the top left corner of the image.

The laser in this example draws the beam with an X-axis offset equal to half the beam graphic's height, since the beam sprite itself is laid out horizontally (the ship fires it rotated at 90 degrees). Rotating it in real time, however, will result in the sprite turning from the top left corner--which looks REALLY ugly when it starts turning to the left.

I believe there may be a way to manipulate it somehow, though, by setting the origin of the sprite using the lengthdir_x and lengthdir_y functions. This means that the origin of the laser itself will rotate along with the beam, making it possible to draw spinning lasers without the origin moving off the mark. I could test it right now, though I'm a little busy at the moment.
--Papilio v0.9 Beta now on itch.io! (development thread)--
Xyga wrote:Blondest eyelashes ever.
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Dodonpachi-style lasers in Game Maker 8

Post by BPzeBanshee »

S20-TBL wrote: I believe there may be a way to manipulate it somehow, though, by setting the origin of the sprite using the lengthdir_x and lengthdir_y functions. This means that the origin of the laser itself will rotate along with the beam, making it possible to draw spinning lasers without the origin moving off the mark. I could test it right now, though I'm a little busy at the moment.
For some reason your explanation clicked (you must be knocking your head against a wall several times explaining such things multiple times to my silly head), and I looked this up and found that someone had the exact same issue at Yoyogames: http://gmc.yoyogames.com/index.php?showtopic=317484

Jumping to the possible solution here, user 'torigara' said this:
If the origin is supposed to be (ox, oy) relative to the top left corner, draw it at
x - lengthdir_x(ox, angle) + lengthdir_y(oy, angle)
y - lengthdir_y(ox, agnle) - lengthdir_x(oy, angle)
Now I've got a tropical cyclone due to hit me Christmas Day so I probably won't be able to get back to you guys before we get another major thunderstorm but I'll put this to the test as soon as I can. I guess that means I won't be able to get a GMOSSE release out for Christmas like I was hoping but I shall strive to fix things up.

EDIT: Lo and behold, it indeed fixes it using newx and newy variables in the actual draw_sprite_general command for the respective x and y positions, while using sprite_xoffset/sprite_yoffset for ox and oy and dir (which is already used to determine direction in the script) for angle.

I'd post a new build showing off a thing I did with mouseaiming but it's a little bit wonky (shake it around fast enough and the laser skips past the obj_lasertip entirely, space gap between drawn laser and object, etc) and also I don't have much time on my hands.
User avatar
Atomhead
Posts: 70
Joined: Mon Sep 26, 2011 1:08 am
Location: Belgium
Contact:

Re: Dodonpachi-style lasers in Game Maker 8

Post by Atomhead »

I checked it out a bit, and indeed it's quite a challenge to wrap my head around. It's very performant here though.
Just looking around already gives a good impression of how you're doing it.

Now, at the risk at being bullet curtained, let me just say... I love this initiative, and while DDP is an awesome game and this is a great example,
I can't help but feel that it looks a little retro (ofcourse it does!), yet therefore... a little outdated.
I think I've already demonstrated my undying love for retro shooters in HI0, but now I want to move on to something "new" and preferably crazy.
I mean... wouldn't it be nicer to see a new type of laser (either visually or functionally)?

So here's my proposition: since we're all GM enthusiasts, why don't we make it a "GM laser thread"?
Lasers are a challenge, and they can be spectacular. They can be pulses, flashes, shots, or "enduring" like the DDP laser (or like the first boss in Ikaruga).

Ofcourse I'll join in once I think of a laser-system to use for HI0's sequel (thinking along the lines of the Danger Infinity lasers).
I'll make one using particles and report back whenever that worked.

I just like the topic of lasers, and I think it could be nice to offer some tricks to get the newbies started.
Just a thought, didn't intend to hijack this topic!

PS: http://www.youtube.com/watch?v=Yau_g9NO_pc&t=4m (Border Down, damn!)
Hyperspace Invaders II: Pixel Edition - Available on STEAM NOW!
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Dodonpachi-style lasers in Game Maker 8

Post by BPzeBanshee »

I like your ideas, and I especially like the idea of a thread containing various methods of creating different kinds of shmup lasers in GM, but this bit worries me:
Ofcourse I'll join in once I think of a laser-system to use for HI0's sequel (thinking along the lines of the Danger Infinity lasers).
I'll make one using particles and report back whenever that worked.
To be quite frank, even on a good computer, use of particles and especially Game Maker's particle system is completely horrible for computers, and any game that features it is going to annoy people when they run a game and find an otherwise very simple game to be much heavier on performance than it should because the developer thought it was a bright idea to add heaps and heaps and heaps of particles to make cool explosions and stuff. I think the one thing we should be making clear to everyone is that cool-looking stuff can be made without resorting to using particles and such.

As for me, the ultimate goal for this is to eventually be able to use this for the final boss of GMOSSE. I plan on making a boss that uses lasers in a way similar to this: http://www.youtube.com/watch?feature=pl ... cwc#t=148s
You say it performs well but just having one of these lasers at the moment reduces the FPS by about 1 frame or so on the legacy PC I use, and even on a modest machine using multiple lasers of the form described above will kill performance (as you can see in stage 2 of Papilio - my best computer got reduced to 30 FPS when the lasers are shot and S20's told me in some of his tests it was bogged down even worse). I may add in some kind of simulated lag function to compensate for this but hopefully I can find some way to optimise the collision checking side of it by making it only occur every 5 steps instead of every step or something similar so I don't have to cheat.

I'll most certainly have a go at seeing what other laser methods I can come up with, but I should have you know there's been a few different types discussed in various threads - maybe the first target of attack for founding the "GM laser thread" would be to put all of those in one place.

EDIT: apologies if I sound like a grump or if my rant makes little sense - the flu is firing my mind in different terrestrial realms from the norm. Also, as an example to support my point, using the Border Down ship in GwangeDash looks exactly the same and that was made using a combination of additive glows and sprites. On low detail it's just the sprite but replacing the additive glows with sprites shouldn't be too difficult. Also, Gustav's DDP-like lasers use randomly-angled explosion sprites which all use draw_set_blend or something similar to blend together and that looks allright too.
User avatar
Atomhead
Posts: 70
Joined: Mon Sep 26, 2011 1:08 am
Location: Belgium
Contact:

Re: Dodonpachi-style lasers in Game Maker 8

Post by Atomhead »

BPzeBanshee wrote:...even on a good computer, use of particles and especially Game Maker's particle system is completely horrible for computers, and any game that features it is going to annoy people when they run a game and find an otherwise very simple game to be much heavier on performance than it should because the developer thought it was a bright idea to add heaps and heaps and heaps of particles to make cool explosions and stuff. I think the one thing we should be making clear to everyone is that cool-looking stuff can be made without resorting to using particles and such.
I can't say I totally agree with this... Think of Geometry Wars/Grid Assault, or Veck... I just love that kind of visual feel, I guess it's a personal preference.
Also, particles don't have to be that heavy, you can easily tone down their performance impact by reducing their life duration, complexity, or simply the number of spawns.
I'm not saying "base everything on particles" either, but I'm thinking a combination of particles/generated geometry and if you prefer also sprites could make for a badass laser ;)
I also haven't tried many other particle systems (except in 3D max), but one of the reasons that I'm still sticking to GM is its relative ease of use (and not "too deep" code).
BPzeBanshee wrote: As for me, the ultimate goal for this is to eventually be able to use this for the final boss of GMOSSE. I plan on making a boss that uses lasers in a way similar to this: http://www.youtube.com/watch?feature=pl ... cwc#t=148s
Alright, didn't realise that was the backstory...
BPzeBanshee wrote:You say it performs well
At least 1 instance of it didn't hurt performance 1 bit for me, I didn't consider multiple instances actually...
BPzeBanshee wrote: I'll most certainly have a go at seeing what other laser methods I can come up with, but I should have you know there's been a few different types discussed in various threads - maybe the first target of attack for founding the "GM laser thread" would be to put all of those in one place.
Right. I haven't checked the forum that extensively yet... I wasn't really thinking about making it that official but you're right.
I was thinking more along the lines of a "put your laser on the table" topic. Just for fun.
BPzeBanshee wrote:EDIT: apologies if I sound like a grump
Don't worry, I've come to expect these type of responses from you ;)
I don't mind...
BPzeBanshee wrote:using the Border Down ship in GwangeDash looks exactly the same and that was made using a combination of additive glows and sprites. On low detail it's just the sprite but replacing the additive glows with sprites shouldn't be too difficult. Also, Gustav's DDP-like lasers use randomly-angled explosion sprites which all use draw_set_blend or something similar to blend together and that looks allright too.
Yeah it's very similar and could indeed be made using your descriptions (although it could be interesting to randomise the lightning bit through code), though in my eyes it looks a lot more "modern" too.

In conclusion, I think our main "issue" is just that we have a different preference for the visual representation in shmups. No biggie. We could still post lasers.
Hyperspace Invaders II: Pixel Edition - Available on STEAM NOW!
User avatar
BPzeBanshee
Posts: 4859
Joined: Sun Feb 08, 2009 3:59 am

Re: Dodonpachi-style lasers in Game Maker 8

Post by BPzeBanshee »

I can't say I totally agree with this... Think of Geometry Wars/Grid Assault, or Veck... I just love that kind of visual feel, I guess it's a personal preference.
Also, particles don't have to be that heavy, you can easily tone down their performance impact by reducing their life duration, complexity, or simply the number of spawns.
I'm not saying "base everything on particles" either, but I'm thinking a combination of particles/generated geometry and if you prefer also sprites could make for a badass laser
I also haven't tried many other particle systems (except in 3D max), but one of the reasons that I'm still sticking to GM is its relative ease of use (and not "too deep" code).
This is true too. I personally got severe headaches the last several times I've tried to learn another programming language, and particles certainly have a lot more controllability once you get into GML. I just think for the more basic use of particles (ie. glows and stuff) there's better and more efficient ways to go about doing the exact same thing. But then that's the brilliance and double-edged sword of Game Maker after all.
Yeah it's very similar and could indeed be made using your descriptions (although it could be interesting to randomise the lightning bit through code), though in my eyes it looks a lot more "modern" too.

In conclusion, I think our main "issue" is just that we have a different preference for the visual representation in shmups. No biggie. We could still post lasers.
I've got a chip on the shoulder so to speak when it comes to performance vs prettiness, but by all means I'm open to alternative views in how things are done. We need more of such discussion here for sure!

To specifics, I actually had a lightning sprite I'd made myself (drew lines, flipped them around, pretty basic/lame) some time ago, I could imagine doing the same thing again and then using that as an overlay/backlay for such a laser as in Border Down. However, keeping it the same length as the laser (and indeed the laser's own length) would require either the use of something similar to the DDP laser (animated sprite the length of the room with it's 'width' determined by laser head object in draw_sprite_general function) or stretching the xscale which would distort it and probably make it look different.

I think once I get a release of GMOSSE out for the new year I'll start a thread featuring some of the content from previous posts that have been here on Development and what you and I have both discussed so far, plus maybe a few examples (that is, if you don't beat me to it ;)). There is definitely more than one way to do this in GM and this kind of activity is just what this place needs. :D
Post Reply