JJSBlog

When 140 characters won't do.

Sounds and scan bullets

- Posted in GameMaker by

Today was largely about sounds. Until now Zenzenzen was silent, so it felt a bit dead. I used a tool I learned about from the Asteroids tutorial, Bfxr, to make some simple shoot and join sounds. More than that, I learned to use audio_sound_gain to adjust the volume of a single instance of a sound--so when the ship joins with an asteroid, the smaller the asteroid is the quieter the join sound is.

Speaking of relative sizes, this is something I've been pretty unsure exactly how to handle. Like, at what size should asteroids join with the ship? Currently I have it at 1/4 ship mass or less. Secondly, how to handle mass in this game? So far I've been treating it properly three dimensionally, but I'm not sure how appropriate that is in such an obviously 2D world. That is, if an asteroid is 1/2 the ship in length and width, it is taking up ~1/4 the area of the ship on screen. However, I assume there is an equally valid third dimension at play, so its mass is actually 1/8 that of the ship. Maybe going straight out 2D would be simpler and better. shrug at this time.

I played a little with the "scan bullet" concept, but I'm not sure it can work as I initially thought. Really I was playing around with the speed of the regular bullet. However, I found that if I put the speed of the bullet too high, it will basically skip from point A to point B without hitting the spaces in between, and thus even giant asteroids will get missed. The entire point is to hit something and report on what it hits, so that's a no go. If I slow the scan bullet down it will have some slight lag time from leaving the ship, which is not preferable. Maybe if rather than treating it like a tiny bullet it instead creates a long thin item all at once, so it doesn't even really have to move to collide? But in that case it might collide with a bunch of objects simultaneously rather than just the nearest one. Maybe something in the middle--like a bullet 16 pixels long. Something that would be less likely to miss things altogether, not have noticeable lag, and if it does overlap a few items, they'll be in such close proximity that it won't make much difference to the player, especially since everything will have moved around very quickly.

I've worked a bit more on scan bullet, and have something workable though I think it could be better. To make no gaps, movement speed needed to be same as image size. 16x1 was a bit small, but scaling it up to 64x4 should do a decent job and with very little lag. I wonder if it wouldn't be better to every frame look at the ship image angle and do a place_meeting to see if there's anything there on a series of points between the ship and the edge of the screen. However, the necessary calculations to determine all those points in a loop seems More Trouble than I feel like getting into right now, so for now the scan bullet is Good Enough. When the scan bullet hits an asteroid, it's destroyed and a global variable "scanasteroidmass" is set to the asteroid's mass. The object that was displaying just the ship's mass now checks to see if there's a scanasteroidmass available, and if so displays it as well, then resets it to 0. This way whenever the ship angles away from the asteroid and scanasteroidmass stops geting that asteroid's data, it's cleared out.

Though it shouldn't be necessary for functioning, for testing purposes I've got the scan bullet visible, so I can show it shooting out and intersecting with something here.

The ship here is turning right, so you can see how the series of scan bullets deviates a bit from what is exactly forward from the ship. Each of those bullets is from a new frame and the game runs 60fps, though, so the lag from the ship to that asteroid is still a small fraction of a second. Iiiiimperfect, though.

Comments