Major surface problem...

darijs1

Member
basically my game is a top down 2d shooter.
first i had made a simple room (map) from tiles.
then later i added a day night cycle, which contains something related to drawing a surface (copy pased from tutorial).
And finally i decided to add some blood and gore...aaand...see the picture for yourself.
Room problem.JPG
As soon as i shoot my npc with a gun blood gets created, but along with it comes this sudden colorful change in the whole surface of the room.
im assuming it has something to do with more than one surfaces being drawn on start or something...

I have an obj_nightcycle with this in its draw event:
Code:
//if outside
if room = Room_1{
    surface_set_target(nightcyclesurf);
    draw_clear(c_black);
    
        //draw glow
        with(obj_lamppost){
            draw_set_blend_mode(bm_src_color);
            draw_sprite_ext(spr_light,0,x,y,glowsize,glowsize,0,c_white,1);
            draw_set_blend_mode(bm_normal)
        }
        
    surface_reset_target();
    draw_surface_ext(nightcyclesurf,0,0,1,1,0,c_white,alpha);
}
And This in its Create Event:
Code:
//set variables
alpha = -3;
daylength = 20;
nightlength = 20;
alarm[0] = room_speed*daylength;
//set surface
nightcyclesurf = surface_create(room_width, room_height);
And i also have an Obj_bloodcontroller with this in create event:
Code:
//blood system
partblood_sys = part_system_create();

//blood particle
partblood = part_type_create();
part_type_shape(partblood,pt_shape_square);
part_type_size(partblood,0.1,0.05,-0.01,0);
part_type_color1(partblood,255);
part_type_alpha1(partblood,1);
part_type_speed(partblood,1,3,0,0);
part_type_direction(partblood,0,359,0,0);
part_type_gravity(partblood,0.3,270);
part_type_blend(partblood,0);
part_type_life(partblood,30,700);

//create emitter
partblood_emit = part_emitter_create(partblood_sys);

//create surface
surfblood = surface_create(room_width, room_height);
//surface fix
w = window_get_width();
h = window_get_height();
And this in its draw event:
Code:
if !surface_exists(surfblood){
    surfblood = surface_create(room_width,room_height);
}else { 
    draw_surface(surfblood,0,0);
}
Please help if you can, ive been having this problem since the blood update, and i havent been able to fix it.
 

darijs1

Member
1st of all, at what place are you drawing the particles to your surface?
If you want to do this, you might want to look into: https://docs.yoyogames.com/source/dadiospice/002_reference/particles/particle systems/part_system_drawit.html

Also, do you immediately get the colored screen, or does it expand/fade in? And does it stay static or is there some grain?
The blood particles get drawn to the x and y of the obj_enemy that gets hit by an obj_bullet, fired from a gun that the obj_player holds.

The colors are kinda dificult to explain, mostly they appear on startup, they dont move or anything, just still pixels of random colors standing there. I notice that when i shoot the obj_enemy, the surface sort of resets, but with the colors still there.
I might have to record a video.
 

Tthecreator

Your Creator!
@darijs1 The weird part is that I don't see any code that draws anything on the surfblood surface. If you temporarily remove the line
draw_surface(surfblood,0,0); then does the problem still occur?
 

darijs1

Member
@darijs1 The weird part is that I don't see any code that draws anything on the surfblood surface. If you temporarily remove the line
draw_surface(surfblood,0,0); then does the problem still occur?
Woah, fast reply.
Im not at home right now, but im gonna look into that as soon as i get there.
 

darijs1

Member
@darijs1 The weird part is that I don't see any code that draws anything on the surfblood surface. If you temporarily remove the line
draw_surface(surfblood,0,0); then does the problem still occur?
i removed the line:
-----------
(from obj_bloodcontroller, DRAW event)

if !surface_exists(surfblood){
surfblood = surface_create(room_width,room_height);
}else {
draw_surface(surfblood,0,0);
}
------------

and it removes the colors and the blood ground splat along with it. thats not what i was looking for.
 

Tthecreator

Your Creator!
i believe sending a .gmz would make things easier and clear things up. how should i send it?
Just google drive it or anything similar that will work. Link sharing is the easiest option. You can either send it in here, or send a personal message if you rather do that.
 
Top