Using the Sin Function to Animate Alpha in GameMaker

For the first level of Apple Bin, I wanted to create a big dirty finger on screen to tell people where they have to tap to launch and apple. It should fade in and out to draw their attention to it. So to do this I want to create a function that will animate the alpha of the object / sprite on screen. Enter sin(x):

Sin Function
Plain ol’ Sin(x)

The sin function is perfect for this, it creates a smooth transition from state to state. The function sin(x) will give you values from -1 to 1 which is also great for this particular instance as I didn’t want it on screen the entire time. For the negative component it won’t be visible as you can’t have a negative alpha. Now to do this in GameMaker, create a sprite and an associated object.

Add a create event to your object and add this code:


///Setup Objects for Dirty Finger
image_alpha = 0

//This will be the value we use with the sin function
xValue = 0;

//Increment by one degree (converted to radians) each time / step
increment = degtorad(1);

 

Also add a step event and add this code to the step event:

 

//Add the one degree increment to x
xValue+=increment;

//Now use the sin function to get the new alpha
newAlpha = sin(xValue);

//Set it to our image
image_alpha = newAlpha;

 

And that’s pretty much is, if all your ducks are lined up you should get something like this:

And if your an idiot like me and animate the wrong property you can get some freaky results:

Apple Bin on Kotaku!

OK, so it’s not a feature but everyone’s got to start somewhere right? Nice to be mentioned in a site I read pretty much every day.

I’ll keep an eye on the stats over the next few days to see if there are any spikes.

Here’s the link.

pp Deals of the Day
Kotaku – App Deals of the Day

Particle System in GameMaker

I’m re-doing a couple of particle effects that I wasn’t entirely happy with using the built in GameMaker Particle System effects.

This has been pretty easy so far, i’m using a tool called Sparks that Nocturne over at the GM forums has created and been kind  enough to share.

It allows you to play around with graphical effects and tweak them on the fly.

There is also a good write up over on the yoyogames wikki Beginners Guide to Particles

Here are a couple of previews:

Apple Smash
Destroying an Apple
End of Level Stars
End of Level Star Particles

Apple Bin – New Android Game – Out Now!

Apple Bin has just been released out into the wild. The hot new Android Game is available now on the play store.

The process of submitting the game to the Google play store has been a dream compared to submitting my other stuff to Windows Phone / Store. Still to early to get any sort of meaningful stats out of it, but rest assured I will be hitting F5 every 3 minutes to make sure I don’t miss any updates. 🙂

And now begins the task of annoying journalists, pestering forums and generally making a nuisance of myself.

Apple Bin - Get it on Google Play

Apple Bin - New Android Game

Level Design

I’m currently in the process of porting my Windows Phone game ‘Apple Bin’ to Android  I thought this would be a good opportunity to re-design the levels to be a bit more challenging.

In general when I introduce a new mechanic such as a portal or gravity switch I’ll try and present it as simply as possible. Then ramp it up pretty quickly. The levels themselves are fairly quick to put together in GameMaker, the time consuming portion is the design. I try and sketch out ideas before i implement them. It makes it a bit easier to visualise the final result.

Apple Bin - early level designs
Apple Bin – early level designs

My five year old daughter Isabelle thought this was great fun and wanted to design a level of her own. I think we might have a budding game designer on our hands.

Izzy's Level
Izzy’s Level

GameMaker – Should you buy it?

I’m a one man wolf pack when it comes to development. I generally squeak in a couple of hours in a night when the kids have gone to bed. My time is very precious, in order to get anything out the door i know it’s going to be months to tick all the boxes. GameMaker has probably halved the time it would have taken to get my games out, that coupled with the fact that you can easily and rapidly prototype mechanics to see if they’re fun or not is a massive bonus.

GameMaker Dev Environment
Apple Bin in progress

The deployment options are amaizing, i bought the full suite when it came on sale recently. I’d previously been just working with the android / windows export options but once i had the additional modules i selected HTML5 and there it was
my game over the web! For me to actually code that from scratch would have taken months. I’ve been able to pop this on dropbox and have friends check out the new levels and do QA testing for free muhaha. Is it perfect? Well no, there are some quirks with the HTML5 physics engine, my GUI crashed once and i lost a nights work but you able able to submit bug reports and see how they’re tracking. There haven’t been any show stoppers so far and it seems like the support guys are making progress on the bugs I’ve submitted. The only other major drawback is the debugging, you’ve got to use a show message box dialog to determine what a variable’s value is which can be a pain in the ass. I believe that this is marked to be improved in a future version though.

The other option i considered was unity, this is also an amazing tool but seemed like it was a bit of overkill for the 2D games i had planned. That and the cost is almost double. When you’ve got a shoestring budget (if any) this matters.

So, should you buy it…yes!