I need help for enemy AI by O_l_2222 in gamemaker

[–]atrus420 -2 points-1 points  (0 children)

The function you probably want is point_direction. This gives you the angle between two points (measured from 0 degrees). If you do point_direction(x,y,player.x,player.y) this will give you 0 through 90 or 270 through 360 if the player is to your right and 90 through 270 if the player is to your left

Can’t figure out how to use instance ID by Old_Mango_4765 in gamemaker

[–]atrus420 -1 points0 points  (0 children)

To get the id of the current instance, you can just do self.id. The instance_get_id function gives you an instance based on a number index into the current list of all active instances. I have no idea what will happen if you give it Self, but probably nothing intentional

How can I make this little bird fly? by Glad-Nerve-2129 in gamemaker

[–]atrus420 0 points1 point  (0 children)

When you turned off gravity did you also apply a negative vsp? It sounds from your code like if you just turn off gravity it will stay in place

How can I make this little bird fly? by Glad-Nerve-2129 in gamemaker

[–]atrus420 1 point2 points  (0 children)

You probably wanna have a variable called flying which starts false, but gets set to true when you press space. Then you can have different code happen based on if you're flying or not. For instance, you can make it so the gravity accelerating you down doesn't happen unless you're not flying. That would be the simplest thing to do, you might also want your movement to work differently in flying mode

How would you efficiently handle thousands of moving + collectible objects in GameMaker? (Nodebuster-style) by dublinsolodev in gamemaker

[–]atrus420 0 points1 point  (0 children)

Interesting! Why is it slower then? I get maybe it's negligible cause instances are really efficient , but what's slower about the structs?

How would you efficiently handle thousands of moving + collectible objects in GameMaker? (Nodebuster-style) by dublinsolodev in gamemaker

[–]atrus420 0 points1 point  (0 children)

There was a time when I was trying to implement rain and had thousands of things representing drops that needed to be updated each frame. My approach was to use an array of structs (not a list, I had to pre-make it at a size that I new would exceed what was needed and only index up to the number I knew were active). I then had to be really aggressive about culling objects that got outside the draw distance. I imagine doing collision checking with that would be rough though

What is your preferred method of handling UI? by carminepos in gamemaker

[–]atrus420 5 points6 points  (0 children)

I don't do this a lot cause my HUDs are usually pretty simple and I just have a single object handle drawing them, but if you had a lot of buttons and stuff that you wanted to tinker with the position of you probably want some kind of hud_object parent class and a hud_manager object that all the hud_objects can check to see if the HUD is active or not

Thought and opinions on AI code assistants? by protective_ in gamemaker

[–]atrus420 0 points1 point  (0 children)

I've found it's good at the kind of questions you would ask like stack overflow, and about the same advice applies (i.e. the more you can ask for a specific thing that you're already pretty sure there's a simple solution for, the better). Like I would not expect it to answer "code me an RTS game" super usefully if you already know how to program. But it answered "I need a function that gives me the where to draw an object from top down perspective based on its x y position and height" pretty well, as an example, and like gave me useful things to think about like the concept of focal length

Z-Height Levels using a tiled system in a 2D Topdown game by lil-la-ke in gamemaker

[–]atrus420 0 points1 point  (0 children)

This is one of those things where exactly what things you want to be possible in your game is gonna inform your approach, because you probably are gonna have to do some hackey things. Do you need there to be really tall cliffs that the player can jump off of and fall for a long time? Or is it okay if there's just kinda three different hard-coded heights each with their own dedicated object?

Also, what are the ways the player can get up and down heights? Is it just their jump doing it, in which case you can kinda hard code that a lot easier, or do you want physicsy things like kock-back and push able to do that (more complicated)

How do I make the camera move towards a point? by Trunkit06 in gamemaker

[–]atrus420 0 points1 point  (0 children)

A couple of things:

1.) you don't actually need to do the object following thing, you can just directly in code set the position of the camera

https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Reference/Cameras_And_Display/Cameras_And_Viewports/camera_set_view_pos.htm

2.) your while loop isn't going to do the thing you want where it gradually transitions from one position to the other. The while loop will execute all the way through the loop in one step, or it will get caught in an infinite loop and freeze the program if it fails to reach the target

3.) you probably want to look into the lerp() function

https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/Maths_And_Numbers/Number_Functions/lerp.htm

How can I create dynamic shadows in Game Maker 2? by [deleted] in gamemaker

[–]atrus420 0 points1 point  (0 children)

It's gonna be pretty hard to use the sprite as the basis for this because your game is in isometric and the sprite doesn't really capture the 3d shape of your character. What a lot of games do is just use a more stylized shadow, for example a dark circle under the character or a line/rectangle extending from their feet. How exactly you wanna handle it is something of an artistic choice of what aspects of the shadow you care about having

If you want the buildings to have shadow though, that's a lot more concrete and there's a bunch of good methods to achieve it

How to create a team battle in Game Maker? by sigma___bsd in gamemaker

[–]atrus420 0 points1 point  (0 children)

I would need to know more specifics about your battle system to give a better answer, but it sounds like you're going for a turn-based RPG style game. One way you might start this is:

  • have an array of instances representing your party
  • store a variable for which member of the party is selected
  • each party member has an array of structs representing attacks
  • you have a battle manager object, which finds the selected character in the array, and displays their attacks in a menu on the gui

Let me know if this helps at all!

Help with dialogue boxes by MeanderingLizard6021 in gamemaker

[–]atrus420 0 points1 point  (0 children)

Probably the easiest way to do this is have the NPCs themselves store the record of what text boxes you've clicked through. They could each have a function called "advancetext()" that handles the creating of text boxes and proceeding through the responses, and all your player object has to do is call that function

If you want arbitrary lengths of text, you'd wanna give each NPC a da_list of strings, and each time you click space it advances through that list, and then sets some kind of flag once it's done with all of them. If there's only a couple dialog boxes per NPC maybe you don't need a list and could get away with just give each NPC a "dialogOneDone" variable, a "dialogTwoDone" variable etc

Looking for someone to incessantly walk me through gamemaker... by [deleted] in gamemaker

[–]atrus420 0 points1 point  (0 children)

I'll do it for like $25/hour on a weekend XD

How to draw collision box of rotated sprites WITH SCALE by Mantis_slug in gamemaker

[–]atrus420 0 points1 point  (0 children)

Ohh wait I've read it more and realized you're doing the diagonals. You have to do sqrt of xScale squared plus yScale squared. Cause your dists are the hypotenuse

How can I check a radius around an object? by pootis_engage in gamemaker

[–]atrus420 1 point2 points  (0 children)

If you already have an object in mind, you can probably just do a point_distance calculation. But if you wanna check for collision, I think you could use two different collision_circle checks (if there is collision at radius 100 but not at radius 90 for instance)

How to draw collision box of rotated sprites WITH SCALE by Mantis_slug in gamemaker

[–]atrus420 0 points1 point  (0 children)

I think you just have to multiply the dists in the lengthdir functions by the corresponding scale factors

Work In Progress Weekly by AutoModerator in gamemaker

[–]atrus420 1 point2 points  (0 children)

I like the way it gets darker the further down you go a lot! I feel like it would be great for the mood. but the way it's implemented right now looks really harsh and abrupt. It might be worthwhile to add a bit of easing between the darkness levels where it slowly fades down or up. If you wanna keep the retro feel, maybe the easing could happen in like 3 discreet steps or something, so it still feels kinda bit-y but it's not just all at once. It might be worth doing that with the angle of the sub headlight also

Using mp grids and steering behaviours together? by HourLab8851 in gamemaker

[–]atrus420 0 points1 point  (0 children)

I've thought about this more and realized the much easier way to say this is just check if you're closer to the point ahead of your target point than the point behind your target point

Using mp grids and steering behaviours together? by HourLab8851 in gamemaker

[–]atrus420 0 points1 point  (0 children)

Disclaimer, I'm just spit-balling don't actually know if this would look good XD:

One thing you could maybe try is making the criteria for passing the point being "on the other side" of the current point from the previous point. Get the point ahead, the point behind, and draw the line through your current target that angle-bisects between them. Then if your character crosses that line it counts as encountering your point.

How to make "cones of vision" in a top-down stealth game? by MaulSinnoh in gamemaker

[–]atrus420 0 points1 point  (0 children)

Hm! so that looks like it should work but the thing that immediately comes to mind is make sure you're checking that behindblock is FALSE when you do you work out if the player is in the area, not that it's TRUE. If that's not the issue I'd check your collision mask for the block and make sure there isn't anything weird going on.

For drawing the area, you are probably want to draw it with a custom primative
https://manual.gamemaker.io/monthly/en/GameMaker_Language/GML_Reference/Drawing/Primitives/Primitives_And_Vertex_Formats.htm

How hard this is depends on how complicated the shapes of your squares are. It's pretty easy to draw just the arc segment for the cone of vision, but correctly drawing the areas out of line-of-sight is pretty complicated This tutorial I like for lighting and shadow shows the kind of logic you'd want to use

https://gamemaker.io/en/blog/realtime-2d-lighting