#Animation Bugs

8 messages · Page 1 of 1 (latest)

solid badger
#

Create event:

view_enabled = true;
view_visible[0] = true;
camera = view_camera[0];

follow = noone;
cameraSmoothSpeed = 15;

//smooth camera stuff
cameraWidth = GAME_W;
cameraHeight = GAME_H;
surface_resize(application_surface, cameraWidth + 1, cameraHeight + 1);
application_surface_draw_enable(false);

viewWidthHalf = camera_get_view_width(camera) * 0.5;
viewHeightHalf = camera_get_view_height(camera) * 0.5;

xTo = xstart;
yTo = ystart;

//shake effect
shakeLength = 0;
shakeMagnitude = 0;
shakeRemain = 0;

//camera states
cameraState = -1;

Step event:

if (follow != noone)
{
    xTo = follow.x;    
    yTo = follow.y;
}


//Update Object Position
x += (xTo - x) / cameraSmoothSpeed;
y += (yTo - y) / cameraSmoothSpeed;

//Keep camera center inside room
x = clamp(x, viewWidthHalf, room_width-viewWidthHalf);
y = clamp(y, viewHeightHalf, room_height-viewHeightHalf);

//Screenshake
x += random_range(-shakeRemain,shakeRemain);
y += random_range(-shakeRemain,shakeRemain);

shakeRemain = max(0, shakeRemain - ((1/shakeLength) * shakeMagnitude));

camera_set_view_pos(camera, floor(x - viewWidthHalf), floor(y - viewHeightHalf));

Post draw event:

gpu_set_blendenable(false);
var _scale = window_get_width() / cameraWidth;

draw_surface_ext(
    application_surface,
    0 - (frac(x) * _scale),
    0 - (frac(y) * _scale),
    _scale,
    _scale,
    0,
    c_white,
    1.0
);
    
gpu_set_blendenable(true);

Room start:

view_enabled = true;
view_visible[0] = true;
camera = view_camera[0];

if (instance_exists(oPlayer))
{
    follow = oPlayer;
}
else
{
    follow = noone;
}

x = follow.x;
y = follow.y;

// reset the view values so they don't default to half the room size
viewWidthHalf = camera_get_view_width(camera) * 0.5;
viewHeightHalf = camera_get_view_height(camera) * 0.5;
autumn thunder
#

You know what I think might be going on? I think your background isn't fully opaque

#

It's not just the player, you can see basically everything is doing the smearing thing as the camera moves around

#

Almost like the data from previous frames is not being fully cleared at the start of each frame

#

I would say check your background layer, make sure it actually has a full 255 alpha everywhere

#

And also maybe try clearing the application surface at the start of the frame to make sure that there's nothing from previous frames on it

solid badger
#

Adding this to the pre draw worked to get rid of the smearing effect.

surface_set_target(application_surface);
draw_clear_alpha(c_black, 0);
surface_reset_target();
#

However, there still exists that stretch of 1 pixel on one side of the character, which may be related the fact that the surface is 1 pixel larger than the application_surface. I did that because it was suggested to make a smooth camera with fractional movements. I just removed the " + 1" to increase the surface size and that got rid of it without seeming to affect the camera smoothness