Creator of Bluish-Green Productions, I use GameMaker Studio to make games for iOS and Android

Report RSS Blasphemy, Madness, SPARTA!

Posted by on

Hello,
Aside from a few quick game projects, what has Bluish-Green Productions been working on? Nothing fun, I can assure you of that. I've been doing plenty of work, but none of that is going to end up in your hands as a playable anything... unless you consider 1500 word essays a form of entertainment.
Well, there is one thing that I've been working on that's game-related: Sprite Origin Manipulation.
If you know anything about Game Maker, you know that every Sprite has an origin point which can be defined prior to running the game. If the Sprite is rotated at all, it rotates around this origin point. However, the origin point cannot be changed, so if you have a Sprite which rotates around a central axis, there is no way to make it rotate from a corner, or any other coordinate.
This is the problem I am tackling. I'm sure there are Dlls and other advanced systems that other people use to make this kind of stuff work, but I'm trying to develop a system that works only through Game Maker's own programming language; GML. That way I won't need to include any additional files if I'm distributing a game that makes use of the system, and also because I don't know how to write Dlls.
The system I've been working on over the past 4 weeks (yes, it has taken me that long) works like this:
1.) A Sprite's new origin point is saved in a pair of variables.
2.) The Object makes a new Sprite with origin coordinates at the ones specified in the variables.
3.) The Object's Sprite is deleted, and replaced with a the new Sprite.
4.) The Object physically moves so that it's new position cancels out the change in origin coordinates.

If that last step doesn't make sense, allow me to explain in greater detail:
When an Object's Sprite changes points of origin, the Sprite's position changes. If you change the origin point of a Sprite from (16,16) (centered on a 32x32 Sprite) to (0,16) (anchored to the left-middle) There is a difference of 16 pixels on the x-axis. The Object needs to move in the opposite direction to compensate for this apparent change in position, so that it looks like it hasn't moved at all.
I've actually got that working. The hard part comes when you start to change the origin when the Sprite has been rotated. Remember, the rotation is only visual manipulation of the Sprite, Game Maker doesn't understand that (for example) the bottom-left corner of the Sprite is not where it thinks it is. I need to make additional calculations for it to understand that.
Right now I'm at a particularly frustrating point where I've got 2 pieces of code that look identical, but only 1 of them works correctly. Which of course means that they aren't identical, but it's REALLY hard to find the difference between them.
I'll probably upload the system when I have it working. Or perhaps you'll just have to wait and see it in a future game of mine. Whenever I get the time to make one...
~Bluish-Green Productions

EDIT: March 26th 2011:
Above problem solved by a generous programmer from the Game Maker Community, problem with crazy schoolwork? Still ongoing at this point... :(

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: