• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Surfaces Help!! [SOLVED]

G

Gillen82

Guest
I'm back again looking your kind help...

I am playing about with a surface which will create blood when enemies are shot, which (sort of) works.

The problem I am having is that the "blood" disappears while still in the view. Attached images will show what I mean.

Here is the code that I have used

CREATE SURFACE
Create Event
Code:
//Create surface
surf_blood = surface_create(room_width, room_height);
Draw Event
Code:
///Draw the Surface
if(!surface_exists( surf_blood ) )
{
    surf_blood = surface_create(room_width, room_height)
}
else
{
    draw_surface(surf_blood, 0, 0);
}

OBJECT BLOOD
Create Event
Code:
///Init Blood
direction = random(359);
speed     = random_range(10,30);
friction  = random_range(speed/20, speed/40);
shrink    = random_range(0.2, 0.7);
Step Event
Code:
//Shrink Blood
image_xscale -= shrink;
image_yscale = image_xscale;

//Fade Overtime
if(speed > 0)
{
    image_alpha -= 0.1;
}

//Draw to Surface
if( instance_exists( part_blood ) )
{
    surface_set_target( part_blood.surf_blood );
    draw_sprite_ext( spr_blood, 0, x, y, image_xscale, image_yscale, 0, c_white, image_alpha );
    surface_reset_target();
}

//Destroy the object
if( image_xscale <= 0 )
{
    instance_destroy();
}

SCRIPT FOR BLOOD
Code:
//Create blood on floor
spawn = random_range(10,30);

for( i = 0; i < spawn; i++ )
{
    instance_create( x+random_range(-16,16), y+random_range(-16,16), obj_blood );
}

As usual, I appreciate giving up your precious time, both to read the post and to respond. If any other info is needed, I will be happy to post.

2.png 1.png
 
G

Gillen82

Guest
Still not working. The surface only seems to be covering a small portion of the room, although I am telling it to be full width and height (I think). There must be something simple that I'm overlooking, but it's not as easy when you're not used to surfaces.

I don't want to get annoyed and move away from it, as I really want to understand what they are and how they can be utilized.

If anyone else has any suggestions they would be greatly appreciated!!

p.s Is there a limit to what size a surface can be?
 
F

Felipe Rybakovas

Guest
You're not drawing the blood into the view


//Draw to Surface
if( instance_exists( part_blood ) )
{
surface_set_target( part_blood.surf_blood );
draw_sprite_ext( spr_blood, 0, x-view_xview[0], y-view_yview[0], image_xscale, image_yscale, 0, c_white, image_alpha );
surface_reset_target();
}

EDIT: also, i think would be better if you set this surface as a global variable.
 
G

Gillen82

Guest
It's not really big. 3840 * 2160. I think the problem has something to do with the views and not the actual code. The blood only seems to draw within the view height & width starting at the room 0,0, so is only working in the top-left corner of the room. I have view[0] following the player, but the surface doesn't seem to move, or cover the entire room :/
 
G

Gillen82

Guest
Sorry guys. I have overlooked a piece of code within my character. I am deactivating an area just larger than the view width & height which was resulting in the surface being deactivated. I honestly would have been stuck on this if @Felipe Rybakovas had not made me look at how I was using the views, so once again, all of your help is appreciated.
 
F

Felipe Rybakovas

Guest
BTW.... You should not create surface larger than your view. This will REALLY mess your performance.

Create a surface that have a little bit more than your current view and draw the surface at 0,0 of the view.
 
Top