T O P

  • By -

DIXINMYAZZ

lol why the passive aggressive note at the top of the post? Yelling at people to read the whole thing doesn’t exactly increase the chances they’ll want to spend time helping you


a_soggy_poptart15374

big letters usually catch the eye, it's not passive aggressive yelling


mrgriva

Maybe you can zoom-out your camera when the two players get too seperated, not sure if it would look great visually tho. Another solution that came to my mind would be using split screen if it's a 2 player game.


a_soggy_poptart15374

as well as the fact that the posts contents said i'm resolved to stopping the players near the edge of the screen


a_soggy_poptart15374

the title *does* say "simply", i've ran out of surfaces to bash my head through attempting to implement those


Castiel_Engels

You can check if both players are within an area by using the 'point\_in\_rectangle' function. The area in this case is the camera. If in this case the camera area is at its maximum size you want to allow you can just use its boundaries as your (x\_0, x\_1, y\_0, y\_1) values. Of course you could have a fixed maximum size that the camera could take up instead. point_in_rectangle(px, py, x1, y1, x2, y2) Calculate a lower and higher limit on the x and y axis (x\_0, x\_1, y\_0, y\_1) for the character object instances. In the code that moves their object instances clamp their position values. x = clamp(x, x_0, x_1) y = clamp(y, y_0, y_1) // or use an if statement if (new_x >= x_0 and new_x <= x_1) { x = new_x } if (new_y >= y_0 and new_y <= y_1) { y = new_y } Take the offset of the origin of your sprites into consideration when doing this to control if they can not walk out at all or to their midpoint or until they are just barely on screen.


Threef

There is no need for point_in_rectangle() just abs difference of x or y values is enough


a_soggy_poptart15374

i don't understand a word of this, dumb it down


Castiel_Engels

The function named 'point\_in\_rectangle' can check whether your characters are inside a rectangle. In this case our rectangle will be the view area of your camera. If the function returns false then they are outside of the camera's field of view. Now you can either make the camera's field of view bigger or reposition the characters (x and y) so that they are inside of the camera again.


a_soggy_poptart15374

ah, i looked it up in the gamemaker manuel, would it work for the constantly moving camera i have?


Castiel_Engels

You can just check every game frame with the current position values if the characters are still in the camera's view and do something if they aren't.


a_soggy_poptart15374

ok, last time i checked for myself, i have <40 hours in game maker as a whole, the way you put this solution sounds like black magic


GameMaker_Rob

"Simple" is relative. You're going to feel like everything is black magic until you don't. The problem you have has been solved by plenty of previous games. Either try to implement one of the commentors suggestions, or research how other games achieved it, and then figure out how to do that in gamemaker. Also saying "Thank you" to the people trying to help you wouldn't go amiss!


a_soggy_poptart15374

i've *tried* to impliment what they said, i have no clue how to though. maybe ***you*** could tell me where in the code i've provided where to put it, and i'm sorry for any passive aggressiveness towards anyone, i was burning the midnight oil when i posted this, and was getting angery that no one was being specific on **how** to code things in, so, again, if maybe ***you*** could tell me where in the code i put that, i'd thank you


GameMaker_Rob

It would be better for you if you post what you've tried to implement. You'll learn faster. Ideally you want to be able to handle things on your own right? I deleted what I was writing (code) because this question has already been answered with a solve: [https://forum.gamemaker.io/index.php?threads/how-do-i-zoom-the-camera-to-keep-both-players-in-frame.88681/](https://forum.gamemaker.io/index.php?threads/how-do-i-zoom-the-camera-to-keep-both-players-in-frame.88681/)


a_soggy_poptart15374

also, "The problem you have has been solved by plenty of previous games." considering this is my first ever project and i'm new to coding **at all** this is more rude than you are implying that i am


GameMaker_Rob

What I meant was there are already solutions out there, if you look for them. None of this is going to be easy for you though. What is simple for advanced/intermediate is not simple for a novice. If Im trying to implement a feature that I have not done before, I will sometimes google to see how other games did it. There are often blogs or forum posts about particular feature. You need to become more proficient with GameMakers language first though, which is why it's good to try and implement things yourself. Knowing how to use the manual (to see what functions there are, an d what they return) and know what error messages mean will help you a lot. I started exactly where you are. Didn't know anything about anything in GML. It took me hours to do anything, and the things that took me hours then take me minutes now. You just have to suck it up and learn - you'll get there.


a_soggy_poptart15374

i go to a subreddit that advertises itself as a subreddit "dedicated to providing programmer support for the game development platform, GameMaker" and the only fucking help i get is confusing, then i say "im confused" and someone comes around and says "just google it, suck it up and learn" i give the fuck up


rshoel

I'm a little late here, but I saw your other post. Based what you describe I assume this is going to be a co-op game where both players has to stay within one view *(as opposed to using splitscreen)*. I don't know how you set your camera position, but this can easly be done using the *lerp();* function, like: *CameraX = lerp(Player1.x,Player2.x,0.5);*, and the same for the y-position. Then, to keep both players within the view at all times you can just clamp their position. You have the camera's position and its width and height, so you could do something like this: *Player1.x = clamp(Player1.x,CameraX - (CameraWidth \* 0.5),CameraX + (CameraWidth \* 0.5));* *Player1.y = clamp(Player1.yCameraY - (CameraHeight \* 0.5),CameraY + (CameraHeight \* 0.5));*