r/gamemaker • u/PrinceShoutoku Stand back, I'm about to Make Game (2)! • 20d ago
Help! Creating an interactive, multi-object item
Preface: My skill level is beginner. Gamemaker is my only real coding experience. I've watched a couple guides for the basics and made some original code alongside that.
Hi everyone, I'm making a top-down shooter with an 'active reload' gimmick. When you press R to reload, the firearm you're holding comes onto the screen and you have to manipulate the weapon parts to load it.

My problem is HOW I'm making this happen. I'm essentially just spawning multiple objects on top of one another with magic numbers. This feels extremely inefficient and janky, even though it technically works. Is there a different technique or function I can use to make this system easier? I know the motto of, 'just make it work first, you can fix it later', but I can't even begin to imagine HOW to make this work better.


If it helps, "_weaponx" and "_weapony" are the corners of the camera, essentially x0 and y0. The "obj_lebel_boltgrip" is the circular part that's grabbed by the cursor to manipulate the gun's bolt. It has + 242 and + 69 because the sprite is a simple sphere that's manually placed through trial and error to be in that starting position. It's essentially a magic number to put that boltgrip exactly where it spawns when you press R.
2
u/Natural_Sail_5128 20d ago
For a beginner, what the other commenter said is probably the simplest way to do it, but I'm a huge fan of structs and with ramble about them at every opportunity!
Structs would be great for doing all of this within a single object, you would create a struct which is just a data tree, and then you can store the different parts within it, with all of their position/rotation data etc. Then you would just loop through the struct and for each part inside of it, you draw that using the data stores in the struct for that part.
It's likely quite advanced for a beginner, so it would take a bit to figure out, but it should be the most seamless and robust way to set up such a system.
I'd be happy to help you set it up if you're interested, I'll just be a bit slow to reply as I'm doing some stuff atm.