r/gamemaker

Code help

I’m new to gamemaker and cannot continue due to this error, I’ve been following the turn based rpg tutorial on YouTube and this shows up no matter what

Edit: I managed to resolve it, apparently all I had to do was capitalise damage for some reason? No clue how that works but I’m glad it does

u/Plas_Lolz — 9 hours ago

I have 2 days to Make a smash bros

I have only 2 days to Make a game similar to smash bro coding with blocks SOMEBODY HELP I DONT KNOW NOTHING 😭😭 I need to learn how to move how to Make a health system how to Make fighting and their ulti i basically need everything

reddit.com
u/Adventurous-Panda481 — 20 hours ago

My game runs at 30fps

How the game looks

Main code body

Profiler view

My game's performance is really really poor, I want to make something like fossil fighters where you dig up fossils but the draw_sprite_part function isn't liking being run 32400 times every frame. Is there another function/ way I could do this more efficiently? I'm not entirely sure if or how I could use clipping masks for this.

It's a bit of an issue since I want the size of the area to be bigger for the actual game idea I have, and I'd also like to make more challenges, all of which need more power to happen.

reddit.com
u/Inside-Gas-7044 — 16 hours ago

How big of a performance hit comes from using get_surfacepixel?

The manual says that it shouldn't be used often because it is slow. Unfortunately, with the lighting engine I've created, I have literally no other way of knowing if the player is in shadows or not without get_surfacepixel, which I need to know so that I can draw the player's shadow on the same surface as the rest of the shadows in order for them to merge properly. At max, only 4 get_surfacepixel's ever have to run (two for the player, two for the player's potential follower), but they're running continuously in the draw event in every single room that the player object is in. So, most rooms.

I haven't personally noticed any performance hits or hiccups, but I also have a really, really good PC, so I need to know how big a hit the average player will get from it.

reddit.com
u/IHaveAPhoneAndPc — 24 hours ago

The function draw_rectangle has some issues and can't be rotated, so I made 2 functions that are more flexible. Hopefully, they'll help you if you have a similar problem!

Hey all! I'm pretty new to Gamemaker (trying it out for my newest game instead of Unreal) and I'm working on a game that uses pixel art. The function draw_rectangle was having issues with adding an extra 1 pixel line on two of the edges and doesn't have a built in way to rotate the rectangle being drawn.

I'm drawing tooltips by drawing a series of rectangles and text and this was the solution I came up with to allow rotation. It's certainly not the cleanest way of doing it, but I figured I'd share anyways.

Edit: I was adjusting angles and realized that there was a slight error with RotatePoint. I adjusted it in the code block var _angle_radians = _angle*pi/180; --> var _angle_radians = (_angle + 180)*pi/180;

//Draws a rectangle with color, alpha, and angle using a primative
function DrawRectangle(_origin_x, _origin_y, _x1, _y1, _x2, _y2, _color = c_white, _alpha = 1, _angle = 0)
{
    var _previous_color = draw_get_colour();
    var _previous_alpha = draw_get_alpha();
    draw_set_colour(_color);
    draw_set_alpha(_alpha);

    draw_primitive_begin(pr_trianglestrip);
    draw_vertex(RotatePoint(_origin_x, _origin_y, _x1, _y1, _angle)[0], RotatePoint(_origin_x, _origin_y, _x1, _y1, _angle)[1]);
    draw_vertex(RotatePoint(_origin_x, _origin_y, _x1, _y2, _angle)[0], RotatePoint(_origin_x, _origin_y, _x1, _y2, _angle)[1]);
    draw_vertex(RotatePoint(_origin_x, _origin_y, _x2, _y1, _angle)[0], RotatePoint(_origin_x, _origin_y, _x2, _y1, _angle)[1]);
    draw_vertex(RotatePoint(_origin_x, _origin_y, _x2, _y2, _angle)[0], RotatePoint(_origin_x, _origin_y, _x2, _y2, _angle)[1]);
    draw_primitive_end();

    draw_set_colour(_previous_color);
    draw_set_alpha(_previous_alpha);
}

//Rotates a point around an origin by the given angle in degrees
function RotatePoint(_x_origin, _y_origin, _x_point, _y_point, _angle)
{
    var _angle_radians = (_angle + 180)*pi/180;
    var _base_x = _x_origin - _x_point;
    var _base_y = _y_origin - _y_point;
    var _normal_x = _base_x*cos(_angle_radians) - _base_y*sin(_angle_radians);
    var _normal_y = _base_x*sin(_angle_radians) + _base_y*cos(_angle_radians);
    return [_x_origin + _normal_x, _y_origin + _normal_y];
}
u/RoGlassDev — 1 day ago

Games made in Gamemaker freeze for 10-15 seconds

Ok, so let me start from the beginning because it's necessary for context.

I bought a new computer some 9 months ago with these specs:

CPU: AMD Ryzen 7 9800X3D
GPU: Radeon 7900 XTX
RAM: 96 GB Corsair 6000 Mhz
PSU: 1000W Hydro Ti Pro
Motherboard: ASRock X870E Nova
Drives: Samsung 990 Pro 4TB x2
Peripherals: Corsair mouse and keyboard
Windows 11 (latest update)
Monitors: 3440x1440 @ 144 Hz & 2560x1440 @ 144 Hz w/ FreeSync enabled on both

I've played a game called Mobmania. It had random freezes happening for 10-15s after which the game would continue, but it would always disconnect a multiplayer game.

Some months later I played a game called Hero Siege. It would have the exact same issue. Game would freeze occasionally for 10-15 seconds. Sometimes the game would continue to play, other times it would disconnect me from the game.

Now today I played a game called Super Mining Mechs. Exact same issue. Game freezes for 10-15 seconds every now and then. The only difference in this game is that it doesn't disconnect multiplayer.

These freezes sometimes happen twice in 30 seconds and other times not once in 30 minutes. It varies greatly.

I wasn't thinking much of it after playing the first two games more than the separate games having some weird issues, but when this exact thing happened in a third game I thought it was weird that these simple looking games would all have the same issue. So I searched what game engine they were all made it and apparently they're all made in Gamemaker.

So without a doubt Gamemaker is the common denominator here. These are the only games I have any issues with.

I've tried changing my refresh rate and reinstalling the games and my drivers etc. (everything is updated) but nothing helps.

My old computer built around 2018 was an Intel CPU system but it did use the same video card. It was the only component I moved over to my new computer. With that said, I thus don't think it's a video card issue unless it's a video card + Windows 11 issue because the old computer ran Windows 10.

EDIT: I'm editing the post here just to clarify that I played Mobmania on my old computer with the same 7900 XTX video card and the same monitors and I never had any problems.

Anyway, is this a known issue? Is there any known solution? If not, how can I provide a proper bug report for this?

------------------------------------------------------------

UPDATE:

ISSUE SOLVED! It was Corsair's iCUE causing the problem. When I shut down iCUE these issues stopped happening.

I also tried:

- Turning off Steam and Discord overlays.
- Changed Window's Power plan setting to Balanced.
- Turned off my second monitor.
- Turned off everything in AMD's Adrenaline software.

None of those things changed anything. But as soon as iCUE was shut down everything was resolved. Turning on iCUE again while the game is running would immediately cause a 10-15 seconds game freeze and disconnect any client players if I was hosting.

reddit.com
u/Cestral — 2 days ago

Anyone know how to make a warning screen?

Like those screens that warn you about flashing lights

For context I'm making a horror fan game that involves medical experimentation and I want to make sure that when I publish it has a trigger warning so people know what they're getting into

Anyone know how to code one?

reddit.com
u/Chloe_the_metal_ — 2 days ago

Unmanaged Space (GameMaker) - demo on Itch and how I keep thousands of currency pickups alive at once

Hi everyone! I just uploaded demo for Unmanaged Space on Itch! It's an incremental tower defense game I'm building in GameMaker Studio 2. You deploy into sectors, defend an Operational Continuity Anchor through Anomaly Escalations, harvest cosmic surplus, retreat, then buy upgrades in Orbital Logistics. The demo is about ~20 minutes across two sectors.

https://dublinsolodev.itch.io/unmanaged-space

I'm sharing it here because late sectors flood the room with currency pickups (hundreds to thousands from one boss burst). Each currency object used to run its own Step (idle, magnet, collect, release). At high counts that meant thousands of Step events every frame, and the game choked.

Huge thanks to u/WubsGames for walking me through GameMaker's profiler. The workflow prioritized using the profiler to run your game, look at the worst bottleneck, fix whatever is at the top of the list, and repeat. Each pass showed the next bottleneck I needed to fix and ended up being so much faster by the end.

The biggest win for me was to move most of the currency logic off the currency and onto my oPlayer. The profiler showed my currency step was dominating. So I shifted most of it into a batch step on my oPlayer, which runs one per frame instead of every currency firing Step. Currency mostly holds state now, where the oPlayer now drives the heavy lifting.

I hope you have fun with the demo! Happy to answer GM questions or go deeper on any of the above. If you try it, I'd love feedback on whether you find the respec interesting enough to try different builds to hit the goals of each sector!```

u/dublinsolodev — 3 days ago

Help with an enemy spawner

I am trying to make a spawner similar to something like in a Mega Man game, where when it is off screen and it hasn't spawned something yet, it creates a specified enemy, if that enemy still exists, don't spawn one.

I have that bit working, but my problem is if i destroy one enemy and its spawner is on screen, a different spawner off screen will spawn the next one in, even if it already has one spawned in, this leads to overlapping enemies and all kinds of confusion.

I know there has to be a way to give each spawned enemy an id relating to what spawner created it and to use that to make sure the right spawner creates an enemy but I can't wrap my head around it, thanks to anyone that can help

I've tried

instance_create_layer(x, y, "Instances", object, {oEnemySpawner: id})

and

if owner.id = id {oEnemySpawner.spawn = 1;}

but it still does the same thing, it might be I start from scratch and I don't mind doing that if it works, so any ideas are welcome

reddit.com
u/The_Great_Elpizo — 2 days ago

I'm making my own mini GameMaker

I'm making a GameMaker based engine with my own scripting language.

https://preview.redd.it/hi6x8ab47x1h1.png?width=1599&format=png&auto=webp&s=b28e3839fc1d2a6dfb7ef06eaf10e05e48e90f56

https://preview.redd.it/ebyy5ob47x1h1.png?width=1599&format=png&auto=webp&s=ce902b095766eb40e631f2da00cf7cf138834f7e

https://i.redd.it/33lr8nb47x1h1.gif

Here's a video of me using the engine to build this little game

It's a C# project containing an IDE that equals to the old GameMaker 8 IDE, an interpreter programming language that i made myself, and a backend MonoGame-based engine that will allow me, in the future, to export the games for desktop and mobile.

I'm doing it because it's super fun and challenging, it will probably never get to the level of modern GameMaker but this isn't the goal. If it sounds interesting to you, then you'll be happy to hear that it's open source and you can find the full code of all project parts + some basic documentation here: https://github.com/ArcadeMakerSources/ArcadeMaker . And here you can read more about how i started this project.

Would love to hear what you think about this!

reddit.com
u/Alert-Neck7679 — 3 days ago

I'm having trouble making Pong from scratch

Basically, I have a create event that sets the speed to 5 and the movement of the ball to be random. I also set the direction of the ball after it hits a paddle in its step event to be random as well. I also set it so the room restarts whenever the ball its the out of frame left and right walls. The top and lower walls end up in the ball bouncing. However, whenever I attempt to run it the ball will bounce off the paddle a couple of times before eventually vibrating out of frame. I'm guessing this is because it hits a certain spot that locks it in a bouncing loop. What should I do? Thanks in advance.

Step Event of ball:

if(place_meeting(x,y,wall_left)){

room\_restart();

}

if(place_meeting(x,y,wall_down)){

direction=irandom\_range(180,0);

}

if(place_meeting(x,y,wall_right)){

room\_restart();

}

if(place_meeting(x,y,wall_up)){

direction=irandom\_range(180,270);

}

if (place_meeting(x,y,paddle_player)){

direction=irandom\_range(0,270);

}

if(place_meeting(x,y,paddle_enemy)){

	direction=irandom\_range(180,0);

}
reddit.com
u/WilledWithin — 3 days ago
▲ 169 r/gamemaker+11 crossposts

Grab this UI elements asset pack

Just released a collection of 170+ UI elements - buttons, sliders, toggles, panels, icons, and more. It's 100% free right now, and you can keep it forever once you grab it. If you want, check it out here: https://polyshades.itch.io/cool-ui

u/Polyshade — 4 days ago

Is there a way to shift my whole level to the right?

Half my level is done, but I now want to open some room at the beginning. Offsetting the layers would shift the beginning of the grid away from the beginning of the level and I wouldn't be able to put more tiles there.

Is there a way to shift tiles to the right, all at the same time? I've already opened some room upwards, but that meant cutting slices of already placed tiles and putting them back together, which is a lot of work and it's very hard no to make mistakes.

reddit.com
u/Im_Really_Not_Cris — 4 days ago

How do I let the player type something in and it SAVES IT

(PS: I've only coded on scratch and all I know is if then, I know NOTHING) I'm making a Visual novel over the summer and for the title screen I want it to be a mockup of a computer login screen that saves the players name (what they put in for the login). I need to know how I can let a player type INTO the text box sprite, how to make a character limit for the name, and how to save the name so that when the character talks about the player it'll properly say the name they put in.

u/AcanthisittaOld3137 — 4 days ago
▲ 13 r/gamemaker+3 crossposts

Early look at the upgrade tree for my incremental tower defense game with a bureaucratic sci-fi theme. Here's what it looks like!

youtu.be
u/dublinsolodev — 5 days ago

how to render a camera to an object

im tryna make portals but i need an object to render the a certain area

idk if i have to use surfaces or what bruh im so tired help!!!

reddit.com
u/gfsddnnne — 5 days ago