• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Proper views?

Hey I'm currently creating an own view, that is supposed to be exactly like the views you can create In the room settings. Everything works fine, except for the vbor. How can I set up a proper vertical border?
My view is always fixed in the center because I used:

view_yview[0] = y-(view_hview[0]/2);

(Game maker 8)

So, what could be a proper alternative way to get a smooth vertical border?

It's a platformer game, and when I for example jump, the camera follows up, and immediately goes down again, when the player is landing. What I want is a vbor of 128 pixels.

Thanks for any help.


EDIT:
I tried to implement an own border, but it turned out to be like the old zelda map transitions. That's too abrupt.
Any ideas? :)
 
Last edited:
Just off the top of my head, I would create an object,maybe call it o_camera, and have it's x position set to the players x position. Then, in the step event of o_camera, I would check if the players y position is within 128 pixels of o_camera y position. If it is greater than 128 pixels, Then I would move the camera y position to within 128 pixels. To make it more smooth, use some smoothing function, can't remember right now but I think gamemaker has a smoothstep function, or else you could try move towarrd point.

Finally, at the end of the step event, set the view to the o_camera x and y position.
 
There is also a marketplace asset called ex_camera which may be able to do what you want. Check out it's documentation to see if it can.
Thanks for your reply, but if I understand it right, it's not exactly what I want.

English is my foreign language, so I'll explain it in another way:

1. Create a new game
2. Create a player object, that can move
3. Create a huge room
4. Create a smaller view, that follows the player object (simply in room settings)
5. Hbor = 190, Vbor = 128.

Now when your player moves up, the view moves up and stays there as long as the player moves outside the Vbor down again.
This is what I want.
My camera instantly moves down again, even if I'm inside the Vbors.
Because my view is centered to the screen middle. That's not what I want. :/ I tried to use stuff like

If player.y < (view_yview[0]+(view_hview[0])/2)-128 {...}

Or similar versions. But once again all I could fill in the {} was centering the view. My problem is more that I don't know, where or how to set the view x & y.

Your version sounds good tho, but I guess that's not exactly what I imagine. Thanks for your help!! :)
 
What's stopping you from using the gamemaker view controls?

I'm not at home right now, but I'll see if I can test my solution later and share it with you.

Could you post the complete code you have tried so far?
 
What's stopping you from using the gamemaker view controls?

I'm not at home right now, but I'll see if I can test my solution later and share it with you.

Could you post the complete code you have tried so far?
thing is: I'm always on my phone because I don't have WiFi in my new flat yet.. :(
I made a screen shake and that's why I can't use the built in view options. I played around with it a bit but nothing worked. Everything works with the version I used, but I don't want it to be centered. What I need is something different to put in the { }... I'm gonna try something later and tell you whether it worked or not :D
 
Hmmm...I've made a screen shake before while still being able to use the gamemaker views. In fact, I think I got the code from a thread discussing screen shake in the old game maker forums. I'll see if I can find it later.
 
Oh my gosh I feel so nooby.. LOL I solved it.
The answer is as dumb as easy:
All I had to do was taking out the screen centering code and replace it by simply:

view_object[0] = obj_Player;
view_hborder[0] = 190; //desired hbor
view_vborder[0] = 128; //desired vbor

We'll thanks anyway I'm glad you tried to help me! :) :) :)
 
Doh...well, those are the built in game-maker view controls - and you said you couldn't use the built in view options - so I didn't think to mention them. Glad you found the solution!
 
It's ok, maybe I said it wrong, it's my fault!. I assumed you meant you wanted to write new code to make your own view system. ;)
 
Top