• 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!

How can I limit a space in my room where the view can move? / fixating a view in a specific spot on

T

thiagohimself

Guest
Hello everyone!

I am making a mobile platform fighter (using GMS 1.4) that looks like this:



So, the idea is to have a big square in the center where the action takes place and on the top and bottom we have each player’s controller.

I made a prototype and got a few feedbacks from my friends and they felt the levels should be bigger. I didn’t want to shrink everything, so, as a compromise I created a system where the camera follows the action of the game and zooms in or out depending on the distance of the characters. By doing that I doubled the space of the room where the action happens, but limited the port to the same size I had before (a 360px square).




However, I did this system without the space for the controllers and now I have no idea how to can I add them back.

My theory is that I should raise the room height / the view port height so I can add the virtual controller on the GUI, while limiting the moment of the view to happen only in the center. But whenever I tried to that the image starts to stretch.

I am not sure on what I should do to fix my problem…
 
T

thiagohimself

Guest
The image I wanted to show was this:
Drama Kids.jpg

and here is the code I made for the zoom:

on the step event:

/// ZOOM
// se os dois objetos dos jogadores existir medir a distancia entre eles
if (instance_exists(obj_player1) and instance_exists(obj_player2)){
distancia = round(point_distance(obj_player1.x, obj_player1.y, obj_player2.x,obj_player2.y))
}
// movimenta a camera
x = round( (obj_player1.x + obj_player2.x) / 2 );
y = round( (obj_player1.y + obj_player2.y) / 2 );
// zoom 0
if (distancia >= 0 and distancia <= 150)
{
i = 0;
}
// zoom 1
if (distancia >= 151 and distancia <= 255)
{
i = 1;
}
// zoom 2
if (distancia >= 256 and distancia <= 345)
{
i = 2;
}
// zoom 3
if (distancia >= 346 and distancia <= 455)
{
i = 3;
}
// zoom 4
if (distancia >= 456 and distancia <= 560)
{
i = 4;
}
// zoom 5
if (distancia >= 561)
{
i = 5;
}
if (obj_player1.x - 10 < view_xview[0] or obj_player2.x -10 < view_xview[0] or obj_player1.x +10 > (view_xview[0] + view_wview[0]) or obj_player2.x +10 > (view_xview[0] + view_wview[0]) or obj_player1.y + 10 < view_yview[0] or obj_player2.y + 10 < view_yview[0] or obj_player1.y - 10 > (view_yview[0] + view_hview[0]) or obj_player2.y - 10 > (view_yview[0] + view_hview[0])){
if (i < 5){
i += 1;
}
}
// seleciona qual o zoom a ser utilizado
zoom_check = zoom

// cria o zoom
if (zoom_check != view_hview[0]){
if (view_hview[0] > zoom_check){
view_hview[0] -= 5;
view_wview[0] -= 5;
}
if (view_hview[0] < zoom_check){
view_hview[0] += 5;
view_wview[0] += 5;
}
}
 
Top