r/gamemaker

Getting a Function from JSON

I have made a JSON file that stores all the dialogue in my game. It is pretty sweet for storing text, but issues arise when I try including variables and functions in my text.

Let's say I have a character that is saying:
"You are x feet away."

With concatenation, this is trivial: I can do
"You are " + distance_to_object(obj) + "feet away."

But how should I do this with JSON? JSON doesn't know what distance_to_object() is, nor does it know what "obj" is

Passing in a string or number isn't too hard, I can just make an arguments variable in my JSON parser.

{
    "textvalue": "this should be 100: [0]",
    "arg": "100"
}

But that only works with static values and not something that can change dynamically in the game.

Any suggestions?

reddit.com
u/EnricosUt — 7 days ago

Should i play games that made on gamemaker to understand it more?

i want to start making games on gamemaker so should i play games made on it to better understand it capablities?

reddit.com
u/ilya_m1g — 8 days ago

My own version of GML...

A little game I'm making with my engine

So, the thing in this screenshot is the IDE of my own game engine ("ArcadeMaker"), which is a hobby C# project I've been working on for years. It shows a little snippet of code written in the custom language I made for the engine.

The project is heavily inspired by GameMaker, but I want to share one little thing where I took a different approach than GM.

You can see in the code in the screenshot (not the GIF, the other screenshot) that it calls the placeMeeting function, but the syntax is a bit different from what it would look like in GML: there are these <> symbols around the object name (placeMeeting(x, y <obj_player>)). These <> mean that we're referencing the TYPE (or "asset" in GM) of the object, rather than a specific instance.

In GML, an object name can also be used to reference an instance (like obj_player.x = 200). GML was my first programming language (back in GM8!), and I remember how confusing this was for me. In my language, you can write obj_player.i.x to reference a single instance of an object in the room.

It's not about mocking GML or anything! GM is 30 times more powerful than my little engine, and I know that. I really think GM is a great (and underrated, by the way) engine. I just wanted to point out this little difference.

Would love to hear your thoughts about it 🙂

by the way, my engine is open source, and if you know C# and looking for cool projects to join, you are more than welcome to contribute! There're a few opened "good first issues" in the repo, and there's me who is happy to answer any question... :)

u/Alert-Neck7679 — 9 days ago

Are saveable AI NPCS ever a good idea for a horror game?

Like I always hear people hate them for being dumb but in what cases do you think they could work?

u/NeedleworkerCute3790 — 7 days ago

Can Gamemaker do this?

I had an idea for a TTRPG campaign a while ago but I don't think it would work without spreadsheets. I tried RPG Maker and I don't think that's what I am looking for and was wondering if this program would let me do the below.

World Map:

  • I want a grid, ideally a hex grid
  • each space would have a biome (color), terrain (hills/mountains/etc.), landmarks (rivers, ruins, towns, caves)
  • would like to have a noise-map generation with the option to base it on a prebuilt map where newly generated grids determine what they are based on what is already there to prevent a hot desert spawning next to an artic region

Exploration map:

  • for landmarks only that have confined spaces and during battle
  • space would be a flat area with maybe 3 levels within you could traverse to with stairs/ramps and exists be it a door, arch, portal, or stairs

Encounter system:

  • I would like a dynamic encounter system based on what is in the hex grid is or location explored
  • encounters would change in difficulty based on the danger level of the hex/location
  • danger level would be random at first but change based on player interactions and the danger level of adjacent spaces every cycle (day/week) and potentially NPCs
  • I would like this system to be easily managed able to modify the creatures by biomes they appear in, modifiers they would have, gear, drops, and art (this last one will be used in combat)
  • location based encounters such as traveling merchants and roving monsters

Combat/City Maps:

  • I am looking to have an easy to modify library of maps that each section can easily be designed with connection points in each part for random generation
  • assets for each section should be easy to add with an option to add new ones and choose if it has collisions or not and even have a list of interactions added to them (for crafting, healing, traps, storage, and markets mostly)
  • entrances/exits should link to similar areas or to the world map to include going up or down in floors (for dungeons and buildings)
  • personal settlements/dungeons should have a resource system which I am thinking a simplified system like from Might and Magic Heroes and Dungeon Maker with an upgrade system managed from a central location as well as a requirement system to build certain structures (I have an old document with some of the ideas done before I realized this was completely impractical for table top)

RPG System:

  • I do have google sheet with an in progress character sheet that would base this on a D100 system but equipment, spells, and talents are not started and the XP system is going through rework
  • player and NPCs will move around either attacking "enemies" of fleeing due to being a noncombatant, low on health, afraid (high level fear effect), or otherwise injured
  • NPCs will prioritize their strongest attacks to determine if they stay at range or not and a large group will form teams with other similar creatures (art would be them forming one image with multiple arts layered up)
  • NPC teams would average stats, add damage, and lose members over time due to taking damage while also taking increased damage/healing from AOE effects (multiply by team size)
  • player will have hotkeys for attacks using the mouse to target enemies with damage/debuffs and allies with buffs or direct the location of an AOE. they would also pause the game when going into inventory/changing spells
  • have a system to make and allow templates to include restrictions to what can take them (whitelist and blacklist based on creature type, faction, and other templates)
  • have a raid system to defend against factions depending on relationship status and to conquer other settlements/hexes
  • item drop should be highly configurable with tables for common, uncommon, rare, exotic for global, biomes, and factions as well as creature specific drops
u/DungeonDragon9 — 10 days ago

What would you have done different

If you got the chance to go back and restart you game development journey what would you change in your learning and methods to achieve the knowledge to game develop and what is something you wish you knew drom the start?

reddit.com
u/Upper-Position-3073 — 9 days ago

Making 3D games in GameMaker is hard. Give me your honest opinion.

I’ve been working on this project for a few months now but something just doesn’t click to me. Especially how the game looks. Now, 3D in GameMaker is pretty hard and it is possible that I’m somewhat at the limit of what this engine can do, but I doubt it. Give me your honest opinion, would you play a game that looks like this? What would you do to make it look better? Thanks :)

Here’s a short clip of the current version:
https://youtu.be/XVeZffMh-FM?si=fjV8U8uFFEAIJlGn

u/KoZimator — 11 days ago

Anyone Know how To Fix This Glitch?

For refrence this is not an RPG game it's a platformer but when the player collides with the ground and moves it glitches out (GIF has been slowed to 0.5x to show detail)

CODE:

if (place_meeting(x + XTravel, y, obj_collision)) {

XTravel = 0

}

if (place_meeting(x + XTravel, y, obj_collision)) {

YTravel = -0.1

} else {

YTravel += 0.1

}

u/Big_Belt_5375 — 11 days ago

We changed our core loop after playtesting revealed a pacing problem. Looking for feedback from other GameMaker devs.

Hey everyone!

We’re developing A Cat in the Cangaço in GameMaker, a 2D action roguelite with survivorslike combat and deckbuilding.

We’ve recently made one of the biggest changes to the game’s core loop so far, based almost entirely on playtester feedback. I’d like to hear what other GameMaker developers think about the approach.

The old loop

DAY (1 min) → NIGHT (1 min) → PLANNING → DAY → NIGHT → PLANNING…

During Day, you play as a cat and fight enemies while collecting Aura.

During Night, you play as a human and do the same.

After each cycle, the game entered a Planning phase. You spent the Aura to improve both forms at the same time, with a trade-off: choosing a good card for one form meant taking a bad card for the other.

Some GIFs of the old system:

We liked the system, but playtesters kept pointing out the same problem:

>The Planning phase was breaking the flow of the game.

Players would get into the rhythm of fighting enemies and then, every two minutes, the game would force them to stop and switch from action to buildcrafting.

Rather than trying to make Planning faster, we decided to remove it from the temporal loop entirely.

The new loop

DAY → NIGHT → DAY → NIGHT…

Instead, the player can encounter three NPCs during the run:

ARMORER: buy new weapons
MULE: get a passive item
FORTUNE TELLER: access the old Planning system and choose temporary effects and synergy cards for the Cat and Human builds

So we’re basically changing the interaction from:

>The game tells you when to stop and make a build decision.

to:

>You decide when you want to stop and make a build decision.

The new version feels much better from a combat-flow perspective, but we’re still unsure about the larger design trade-off.

We’re worried that making buildcrafting optional could make the system too easy to ignore. The old version had a very clear rhythm, while the new version gives the player much more freedom.

Would you keep the forced Planning phase, make it optional like we did, or try a third solution?

And if you’ve had a similar experience where playtesting convinced you to remove or move a major gameplay system, I’d be interested in hearing how you handled it.

If you want to try the game:

Current version:
https://store.steampowered.com/app/3780630/

The current version is available through the open Steam Playtest.

Old version:
https://bragiestudios.com/PitacoLab/Builds/

You don’t need to play it to comment. I’m mainly interested in hearing how other developers think about the pacing and structure of this kind of loop.

u/irlanbragi — 8 days ago

Wondering how I can begin to learn GML with 0 coding knowledge?

As the title says, I have 0 coding knowledge and would like to learn how GML works. I've seen comments saying to "learn the basics of coding first" which I would also like a pointer to. I am basically brand new to all this stuff and would just like a few pointers if someone would be gracious enough to help me out. I've tried making a small RPG but literally can't code a damn thing so I end up looking at youtube tutorials but feel like I am just copying code more than actually retaining and applying. Thank you in advance!

reddit.com
u/GratefulEric — 10 days ago

Struggle with falling/landing code

You ever stare at a problem long enough that it starts to become more confusing instead of less? I suspect that’s what happened to me here, lol.

I’m trying to perfect a simple script that causes a mob to land atop a platform object if it’s along its fall trajectory. I’ve gotten it to work in several different ways tbh, but there’s always some slight bug I find. The problem is always something like a specific case in which the mob falls right through, etc. I’m hoping someone can help clear a few things up for me.

The simplest way as I understand it is something like:
if mob.y < obj_platform.bbox_top) && (mob.y + ySpeed >= obj_platform.bbox_top)), then snap mob to the top of the platform and reset ySpeed/gravity to 0. << Where “ySpeed” is a variable that accumulates a value “grav” each frame (basically they do exact same as the built-in constants).

I know all this works, and to clarify: I’m not having any issues with my jumping/falling cods. What’s confusing me is the general use of ‘obj_platform’ here. If I have multiple platform objects in the room, does it essentially iterate and check for each one? And what happens if there are multiple platforms that meet the landing requirements, but one is closer than the other?

I’ve also re-written the code to basically use instance_count(obj_platform), then run an instance_find() loop for each instance. This is fundamentally the same as my code further above, yes? It does however give me more control - for example, I can push each instance within range into another array _platforms, then sort that array by proximity to the mob along the Y axis, and them I can assume that _platforms[0] (if any) the the closest valid platform, and land on it. Else mob.y += ySpeed and ySpeed +=grav.

Sorry if this is hard to read lol, but I’m so close and I suspect my overthinking is what’s getting me stuck. Most recent my code works perfectly EXCEPT when there are 2 platforms right next to each other, and one is like 1px lower than the other - walking from that platform into the higher one (which would not be considered for landing, because it’s higher) causes the mob to fall correctly but then continue falling through any other platforms below lol.

I guess my main question is: does simply doing “if obj_plat meets the requirement etc…” work the same or better as doing “instance_count” and then looping for each instance[n]? Thanks in advance lol!!!

reddit.com
u/Frog_with_a_job — 10 days ago

Is there a reason to not put a clean up event in every non persistant object in my game?

Just wondering or should i try to weed out memory leaks one by one

reddit.com
u/spotlessbaby — 9 days ago

How can I further advance my learning of GML?

I haven't been working with GameMaker for very long (about eleven months) , but I'm already at a loss for how to learn more. I practice coding every day, but I feel like I want to move on to the next level (sin(), cos(), gravity, and so on). Do you think I should stay where I am or should I study more? And if so, please tell me what you recommend I do to learn.

reddit.com
u/buhozt — 10 days ago