• 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 Blood drawn outside parameters

C

Chatterb0x

Guest
There are, essentially, 2 objects.
  • obj_blood
  • obj_blossoms
Upon creation, obj_blossoms initializes a surface that is its sprite width and height. It is drawn at object x and y.
An obj_blood instance is created when enemies are killed. In a collision event between obj_blood & obj_blossoms, the former's sprite is drawn to the surface.

I've put this code inside the obj_blood step event.
Code:
//If the blood instance is not colliding with the blossoms, destroy blood instance.
if!(place_meeting(x,y,obj_blossoms)){
instance_destroy();
}
And yet blood instances are still being drawn along outskirts of the blossom object. Please view this gif.
http://giphy.com/gifs/blind-samurai-3oriOb87y0cLqrRddu
You can see that the 'fringe' blood is not visible until I run a dissolve script. Now, some of that is because even if a single pixel touches the blossoms, its instance remains. But other instances appear no where close to the blossoms!

That brings me to 2 questions:
  • How can I make it so the blood instance must be on the blossom instance entirely, else it's destroyed?
  • Why do blood instances appear outside the blossom and how can I correct this?
I will post relevant code below.
 
C

Chatterb0x

Guest
obj_blood1
Code:
Information about object: obj_blood1
Sprite: spr_blood1
Solid: false
Visible: true
Depth: -3
Persistent: false
Parent: 
Children: 
Mask: 
No Physics Object
Create Event:
execute code:

///Setting blood movement variables
//Blood moves in direction between 0 and 180 degrees.
if(blood_pattern1){
blood_direction = random(180);
//Blood moves in direction between 0 and 90 degrees.
} else if(blood_pattern2 && player_dir == "right"){
blood_direction = random(90);
//Blood moves in direction between 90 and 180 degrees.
}else if(blood_pattern2 && player_dir == "left"){
blood_direction = random_range(90,180);
//Blood moves in direction between 0 and 360 degrees.
}else if(blood_pattern3){
blood_direction = random(360)
}

//Low range stays near first impact. High range creates quick, far blood streaks.
//Was previously 30,80.
blood_speed = random_range(30,60);
//I want the blood to start out very fast, but also slow down incredibly fast
//The overall splatter will last 2-8 frames -Zack Bell
//Setting variable storing hue, saturation, and value blend.
image_col = make_color_hsv(16777215,255,random_range(180,255));

Destroy Event:
execute code:

///Run dissolve script.
if(place_meeting(x,y,obj_blossoms)){
scr_sprite_dissolve(obj_control.petal_dir,
obj_control.dissolve_speed,
obj_control.chunk_size,
obj_control.shrink,
obj_control.shrink_amt,
obj_control.grav,
obj_control.fade,
obj_control.fade_amt,
obj_control.spin,
obj_control.life);
}


Alarm Event for alarm 0:
execute code:

///Destroy instance.
instance_destroy();

Step Event:
execute code:

//Slowing speed of instance.
if (blood_speed > 0){
blood_speed = choose(blood_speed, 0);   
}

//If the blood instance is not colliding with the blossoms, destroy blood instance.
if!(place_meeting(x,y,obj_blossoms)){
instance_destroy();
}

End Step Event:
execute code:

//Actual movement
//Feel free to use h/vspeed if you don't want to do this yourself. -Zack Bell
x += lengthdir_x(blood_speed,blood_direction);
y += lengthdir_y(blood_speed,blood_direction);


Collision Event with object obj_blossoms:
execute code:

///Drawing blood sprite on surface.
with other{
   draw_set_colour_write_enable(1,1,1,0);
    surface_set_target(surface);
    draw_sprite(spr_blood1,other.image_index,other.x-x,other.y-y);
    surface_reset_target();
    draw_set_colour_write_enable(1,1,1,1);
}

Keyboard Event for <Space> Key:
for other object: execute code:

///Call Alarm 0 to destroy instance.
var count = random_range(.5,4);
alarm[0] = room_speed * count;

Draw Event:
execute code:

///Don't draw.
 
C

Chatterb0x

Guest
obj_blossoms
Code:
Information about object: obj_blossoms
Sprite: spr_blossoms
Solid: false
Visible: true
Depth: -2
Persistent: false
Parent: 
Children: 
Mask: 
No Physics Object
Create Event:
execute code:

///Setting image_alpha
image_alpha = 0;
//Creating the surface
surface = surface_create(sprite_width, sprite_height);

Step Event:
execute code:

//If game has started, initiate surface.
if(game_start){
image_alpha += .05;
surface_set_target(surface);
draw_clear_alpha(0,0);
draw_sprite(spr_blossoms,image_index,0,0);
surface_reset_target();
}

Other Event: Game End:
execute code:

///Prevent memory leak.
surface_free(surface);



Draw Event:
execute code:

if(game_start){
//draw_surface(surface,x,y);
draw_surface(surface,x,y);
}
 
Top