#Surface don't draw everything when changing rooms

36 messages · Page 1 of 1 (latest)

dawn whale
#

doesnt look like youre accounting for offset on the surface

#

unless youre making a surface the size of the whole room

#

your view size is 2048x2048?

#

why not just make it the size of the view?

#

nah

#

just make it the size of the view, for one

#

second of all, youre drawing the surface to the camera's position (top-left of view) but it does not appear that you're accounting for the offset between the position of obj_lit or charMain in the room and the camera

#

your camera moves around right?

#
var vx = camera_get_view_x(0)
var vy= camera_get_view_y(0)

//code here

draw_surface(surface, vx, vy);```
#

here you are drawing the surface to the view position

#

but the coordinates on the surface are not the same as the room or the view

#

the top left of the surface is always 0,0 no matter where the surface is drawn in the room. if your camera is at 420,69 in the room then the top left of the surface is still 0,0

#

the surface is following the camera

#

you draw it to vx, vy

#

which is the camera position

#

but your draw_sprite calls on the surface use room positions not camera positions

#

lets see your code now

#

u can paste it here, hastebin's color scheme makes it hard to read anything

#

alright i see part of the problem

#

0 is not a valid camera

#

view_camera[0] is

#
var vx = camera_get_view_x(0)
var vy = camera_get_view_y(0)```should be```gml
var vx = camera_get_view_x(view_camera[0]);
var vy = camera_get_view_y(view_camera[0]);```
#

second thing

#

see this line:

#
draw_sprite_ext(vfx_light, 0, chrMain.x, chrMain.y, 20, 20, 0, c_white, 1)```
#

chrMain.x and chrMain.y are the character's position in the room right?

#

well their position in the room is not the same as their position on the surface

#

you need to get the offset, which is the position minus camera position. so charMain.x - vx and charMain.y - vy

#

this goes the same for the light

#

is this a persistent object?

#

might could, depending on the transition

#

but i would just not make this persistent, i see no reason to have it be persistent

#

why

#

well i do think you'd be better off separating these things, especially because it makes it harder to debug things

#

however, what you should then do is make sure you're freeing the surface between rooms

#

and making sure the object is not re-making itself