Demo entry 6787662

olivia

   

Submitted by anonymous on Apr 14, 2019 at 23:38
Language: JavaScript. Code size: 7.9 kB.

//view_w_half = camera_get_view_width(cam) * 0.5;

//view_h_half = camera_get_view_height(cam) * 0.5; //to view middle of camera

xTo = xstart; //what were moving towards at any point in time
yTo = ystart;


view_w_half = 300
view_h_half = 240

camera_set_view_size(cam, view_w_half*2, view_h_half*2)


//@description update camera


//object represents where the camera should be

//update destination
if(instance_exists(follow)){
	
	xTo = follow.x; //looks to see if theres an x coordinate and puts it into xTo
	yTo = follow.y;
	
	
}

//update object position

x+= (xTo - x) / 25; //difference between where we want to be (xTo) and where we currently are (x)
					//moves us 1/25th  of the distacne bewteen the current position between x and xTo
y+= (yTo - y) / 25;


x = clamp(x, view_w_half, room_width - view_w_half);
y = clamp(y, view_h_half, room_height - view_h_half);




//update camera view

camera_set_view_pos(cam, x - view_w_half, y - view_h_half)


//if(room!=rMenu){
	
//	layer_x("Background", x/2);
//	layer_y("Background", y-180);
	
//}

if(room!= rMenu) && (room != rEnding){

if(layer_exists("backwall")){

	layer_x("backwall", x / 2); //gonna move half the speed as the camera
	
}
if(layer_exists("waterfalls")){

	layer_x("waterfalls", x / 4); //gonna move half the speed as the camera
	
}
}


/// @desc gui/vars/menu setup

#macro SAVEFILE "Save.sav"



gui_width = display_get_gui_width();
gui_height = display_get_gui_height();
gui_margin = 32;


menu_x = gui_width;//+200;
menu_y = gui_height - gui_margin;
menu_x_target = gui_width - gui_margin;
menu_speed = 25; //lower is faster
menu_font = fMenu;
menu_itemheight = font_get_size(fMenu);
menu_committed = -1;
menu_control = true;


menu[2] = "New Game";
menu[1] = "Continue";
menu[0] = "Goodbye";

menu_items = array_length_1d(menu);
menu_cursor = 2;

/// @desc control menu

//item ease in

menu_x +=(menu_x_target - menu_x) / menu_speed;


//keyboar controls


if(menu_control) {
	
	if(keyboard_check_pressed(vk_up)){
		
		menu_cursor++;
		if(menu_cursor >= menu_items){
			menu_cursor = 0;
		}
		audio_play_sound(singleNote, 6, false);
		
	}
	
	if(keyboard_check_pressed(vk_down)){
		
		menu_cursor--;
		if(menu_cursor < 0){
			menu_cursor = menu_items - 1;
		}
		audio_play_sound(singleNote, 6, false);
		
	}
	
	if(keyboard_check_pressed(vk_enter)){
	
		menu_x_target = gui_width+200;
		menu_committed = menu_cursor;
		menu_control = false;
		audio_play_sound(sparkle3, 10, false);
		
	}
	
	
}

if(menu_x > gui_width+150) && (menu_committed != -1){
	
		switch(menu_committed){
			// temporary, change below
			//case 2: slideTransition(TRANS_MODE.GOTO, Bar); break;
			case 2: slideTransition(TRANS_MODE.NEXT); break;
			case 1:{
				
				if(!file_exists(SAVEFILE)){
					
					slideTransition(TRANS_MODE.NEXT);
					
				}
				else{
					var file = file_text_open_read(SAVEFILE);	
					var target = file_text_read_real(file);
					file_text_close(file);
					slideTransition(TRANS_MODE.GOTO, target);
				}
				
				
			}
			break;
			case 0: game_end(); break;
			
		}
	
}

/// @desc draw menu

draw_set_font(fMenu);
draw_set_halign(fa_right);
draw_set_valign(fa_bottom);

for(var i = 0; i < menu_items; i++){
	
	var offset = 2;
	var txt = menu[i];
	
	if(menu_cursor == i){
		txt = string_insert("> ", txt, 0);
		var col = c_white;
	}
	else{
	
		var col = c_gray;
	
	}
	
	var xx = menu_x;
	var yy = menu_y - (menu_itemheight * (i*1.50));
	
	draw_set_color(c_black);
	draw_text(xx - offset, yy, txt);
	draw_text(xx + offset, yy, txt);
	draw_text(xx, yy - offset, txt);
	draw_text(xx, yy + offset, txt);
	
	draw_set_color(col);
	draw_text(xx, yy, txt);
	
	
	
}

draw_set_color(c_black);
draw_rectangle(gui_width, gui_height-200, gui_width+900, gui_height, false);

if (audio_is_playing(mWaterfall))
   {
		audio_sound_gain(mWaterfall, 0, 2500);
		audio_sound_gain(underwaterWail, 0, 2500);
   }


audio_play_sound(solemnbeach2, 7, true);
audio_play_sound(drips2, 7, true);
audio_play_sound(dripsLOUD2, 7, true);

if (audio_is_playing(solemnbeach))
   {
		audio_sound_gain(solemnbeach, 0, 2500);
		audio_sound_gain(dripsLOUD, 0, 2500);
		audio_sound_gain(drips, 0, 2500);
		
   }
  else if (audio_is_playing(templeofistus))
   {
		audio_sound_gain(templeofistus, 0, 2500);
   }


audio_play_sound(mWaterfall, 7, true);
audio_play_sound(underwaterWail, 7, true);

if (audio_is_playing(mWaterfall))
   {
		audio_sound_gain(mWaterfall, 0, 2500);
		audio_sound_gain(underwaterWail, 0, 2500);
   }
   
   audio_play_sound(templeofistus, 7, true);
   audio_play_sound(underwaterWail, 7, true);
   
/// @ desc 


spd = 0.25; //speed at which text is gonna come onto the screen = 1 chara every 4 frames (spd of 1 is 1 charactr every frame)
letters = 0; // how man ywe should be currently drawing to the screen
text = "Welcome, Lucinda\nShe's waiting for you";
length = string_length(text);
text_current = "";
w = 0;
h = 0;
border = 10;

///@desc progresstext

letters += spd;

text_current = string_copy(text, 1, floor(letters));

draw_set_font(fSign);

if(h == 0)h = string_height(text);	
	w = string_width(text_current);


//drestory

if(letters >=length) && (keyboard_check_pressed(vk_anykey)){
		instance_destroy();
		with (objectCamera) follow = objectPlayer;
}

///@desc


var halfw = w * 0.5;

//draw the box
draw_set_color(c_black);
draw_set_alpha(0.5);
draw_roundrect_ext(x-halfw-border, y-h-(border*2), x+halfw+border, y, 15, 15, false);

draw_sprite(sMarker, 0, x, y);
draw_set_alpha(1);


//draw text

DrawSetText(c_white,fSign,fa_center,fa_top);
draw_text(x, y - h - border, text_current);

// Allows one line setup of major text drawing vars.
// Requring all four prevents silly coders from forgetting one
// And therefore creating a dumb dependency on other event calls.
// (then wondering why their text changes later in development)

#macro RES_W 1024
#macro RES_H 768

display_set_gui_size(RES_W, RES_H);


global.game_width = display_get_gui_width();
global.game_height = display_get_height();

global.show_inventory = false;
global.inv_slots = 16;
global.ds_inventory = ds_grid_create(2, global.inv_slots);
global.double_jump_enabled = false;
global.character_lock = false;
//display_set_gui_size(global.game_width, global.game_height);


if(keyboard_check(vk_lshift)){

	window_set_fullscreen(!window_get_fullscreen()); //gets true or false if its full screen and does the opposite

}

scene_info = [
	[cutscene_move_obj, objectPlayer, 400, 0, 5]
];

create_cutscene(scene_info);


if(keyboard_check(vk_lshift)){

	window_set_fullscreen(!window_get_fullscreen()); //gets true or false if its full screen and does the opposite

}

//@desc move player towards the center

layer_x("TitleAssets", min(layer_get_x("TitleAssets")+1 , RES_W * 0.5 - 32));

//progress text

letters += spd;

text = string_copy(endtext[currentline], 1, floor(letters));

//next line
if(letters >= length) && (keyboard_check_pressed(vk_anykey)){
	
	if(currentline+1 == array_length_1d(endtext)){
		//layer_x("TitleAssets", min(layer_get_x("TitleAssets")+1 , RES_W * 0.5 - 32)); MOVE OFFSCREEN
		slideTransition(TRANS_MODE.RESTART); //go to title screen
	}
	else{
		currentline++;
		letters = 0;
		length = string_length(endtext[currentline]);
	}
	
}

draw_set_color(c_black);
draw_rectangle(0, 0, RES_W, 128, false);
draw_rectangle(0, RES_H-128, RES_W, RES_H, false);

DrawSetText(c_black, fSign, fa_center, fa_top);
draw_text(RES_W*0.5 + 2, RES_W*0.3 + 2, text);
draw_set_color(c_white);
draw_text(RES_W*0.5, RES_W*0.3, text);

 

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).