Skip to content

Commit

Permalink
Merge pull request #15 from jack27121/v2.2.0
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
jack27121 committed Jul 29, 2023
2 parents f607fb6 + 3f55b7e commit 2466e37
Show file tree
Hide file tree
Showing 103 changed files with 2,555 additions and 232 deletions.
6 changes: 6 additions & 0 deletions objects/__obj_stanncam_manager/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ resolution_w = 0;
resolution_h = 0;
number_of_cams = 0;
keep_aspect_ratio = true;

resize_width = 0;
resize_height = 0;

__display_scale_x = 1;
__display_scale_y = 1;
2 changes: 1 addition & 1 deletion objects/__obj_stanncam_manager/Other_4.gml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ for (var i = 0; i < array_length(global.stanncams); ++i) {
if (global.stanncams[i] == -1) continue;
global.stanncams[i].__check_viewports();
}
__stanncam_update_resolution();
__stanncam_update_resolution();
7 changes: 7 additions & 0 deletions objects/__obj_stanncam_manager/Step_2.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ for (var i = 0; i < array_length(global.stanncams); ++i) {
if (global.stanncams[i] == -1) continue;
global.stanncams[i].__step();
}

//constantly checks if the window is being resized and changes the resolution to match
if(global.window_mode == STANNCAM_WINDOW_MODE.windowed && (resize_width != window_get_width() || resize_height != window_get_height())){
resize_width = window_get_width();
resize_height = window_get_height();
stanncam_set_resolution(resize_width,resize_height);
}
4 changes: 2 additions & 2 deletions objects/obj_ball/obj_ball.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions objects/obj_camera/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @description
//camera
stanncam_init(320,240,1920,1080);
stanncam_init(320,180,1920,1080);
cam1 = new stanncam(obj_player.x,obj_player.y,global.game_w,global.game_h);
cam1.follow = obj_player;

Expand All @@ -14,7 +14,7 @@ pointer_x = 0;
pointer_y = 0;

zoom_mode = 0;
zoom_text = "no zooming"
zoom_text = cam1.zoom_amount

speed_mode = 1;

Expand Down
20 changes: 17 additions & 3 deletions objects/obj_camera/Draw_64.gml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,32 @@ var following = (cam1.follow != undefined) ? "following" : "not following"
draw_text_outline(1,offset,"[space] " + following,outline_width,precision);
draw_text_outline(1,offset*2,"[ALT] toggle hi-res GUI",outline_width,precision);
draw_text_outline(1,offset*3,"[LMB] move cam to pos (when not following)",outline_width,precision);
draw_text_outline(1,offset*4,"[RMB] "+ zoom_text,outline_width,precision);
draw_text_outline(1,offset*4,"[RMB] Zoom amount: "+ string(zoom_text),outline_width,precision);
var constrained = (cam1.room_constrain) ? "camera constrained to room" : "camera not constrained to room";
draw_text_outline(1,offset*5,"[CTRL] "+ constrained,outline_width,precision);
draw_text_outline(1,offset*6,"[F] camera shake",outline_width,precision);
draw_text_outline(1,offset*7,"[Tab] camera speed "+ string(cam1.spd),outline_width,precision);
draw_text_outline(1,offset*8,"[1 & 2] to switch between example rooms",outline_width,precision);

//draw current resolution text
draw_set_halign(fa_right)
draw_text_outline(global.gui_w-1,1,"game resolution: "+string(__obj_stanncam_manager.display_res_w)+" x "+string(__obj_stanncam_manager.display_res_h)+" [F1]",outline_width,precision);
draw_text_outline(global.gui_w-1,1,"game resolution: "+string(global.res_w)+" x "+string(global.res_h)+" [F1]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset,"GUI resolution: "+string(global.gui_w)+" x "+string(global.gui_h)+" [F2]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset*2,"Keep aspect ratio: "+string(stanncam_get_keep_aspect_ratio())+" [F3]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset*3,"fullscreen: "+string(window_get_fullscreen())+" [F4]",outline_width,precision);
var window_mode_text = "";
switch (global.window_mode) {
case STANNCAM_WINDOW_MODE.windowed:
window_mode_text = "windowed ";
break;
case STANNCAM_WINDOW_MODE.fullscreen:
window_mode_text = "fullscreen";
break;
case STANNCAM_WINDOW_MODE.borderless:
window_mode_text = "borderless";
break;
}

draw_text_outline(global.gui_w-1,offset*3,$"window mode: {window_mode_text} [F4]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset*4,"split-screen: "+string(split_screen)+" [F5]",outline_width,precision);

//point at player, when it's outside camera bounds
Expand Down
3 changes: 3 additions & 0 deletions objects/obj_camera/Keyboard_123.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// @description


20 changes: 13 additions & 7 deletions objects/obj_camera/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,22 @@ if(mouse_check_button_pressed(mb_right)){
switch (zoom_mode) {
case 0:
//no zooming
zoom_text = "no zooming";
cam1.zoom(1,room_speed*1);
obj_tv.tv.zoom(1,room_speed*1);
break;
case 1:
//zoom in
zoom_text = "zoomed in";
cam1.zoom(0.5,room_speed*1);
obj_tv.tv.zoom(0.5,room_speed*1);
break;
case 2:
//zoom out
zoom_text = "zoomed out";
cam1.zoom(2,room_speed*1);
obj_tv.tv.zoom(2,room_speed*1);
break;
}
}
zoom_text = cam1.zoom_amount;

//toggle camera speed
if(keyboard_check_pressed(vk_tab)){
Expand Down Expand Up @@ -118,8 +116,16 @@ if(keyboard_check_pressed(vk_f2)){
stanncam_set_gui_resolution(gui_w,gui_h);
}

//toggle fullscreen
if(keyboard_check_pressed(vk_f3)) stanncam_toggle_keep_aspect_ratio();
//toggle keep aspect ratio
if(keyboard_check_pressed(vk_f3)){
stanncam_set_keep_aspect_ratio( !stanncam_get_keep_aspect_ratio() );
}

//toggle fullscreen
if(keyboard_check_pressed(vk_f4)) stanncam_toggle_fullscreen();
//toggle between window modes
if(keyboard_check_pressed(vk_f4)){
var window_mode = global.window_mode;
window_mode++;
if (window_mode == 3) window_mode = 0;

stanncam_set_window_mode(window_mode)
}
7 changes: 4 additions & 3 deletions objects/obj_camera/obj_camera.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions objects/obj_camera_sidescroller/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// @description
//camera
stanncam_init(400,270,1920,1080);
cam1 = new stanncam(obj_player_sidescroller.x,obj_player_sidescroller.y,global.game_w,global.game_h);
cam1.follow = obj_player_sidescroller;
cam1.room_constrain = true;

cam2 = cam1.clone();
cam2.follow = obj_player_sidescroller2;
cam2.set_size(global.game_w/2,global.game_h,0);

split_screen = false;

//pointer
zoom_text = cam1.zoom_amount

speed_mode = 1;
zoom_mode = 1;

game_res = 2;
gui_hires = false;
gui_res = 0;

resolutions = [
{ w:400 , h:400 }, //1:1
{ w:500 , h:250 }, //2:1
{ w:320 , h:180 }, //16:9
{ w:640 , h:360 },
{ w:1280 , h:720 },
{ w:1920 , h:1080 },
{ w:2560 , h:1440 }
]

lookahead = false;

surface = -1;
51 changes: 51 additions & 0 deletions objects/obj_camera_sidescroller/Draw_64.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// @description
//chooses pixel font or hires font
if(gui_hires){
draw_set_font(f_hires);
var offset = 45;
var outline_width = 4;
var precision = 16;
draw_set_color(c_white)
} else {
draw_set_font(f_pixel);
var offset = 8;
var outline_width = 1;
var precision = 8;
draw_set_color(c_white)
}

//draws helper text
draw_set_halign(fa_left);
draw_set_valign(fa_top);
draw_text_outline(1,1,"[arrow keys] move character",outline_width,precision);
draw_text_outline(1,offset*2,"[ALT] toggle hi-res GUI",outline_width,precision);
draw_text_outline(1,offset*4,"[RMB] / [SCRL WHEEL] "+ string(zoom_text),outline_width,precision);
var constrained = (cam1.room_constrain) ? "camera constrained to room" : "camera not constrained to room";
draw_text_outline(1,offset*5,"[CTRL] "+ constrained,outline_width,precision);
var debug = (cam1.debug_draw) ? "debug draw on" : "debug draw off";
draw_text_outline(1,offset*6,"[SHIFT] "+ debug,outline_width,precision);
draw_text_outline(1,offset*7,"[F] camera shake",outline_width,precision);
draw_text_outline(1,offset*8,"[Tab] camera speed "+ string(cam1.spd),outline_width,precision);
draw_text_outline(1,offset*9,"[1 & 2] to switch between example rooms",outline_width,precision);

//draw current resolution text
draw_set_halign(fa_right)
draw_text_outline(global.gui_w-1,1,"game resolution: "+string(global.res_w)+" x "+string(global.res_h)+" [F1]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset,"GUI resolution: "+string(global.gui_w)+" x "+string(global.gui_h)+" [F2]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset*2,"Keep aspect ratio: "+string(stanncam_get_keep_aspect_ratio())+" [F3]",outline_width,precision);

var window_mode_text = "";
switch (global.window_mode) {
case STANNCAM_WINDOW_MODE.windowed:
window_mode_text = "windowed ";
break;
case STANNCAM_WINDOW_MODE.fullscreen:
window_mode_text = "fullscreen";
break;
case STANNCAM_WINDOW_MODE.borderless:
window_mode_text = "borderless";
break;
}

draw_text_outline(global.gui_w-1,offset*3,$"window mode: {window_mode_text} [F4]",outline_width,precision);
draw_text_outline(global.gui_w-1,offset*4,"split-screen: "+string(split_screen)+" [F5]",outline_width,precision);
50 changes: 50 additions & 0 deletions objects/obj_camera_sidescroller/Draw_77.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/// @description

parralax_bg = function(cam_){

//the background is scaled up so it appears smooth when being parralaxed

var scalex = stanncam_get_res_scale_x();
var scaley = stanncam_get_res_scale_y();

//the offset the camera is from the middle of the room
var offset_x = (-cam_.get_x() -cam_.x_frac) * scalex;
var pos_x = -200 + cam_.x_frac;
var pos_y = 0 + cam_.y_frac;

draw_sprite_ext_tiled(spr_underwater_layer00,0,pos_x + (offset_x * 0.0),pos_y,2,1,scalex,scaley);
draw_sprite_ext_tiled(spr_underwater_layer01,0,pos_x + (offset_x * 0.2),pos_y,2,1,scalex,scaley);
draw_sprite_ext_tiled(spr_underwater_layer02,0,pos_x + (offset_x * 0.4),pos_y,2,1,scalex,scaley);
draw_sprite_ext_tiled(spr_underwater_layer03,0,pos_x + (offset_x * 0.6),pos_y,2,1,scalex,scaley);
draw_sprite_ext_tiled(spr_underwater_layer04,0,pos_x + (offset_x * 0.8),pos_y,2,1,scalex,scaley);
draw_sprite_ext_tiled(spr_underwater_layer05,0,pos_x + (offset_x * 1.0),pos_y,2,1,scalex,scaley);
}

parralax_bg1 = function(){
parralax_bg(cam1);
}

parralax_bg2 = function(){
parralax_bg(cam2);
}

//fancy splitscreen rendering
var width = global.res_w;
var height = global.res_h;

//the parralax drawing is scaled down again
var scalex = 1/stanncam_get_res_scale_x();
var scaley = 1/stanncam_get_res_scale_y();

if(!split_screen){
cam1.draw_special(parralax_bg1,0,0,width,height,scalex,scaley);
cam1.draw(0,0);
} else {
//fancy splitscreen rendering

cam1.draw_special(parralax_bg1,0,0,width/2,height,scalex,scaley);
cam1.draw(0,0);

cam2.draw_special(parralax_bg2,global.game_w/2,0,width/2,height,scalex,scaley);
cam2.draw(global.game_w/2,0);
}
5 changes: 5 additions & 0 deletions objects/obj_camera_sidescroller/Mouse_60.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// @description
var zoom_amount = cam1.zoom_amount;
zoom_amount-=0.05
zoom_amount = clamp(zoom_amount,0.1,2);
cam1.zoom(zoom_amount,0);
5 changes: 5 additions & 0 deletions objects/obj_camera_sidescroller/Mouse_61.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// @description
var zoom_amount = cam1.zoom_amount;
zoom_amount+=0.05
zoom_amount = clamp(zoom_amount,0.1,2);
cam1.zoom(zoom_amount,0);
Loading

0 comments on commit 2466e37

Please sign in to comment.