Since I'm devastatingly surprised that no one decided to help me on the Pushing or Pulling. So I thought I could be able to put it in here instead, since I hope it can be able to attract help. I've been stuck as a cliffhanger without anyone helping me, and I'm only just a rookie at the coding and such. Just to get on with it, I was trying to do a Mega Man Transition or DuckTales-like Transition for the sake of the similarity.
If you are one of the people who knows it supposed to be in "Coding Help", I know, but people don't feel like helping me for at least 10 days. I hope I can get help just to move on....
*And Also, I'm borrowing TheWreckingPrograms' code for the border from "Mega Man Engine".
Since I'm devastatingly surprised that no one decided to help me on the Pushing or Pulling. So I thought I could be able to put it in here instead, since I hope it can be able to attract help. I've been stuck as a cliffhanger without anyone helping me, and I'm only just a rookie at the coding and such. Just to get on with it, I was trying to do a [b]Mega Man Transition[/b] or [b]DuckTales-like Transition[/b] for the sake of the similarity.
If you are one of the people who knows it supposed to be in "Coding Help", I know, but people don't feel like helping me for at least 10 days. I hope I can get help just to move on....
*And Also, I'm borrowing TheWreckingPrograms' code for the border from "Mega Man Engine".
There's a hundred ways to skin a cat, so to figure out the most efficient way to do this, we'd need some more information. Do you plan on each piece of a level being the same size, like classic Megaman, or will they vary in size like Metroid or Megaman X?
There's a hundred ways to skin a cat, so to figure out the most efficient way to do this, we'd need some more information. Do you plan on each piece of a level being the same size, like classic Megaman, or will they vary in size like Metroid or Megaman X?
And also, the reason why I asked for the Mega Man Transition so I could at least make it look like DuckTales with the movement of the camera, which is only for going up and down. Sorry for the cause of the trouble like this. And yes, I'm still trying to figure it out...
And also, the reason why I asked for the Mega Man Transition so I could at least make it look like [b]DuckTales [/b]with the movement of the camera, which is only for going up and down. Sorry for the cause of the trouble like this. And yes, I'm still trying to figure it out...
So which of these are you looking for specifically?
For the game to pause while the camera moves? Or for the camera to move without the pause? Or are you looking for the fadeout?
I'm not familiar with Wrecking's code, so I can only really help with the general idea and non-Gamemaker-specific code.
https://youtu.be/r9mKFk9dO5Q?t=392
https://youtu.be/Ck5yMwFWHAg?t=150
So which of these are you looking for specifically?
For the game to pause while the camera moves? Or for the camera to move without the pause? Or are you looking for the fadeout?
Ok. So, do you know how to do either separately? As in, do you know how to pause the game and do you know how to move the camera, not necessarily both at the same time.
Ok. So, do you know how to do either separately? As in, do you know how to pause the game and do you know how to move the camera, not necessarily both at the same time.
I did learn how to pause it and a fundamental way of doing so with the "camera movement". I guess I can try to do with the moving camera since it may be a little easier, but still intermediate for a developer like me.
I did learn how to pause it and a fundamental way of doing so with the "camera movement". I guess I can try to do with the moving camera since it may be a little easier, but still intermediate for a developer like me.
So you know how to do both? Uh so what do you specifically need help with? Maybe add some of the relevant code too? I imagined that moving w/ pause can be done separately. As in, you pause the game and let the camera move. When the camera gets to the destination, the game is unpaused. Or, if you want to remove the camera dependency for unpausing, you can add a timer that unpauses the game. It's duration would match the camera move duration.
So you know how to do both? Uh so what do you specifically need help with? Maybe add some of the relevant code too? I imagined that moving w/ pause can be done separately. As in, you pause the game and let the camera move. When the camera gets to the destination, the game is unpaused. Or, if you want to remove the camera dependency for unpausing, you can add a timer that unpauses the game. It's duration would match the camera move duration.
I did find a way to move the camera without pausing, but still may have a little struggle.
Here is some of the sources from WreckingPrograms. (Also changed some stuff to my character)
SCRIPT: SwitchBorders
Code:
///playerSwitchSections() //Moving from one section to the next, if possible
//newSectionXOffset/newSectionYOffset are used to get the right section borders in the new section //Taking the normal X/Y coordinate would result in rounding errors in playerCameraInit(), //which could either cause the game to freeze or the wrong section borders to be used //Using 16 or 32 instead of 64 would also occassionally cause these problems, probably because of the +6/-6
if x > sectionRight-6 && place_meeting(x-hsp-6, y, objSectionArrowRight) //Right && !collision_rectangle(sectionRight+1, bbox_top, sectionRight+2, bbox_bottom, obj_wall, false, false) {
if bbox_top <= view_yview[0] newSectionYOffset = 96; else if bbox_bottom >= view_yview[0]+view_hview[0] newSectionYOffset = -96; else newSectionYOffset = 0;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up } else if x < sectionLeft+6 && place_meeting(x-hsp-6, y, objSectionArrowLeft) //Left && !collision_rectangle(sectionLeft-1, bbox_top, sectionLeft-2, bbox_bottom, obj_wall, false, false) { instance_activate_object(objSectionBorderLeft); instance_activate_object(objSectionBorderRight); instance_activate_object(objSectionBorderTop); instance_activate_object(objSectionBorderBottom); instance_activate_object(objSectionArrowLeft); instance_activate_object(objSectionArrowRight); instance_activate_object(objSectionArrowUp); instance_activate_object(objSectionArrowDown); newSectionXOffset = -64;
if bbox_top <= view_yview[0] newSectionYOffset = 96; else if bbox_bottom >= view_yview[0]+view_hview[0] newSectionYOffset = -96; else newSectionYOffset = 0;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up } else if sprite_get_ycenter() > sectionBottom-6 && place_meeting(x, sprite_get_ycenter()-vsp+6, objSectionArrowDown) //Down && !collision_rectangle(bbox_left+4, sectionBottom+1, bbox_right-4, sectionBottom+2, obj_wall, false, false) { instance_activate_object(objSectionBorderLeft); instance_activate_object(objSectionBorderRight); instance_activate_object(objSectionBorderTop); instance_activate_object(objSectionBorderBottom); instance_activate_object(objSectionArrowLeft); instance_activate_object(objSectionArrowRight); instance_activate_object(objSectionArrowUp); instance_activate_object(objSectionArrowDown); newSectionXOffset = 0; newSectionYOffset = 64;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up } else if sprite_get_ycenter() < sectionTop+6 && place_meeting(x, sprite_get_ycenter()-vsp-6, objSectionArrowUp) //Up && climbing == true && !collision_rectangle(bbox_left+4, sectionTop-1, bbox_right-4, sectionTop-2, obj_wall, false, false) { instance_activate_object(objSectionBorderLeft); instance_activate_object(objSectionBorderRight); instance_activate_object(objSectionBorderTop); instance_activate_object(objSectionBorderBottom); instance_activate_object(objSectionArrowLeft); instance_activate_object(objSectionArrowRight); instance_activate_object(objSectionArrowUp); instance_activate_object(objSectionArrowDown); newSectionXOffset = 0; newSectionYOffset = -64;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up }
Player's Alarm 7
Code:
//Initialize switching sections
if newSectionXOffset > 0 //Switching to the right { x = sectionRight-6; playerCameraInit(); with instance_create(x, y, objSectionSwitcher) dir = "right"; } else if newSectionXOffset < 0 //Switching to the left { x = sectionLeft+6; playerCameraInit(); with instance_create(x, y, objSectionSwitcher) dir = "left"; } else if newSectionYOffset > 0 //Switching down { y = sectionBottom-6 + sprite_yoffset - (sprite_height/2); playerCameraInit(); with instance_create(x, y, objSectionSwitcher) dir = "down"; } else if newSectionYOffset < 0 //Switching up { y = sectionTop+6 + sprite_yoffset - (sprite_height/2); playerCameraInit(); with instance_create(x, y, objSectionSwitcher) dir = "up"; }
SCRIPT: Player's Camera
Code:
///playerCamera() //Handles the camera //Call it in objMegaman
//Follow the player view_xview[0] = round(x - view_wview[0]/2); view_yview[0] = round(y - view_hview[0]/2);
//Stop at section borders if view_xview[0] > sectionRight-view_wview[0] view_xview[0] = sectionRight-view_wview[0]; else if view_xview[0] < sectionLeft view_xview[0] = sectionLeft;
if view_yview[0] > sectionBottom-view_hview[0] view_yview[0] = sectionBottom-view_hview[0]; else if view_yview[0] < sectionTop view_yview[0] = sectionTop;
//Stop at room borders if view_xview[0] > room_width-view_wview[0] view_xview[0] = room_width-view_wview[0]; else if view_xview[0] < 0 view_xview[0] = 0;
if view_yview[0] > room_height-view_hview[0] view_yview[0] = room_height-view_hview[0]; else if view_yview[0] < 0 view_yview[0] = 0;
SCRIPT: Initiative of the Camera
Code:
///playerCameraInit() //Initialize the camera //For the meanings of newSectionXOffset/newSectionYOffset, see playerSwitchSections var dist;
if instance_exists(obj_raccoon) { //Basically copy the player's appearance, so that the object can return to its original behaviour when done switching sections with obj_raccoon visible = false; sprite_index = obj_raccoon.sprite_index; image_index = obj_raccoon.image_index; imgSpd = obj_raccoon.image_speed; image_speed = imgSpd; image_xscale = obj_raccoon.image_xscale;
//Variables that can me modified to make switching sections faster/slower screenSpeedHor = 4; //The speed that the screen will move at if travelling horizontally playerSpeedHor = 0.4; //The speed that Mega Man will move at if travelling horizontally screenSpeedVert = 4; //Same as above but if travelling vertically playerSpeedVert = 0.4; //Same as above but if travelling vertically
playerSpeedHorDoor = 0.7; //The speed that Mega Man will move at if travelling horizontally through a door
//Variables that cannot be modified climbTimer = 0; canProgressDoor = false; canStep = false;
Alarm 0
Code:
if door == true { image_speed = 0; alarm[1] = ceil(4 / 0.15) } else image_speed = imgSpd;
canStep = true;
Alarm 1
Code:
image_speed = imgSpd; canProgressDoor = true;
Step
Code:
//Moving the screen and player (or rather, both the player and the clone of the player. See create event for more information on that)
if canStep == true && playerSpeedHorDoor != 0 //When the door is closing, we should not move { if !(door == true && canProgressDoor == false) { //Right if dir == "right" { view_xview[0] += screenSpeedHor;
if door == false { x += playerSpeedHor; obj_raccoon.x += playerSpeedHor; } else { x += playerSpeedHorDoor; obj_raccoon.x += playerSpeedHorDoor; }
if view_xview[0] >= obj_raccoon.sectionLeft { view_xview[0] = obj_raccoon.sectionLeft;
if door == false { global.frozen = false; obj_raccoon.visible = true; instance_destroy(); with obj_raccoon playerDeactivateObjects(); } else { var bossdr; bossdr = instance_place(obj_raccoon.sectionLeft, y, objBossDoor); if bossdr >= 0 { bossdr.opening = false; bossdr.closing = true; image_speed = 0; playerSpeedHorDoor = 0; } else { global.frozen = false; obj_raccoon.visible = true; instance_destroy(); with obj_raccoon playerDeactivateObjects(); } } } }
//Left else if dir == "left" { view_xview[0] -= screenSpeedHor;
if door == false { x -= playerSpeedHor; obj_raccoon.x -= playerSpeedHor; } else { x -= playerSpeedHorDoor; obj_raccoon.x -= playerSpeedHorDoor; }
if view_xview[0] <= obj_raccoon.sectionRight-view_wview[0] { view_xview[0] = obj_raccoon.sectionRight-view_wview[0];
if door == false { global.frozen = false; obj_raccoon.visible = true; instance_destroy(); with obj_raccoon playerDeactivateObjects(); } else { var bossdr; bossdr = instance_place(obj_raccoon.sectionRight, y, objBossDoor); if bossdr >= 0 { bossdr.opening = false; bossdr.closing = true; image_speed = 0;
//Climbing animation if sprite_index == spr_rac_climb { climbTimer += 1; if climbTimer >= 8 { image_xscale = -image_xscale; with obj_raccoon image_xscale = -image_xscale; climbTimer = 0; } } } }
I did find a way to move the camera without pausing, but still may have a little struggle.
Here is some of the sources from WreckingPrograms. (Also changed some stuff to my character)
SCRIPT: SwitchBorders
[code]///playerSwitchSections()
//Moving from one section to the next, if possible
//newSectionXOffset/newSectionYOffset are used to get the right section borders in the new section
//Taking the normal X/Y coordinate would result in rounding errors in playerCameraInit(),
//which could either cause the game to freeze or the wrong section borders to be used
//Using 16 or 32 instead of 64 would also occassionally cause these problems, probably because of the +6/-6
if x > sectionRight-6 && place_meeting(x-hsp-6, y, objSectionArrowRight) //Right
&& !collision_rectangle(sectionRight+1, bbox_top, sectionRight+2, bbox_bottom, obj_wall, false, false)
{
instance_activate_object(objSectionBorderLeft);
instance_activate_object(objSectionBorderRight);
instance_activate_object(objSectionBorderTop);
instance_activate_object(objSectionBorderBottom);
instance_activate_object(objSectionArrowLeft);
instance_activate_object(objSectionArrowRight);
instance_activate_object(objSectionArrowUp);
instance_activate_object(objSectionArrowDown);
newSectionXOffset = 64;
if bbox_top <= view_yview[0]
newSectionYOffset = 96;
else if bbox_bottom >= view_yview[0]+view_hview[0]
newSectionYOffset = -96;
else
newSectionYOffset = 0;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up
}
else if x < sectionLeft+6 && place_meeting(x-hsp-6, y, objSectionArrowLeft) //Left
&& !collision_rectangle(sectionLeft-1, bbox_top, sectionLeft-2, bbox_bottom, obj_wall, false, false)
{
instance_activate_object(objSectionBorderLeft);
instance_activate_object(objSectionBorderRight);
instance_activate_object(objSectionBorderTop);
instance_activate_object(objSectionBorderBottom);
instance_activate_object(objSectionArrowLeft);
instance_activate_object(objSectionArrowRight);
instance_activate_object(objSectionArrowUp);
instance_activate_object(objSectionArrowDown);
newSectionXOffset = -64;
if bbox_top <= view_yview[0]
newSectionYOffset = 96;
else if bbox_bottom >= view_yview[0]+view_hview[0]
newSectionYOffset = -96;
else
newSectionYOffset = 0;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up
}
else if sprite_get_ycenter() > sectionBottom-6 && place_meeting(x, sprite_get_ycenter()-vsp+6, objSectionArrowDown) //Down
&& !collision_rectangle(bbox_left+4, sectionBottom+1, bbox_right-4, sectionBottom+2, obj_wall, false, false)
{
instance_activate_object(objSectionBorderLeft);
instance_activate_object(objSectionBorderRight);
instance_activate_object(objSectionBorderTop);
instance_activate_object(objSectionBorderBottom);
instance_activate_object(objSectionArrowLeft);
instance_activate_object(objSectionArrowRight);
instance_activate_object(objSectionArrowUp);
instance_activate_object(objSectionArrowDown);
newSectionXOffset = 0;
newSectionYOffset = 64;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up
}
else if sprite_get_ycenter() < sectionTop+6 && place_meeting(x, sprite_get_ycenter()-vsp-6, objSectionArrowUp) //Up
&& climbing == true && !collision_rectangle(bbox_left+4, sectionTop-1, bbox_right-4, sectionTop-2, obj_wall, false, false)
{
instance_activate_object(objSectionBorderLeft);
instance_activate_object(objSectionBorderRight);
instance_activate_object(objSectionBorderTop);
instance_activate_object(objSectionBorderBottom);
instance_activate_object(objSectionArrowLeft);
instance_activate_object(objSectionArrowRight);
instance_activate_object(objSectionArrowUp);
instance_activate_object(objSectionArrowDown);
newSectionXOffset = 0;
newSectionYOffset = -64;
alarm[7] = 1; //In GM Studio, the code in alarm 1 needs to be executed one frame later, else an error message will pop up
}[/code]
Player's Alarm 7
[code]//Initialize switching sections
if newSectionXOffset > 0 //Switching to the right
{
x = sectionRight-6;
playerCameraInit();
with instance_create(x, y, objSectionSwitcher) dir = "right";
}
else if newSectionXOffset < 0 //Switching to the left
{
x = sectionLeft+6;
playerCameraInit();
with instance_create(x, y, objSectionSwitcher) dir = "left";
}
else if newSectionYOffset > 0 //Switching down
{
y = sectionBottom-6 + sprite_yoffset - (sprite_height/2);
playerCameraInit();
with instance_create(x, y, objSectionSwitcher) dir = "down";
}
else if newSectionYOffset < 0 //Switching up
{
y = sectionTop+6 + sprite_yoffset - (sprite_height/2);
playerCameraInit();
with instance_create(x, y, objSectionSwitcher) dir = "up";
}[/code]
SCRIPT: Player's Camera
[code]///playerCamera()
//Handles the camera
//Call it in objMegaman
//Follow the player
view_xview[0] = round(x - view_wview[0]/2);
view_yview[0] = round(y - view_hview[0]/2);
//Stop at section borders
if view_xview[0] > sectionRight-view_wview[0]
view_xview[0] = sectionRight-view_wview[0];
else if view_xview[0] < sectionLeft
view_xview[0] = sectionLeft;
if view_yview[0] > sectionBottom-view_hview[0]
view_yview[0] = sectionBottom-view_hview[0];
else if view_yview[0] < sectionTop
view_yview[0] = sectionTop;
//Stop at room borders
if view_xview[0] > room_width-view_wview[0]
view_xview[0] = room_width-view_wview[0];
else if view_xview[0] < 0
view_xview[0] = 0;
if view_yview[0] > room_height-view_hview[0]
view_yview[0] = room_height-view_hview[0];
else if view_yview[0] < 0
view_yview[0] = 0;[/code]
SCRIPT: Initiative of the Camera
[code]///playerCameraInit()
//Initialize the camera
//For the meanings of newSectionXOffset/newSectionYOffset, see playerSwitchSections
var dist;
//Left
dist = 0;
while !place_meeting(floor((x+newSectionXOffset)/16)*16 - dist, y+newSectionYOffset, objSectionBorderLeft)
&& dist <= 16 * 200
{
dist += 16;
}
if dist >= 16 * 200
{
show_message("Got stuck on left");
}
sectionLeft = instance_place(floor((x+newSectionXOffset)/16)*16 - dist, y+newSectionYOffset, objSectionBorderLeft).x;
//Right
dist = 0;
while !place_meeting(ceil((x+newSectionXOffset)/16)*16 + dist, y+newSectionYOffset, objSectionBorderRight)
&& dist <= 16 * 200
{
dist += 16;
}
if dist >= 16 * 200
{
show_message("Got stuck on right");
}
sectionRight = instance_place(ceil((x+newSectionXOffset)/16)*16 + dist, y+newSectionYOffset, objSectionBorderRight).x + 16;
//Top
dist = 0;
while !place_meeting(x+newSectionXOffset, floor((y+newSectionYOffset)/16)*16 - dist, objSectionBorderTop)
&& dist <= 16 * 200
{
dist += 16;
}
if dist >= 16 * 200
{
show_message("Got stuck on top");
}
sectionTop = instance_place(x+newSectionXOffset, floor((y+newSectionYOffset)/16)*16 - dist, objSectionBorderTop).y;
//Bottom
dist = 0;
while !place_meeting(x+newSectionXOffset, ceil((y+newSectionYOffset)/16)*16 + dist, objSectionBorderBottom)
&& dist <= 16 * 200
{
dist += 16;
}
if dist >= 16 * 200
{
show_message("Got stuck on bottom");
}
sectionBottom = instance_place(x+newSectionXOffset, ceil((y+newSectionYOffset)/16)*16 + dist, objSectionBorderBottom).y + 16;[/code]
obj_SectionSwitcher
CREATE
[code]door = false;
global.frozen = true;
global.switchingSections = true;
with obj_enemybounce beenOutsideView = true;
deactivateUnimportantObjects();
if instance_exists(obj_raccoon)
{
//Basically copy the player's appearance, so that the object can return to its original behaviour when done switching sections
with obj_raccoon visible = false;
sprite_index = obj_raccoon.sprite_index;
image_index = obj_raccoon.image_index;
imgSpd = obj_raccoon.image_speed;
image_speed = imgSpd;
image_xscale = obj_raccoon.image_xscale;
alarm[8] = 1;
}
else
{
instance_destroy();
global.frozen = false;
}
//Variables that can me modified to make switching sections faster/slower
screenSpeedHor = 4; //The speed that the screen will move at if travelling horizontally
playerSpeedHor = 0.4; //The speed that Mega Man will move at if travelling horizontally
screenSpeedVert = 4; //Same as above but if travelling vertically
playerSpeedVert = 0.4; //Same as above but if travelling vertically
playerSpeedHorDoor = 0.7; //The speed that Mega Man will move at if travelling horizontally through a door
//Variables that cannot be modified
climbTimer = 0;
canProgressDoor = false;
canStep = false;[/code]
Alarm 0
[code]if door == true
{
image_speed = 0;
alarm[1] = ceil(4 / 0.15)
}
else
image_speed = imgSpd;
canStep = true;[/code]
Alarm 1
[code]image_speed = imgSpd;
canProgressDoor = true;[/code]
Step
[code]//Moving the screen and player (or rather, both the player and the clone of the player. See create event for more information on that)
if canStep == true && playerSpeedHorDoor != 0 //When the door is closing, we should not move
{
if !(door == true && canProgressDoor == false)
{
//Right
if dir == "right"
{
view_xview[0] += screenSpeedHor;
if door == false
{
x += playerSpeedHor;
obj_raccoon.x += playerSpeedHor;
}
else
{
x += playerSpeedHorDoor;
obj_raccoon.x += playerSpeedHorDoor;
}
if view_xview[0] >= obj_raccoon.sectionLeft
{
view_xview[0] = obj_raccoon.sectionLeft;
if door == false
{
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
else
{
var bossdr;
bossdr = instance_place(obj_raccoon.sectionLeft, y, objBossDoor);
if bossdr >= 0
{
bossdr.opening = false;
bossdr.closing = true;
image_speed = 0;
playerSpeedHorDoor = 0;
}
else
{
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
}
}
}
//Left
else if dir == "left"
{
view_xview[0] -= screenSpeedHor;
if door == false
{
x -= playerSpeedHor;
obj_raccoon.x -= playerSpeedHor;
}
else
{
x -= playerSpeedHorDoor;
obj_raccoon.x -= playerSpeedHorDoor;
}
if view_xview[0] <= obj_raccoon.sectionRight-view_wview[0]
{
view_xview[0] = obj_raccoon.sectionRight-view_wview[0];
if door == false
{
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
else
{
var bossdr;
bossdr = instance_place(obj_raccoon.sectionRight, y, objBossDoor);
if bossdr >= 0
{
bossdr.opening = false;
bossdr.closing = true;
image_speed = 0;
playerSpeedHorDoor = 0;
}
else
{
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
}
}
}
//Down
else if dir == "down"
{
view_yview[0] += screenSpeedVert;
y += playerSpeedVert;
obj_raccoon.y += playerSpeedVert;
if view_yview[0] >= obj_raccoon.sectionTop
{
view_yview[0] = obj_raccoon.sectionTop;
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
}
//Up
else if dir == "up"
{
obj_raccoon.y -= playerSpeedVert;
if view_yview[0] <= obj_raccoon.sectionBottom - view_hview[0]
{
view_yview[0] = obj_raccoon.sectionBottom - view_hview[0];
global.frozen = false;
obj_raccoon.visible = true;
instance_destroy();
with obj_raccoon playerDeactivateObjects();
}
}
//Climbing animation
if sprite_index == spr_rac_climb
{
climbTimer += 1;
if climbTimer >= 8
{
image_xscale = -image_xscale;
with obj_raccoon image_xscale = -image_xscale;
climbTimer = 0;
}
}
}
}
[/code]
I'm still reading the code, but what's the specific problem you're having?
Edit: Where are the objSectionBorders and objSectionArrow's placed? Edit2: Can you explain how the camera behaviour? and maybe show a gif or video of the result of the above code?
Is this what happens?
1) The camera is bounded by the section bounds and room bounds per step. (player's cam) 2) When the player overlaps the section arrow bound colliders (playerSwitchSections()), search for, at 16pxl increments, the new bounds. (init cam) 3) Set camera move speeds, duplicate player visually, and flag the game as frozen (objSwitcher) 4) Move the camera, player, clone , handle climbing animation, unfreezing the game, doors, clone destroy, (playerstep)
I'm still reading the code, but what's the specific problem you're having?
Edit: Where are the objSectionBorders and objSectionArrow's placed?
Edit2: Can you explain how the camera behaviour? and maybe show a gif or video of the result of the above code?
Is this what happens?
1) The camera is bounded by the section bounds and room bounds per step. (player's cam)
2) When the player overlaps the section arrow bound colliders (playerSwitchSections()), search for, at 16pxl increments, the new bounds. (init cam)
3) Set camera move speeds, duplicate player visually, and flag the game as frozen (objSwitcher)
4) Move the camera, player, clone , handle climbing animation, unfreezing the game, doors, clone destroy, (playerstep)
Actually, the real problem is..well, I'll let the "GIF" do the explaining on this point.
The current problem:
When I move anywhere from where the camera stop (when movable), it doesn't seem to stop at the next border being displayed below.
obj_SectionBorders are only placed around the area of the player according to the resolution of the game (160x144).
obj_SectionArrow are only placed within the border depending on what directionf rom where the player is going.
Actually, the real problem is..well, I'll let the "GIF" do the explaining on this point.
The current problem:
[img]http://i.imgur.com/V4OuwGK.gif[/img]
[size=85][pre]When I move anywhere from where the camera stop (when movable), it doesn't seem to stop at the next border being displayed below.[/pre][/size]
obj_SectionBorders are only placed around the area of the player according to the resolution of the game (160x144).
obj_SectionArrow are only placed within the border depending on what directionf rom where the player is going.
Hmm so the border size is always the same, right around the 160x144 screen? But when do they move? When are their positions updated? Maybe they haven't moved so the switch borders code is constantly triggering the alarm and rest of the stuff?
If the border size is always the same, you can get rid of the border objects. To calculate the section bounds of the player:
You should also separate the camera code from the player code so that they're less mixed. It'll make things easier to debug too. The camera bounding and following code is a good example of what you should continue doing. But the step code is a bad example.
Hmm so the border size is always the same, right around the 160x144 screen? But when do they move? When are their positions updated? Maybe they haven't moved so the switch borders code is constantly triggering the alarm and rest of the stuff?
If the border size is always the same, you can get rid of the border objects. To calculate the section bounds of the player:
playerLeftBound = floor( x / 160) * 160
playerTopBound = floor(y / 144) * 144
Then you compare that with the view positions. If they differ, then the player is in a different section so the camera should move.
if(playerLeftBound != view_xview[0]) newBoundLeft = playerLeftBound
if(playerTopBound != view_yview[0]) newBoundLeft = playerTopBound
You should also separate the camera code from the player code so that they're less mixed. It'll make things easier to debug too. The camera bounding and following code is a good example of what you should continue doing. But the step code is a bad example.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum