• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code what is a view camera?

whats a view camera? is it just a weird name for the actual camera?

I'm trying to retrieve the camera's position and size but all I see are camera view functions
 

Jakylgamer

Member
yea this is a bit confusing at first but heres how to go about it
Code:
var view_wview = camera_get_view_width(view_camera[0]);
var view_hview = camera_get_view_height(view_camera[0]);
var view_xview = camera_get_view_x(view_camera[0);
var view_yview = camera_get_view_y(view_camera[0]);
and thats basically the functions remade in gms2

then to set the position you need
Code:
camera_set_view_pos(view_camers[0],view_xview,view_yview);
 
does the camera draw the screen before it is scaled up with viewports properties

if so is it possible to have the camera be smaller then the actual view?

I'm trying to get my camera draw the unscaled version of my screen onto the scaled viewport
 

Jakylgamer

Member
if you mean like have a view port 640 x 480 then a view inside that of lets say 320 x 240
i think you have to use the camera_create() functions and set the matrix finctions for it .
not sure how to implement this yet still tinkering around with the camera stuff
 
no I mean like a zelda style screen where there are multiple screens in a map(room)
I want to draw the unscaled current screen to the scaled viewport in my game window.
here is some example code

Code:
//set background color when there is no veiwport
window_set_color($ff00ff)

//set the global variables
globalvar Screen_Camera, Screen, Screen_Prev, Screen_X1, Screen_Y1, Screen_X2, Screen_Y2;

//create camera and set the screen and previous screen to 0 (aka top left screen on the map(room))
Screen_Camera = camera_create();
Screen        = 0;
Screen_Prev   = Screen;

///popolate Screen rects with all possible screens
for (var i=0; i<256; i++)
{
    Screen_X1[i] = i * 160;
    Screen_Y1[i] = i * 128; // leave 16 pixels for the hud
    Screen_X2[i] = Screen_X1[i] + 160;
    Screen_Y2[i] = Screen_Y1[i] + 128; // leave 16 pixels for the hud
}
//make Screen_Camera draw to view 0
view_set_camera(0, Screen_Camera);

//set camera script for drawing screen background color
camera_set_begin_script(Screen_Camera, scr_camera_begin)

//Testing Variable because I can't get it to work
Screen_Camera_X = camera_get_view_x(Screen_Camera);
Screen_Camera_Y = camera_get_view_y(Screen_Camera);
Screen_Camera_W = camera_get_view_width(Screen_Camera);
Screen_Camera_H = camera_get_view_height(Screen_Camera);

Screen_View_X = view_ (Screen_Camera);
Screen_View_Y = camera_get_view_y(Screen_Camera);
Screen_View_W = camera_get_view_width(Screen_Camera);
Screen_View_H = camera_get_view_height(Screen_Camera);

//hud camera not used yet
//SubScreen_Camera = camera_create();
//camera_set_view_pos(SubScreen_Camera, -160, -144)

/code]
 
idk I think cameras are bugged right now I scaled down everything just to see if it works and it doesn't

window_size = (160, 144)
room_size = (160, 128)
view_size = (160, 128)
viewport_size = (160, 144)
custom screen variable array size = (160, 128)

I have a window buffer color of (255, 0, 255, 255)
I have a room background color of (0, 0, 0, 0)
I am drawing a rectangle color of (0, 0, 0, 255) in the camera update event

@Nocturne plz tell me this is a bug if not its a serious design flaw on yoyogames end

this is my scripts
Code:
window_set_color($ff00ff)
///Camera Settings
globalvar Screen_Camera, Screen, Screen_Prev, Screen_X, Screen_Y, Screen_W, Screen_H;  

Screen        = 0;
Screen_Prev   = Screen;
for (var i=0; i<256; i++)
{
    Screen_X[i] = i * 160;
    Screen_Y[i] = i * 128;
    Screen_W[i] = 160;
    Screen_H[i] = 128;
}

window_set_size(160, 144);
Screen_Camera = scr_camera_create(0, Screen_X[Screen], Screen_Y[Screen], Screen_W[Screen], Screen_H[Screen])
view_set_camera(0, Screen_Camera);
Code:
/// @ description scr_camera_resize
/// @ param target_veiw
/// @ param x
/// @ param y
/// @ param width
/// @ param height

// Parameters Vars
var _v = argument[0];
var _x = argument[1];
var _y = argument[2];
var _w = argument[3];
var _h = argument[4];

var _cam = camera_create();
          camera_set_view_pos(_cam, _x, _y);
          camera_set_view_size(_cam, _w, _h);
          camera_set_begin_script(_cam, _scr_camera_clear); // this is the script that draws a rectangle to the screen arrays with the current screen index
          camera_set_update_script(_cam, _scr_camera_update); // script defined here is empty
  
view_set_camera(_v, _cam);
camera_apply(_cam);
return _cam;

I am getting really frustrated and it seems like noone can help me because they don't know either

Edit: I just realized there are no tutorials on camera's either

Edit2: ok so I got it working however I had to use camera_create_view() instead of camera_create which is obviously a bug someone can report it if they care
however my view or camera is getting clipped on the top and bottom edges of the screen by 8 pixels and i don't know why
 
Last edited:
Top