Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Negative sprites in Gamemaker (round 2)  (Read 3847 times)

0 Members and 1 Guest are viewing this topic.
Negative sprites in Gamemaker (round 2)
« on: July 26, 2009, 05:54:39 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
I'm sure some of you do this blindfolded. If you could also explain the answers then that would be most appreciated.

In alttp enemies turn negative when hit. That what I want to recreate. The enemy's sprite need to turn negative through it's own draw event. White turns to black etc. But the transparent pieces should stay transparent.

The answer I got in a previous topic turned the the images grayish. Including the parts that were previously transparent.
Logged
Re: Negative sprites in Gamemaker (round 2)
« Reply #1 on: July 26, 2009, 07:27:11 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
Why don't you just switch to animation where the colors flash between inverted and normal colors?
Logged



i love big weenies and i cannot lie
Re: Negative sprites in Gamemaker (round 2)
« Reply #2 on: July 26, 2009, 08:23:50 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Posts: 728
Hrmmm, most likely the reason why your getting such results is that changing the blend mode does not take the alpha into consideration. (Thus the border) Plus it's taking into consideration the colors beneath the sprite as well. (Weird grayish color) Your best bet is making a surface and drawing to that.

An example:

Object: obj_invert_colors_test;

Create Event:
Code: [Select]
Surface = surface_create(width, height);
Draw Event:
Code: [Select]
surface_set_target(Surface);

draw_clear_alpha(c_white, 0);
draw_set_color(c_white);

draw_set_blend_mode_ext(bm_inv_dest_color, bm_inv_src_color);
draw_sprite(sprite, image_index, 0, 0);
draw_set_blend_mode(bm_normal);

surface_reset_target();
draw_surface(Surface, x, y);

Destroy Event:
Code: [Select]
surface_free(Surface);
Logged
  • Pyxosoft
Re: Negative sprites in Gamemaker (round 2)
« Reply #3 on: July 27, 2009, 06:14:19 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
Thanks for the post. I was looking into surfaceses (?) so I'm glad I was on the right track.

However, I still can't get it to work. Even worse, I have no idea what I'm doing wrong. This is the same code structure I use for my pause function (excl the negative bit) and that works fine.

Here is the code I have currently put in the draw event of an enemy's sprite:
Code: [Select]
if (control_id.recovery_time > 0)
{
    // draw negative sprite
    surface_Enemy_Sprite = surface_create(sprite_width, sprite_height);
   
    surface_set_target(surface_Enemy_Sprite);

    draw_clear_alpha(c_white, 0);
    draw_set_color(c_white);
   
    draw_set_blend_mode_ext(bm_inv_dest_color, bm_inv_src_color);
    draw_sprite(sprite_index, image_index, 0, 0);
    draw_set_blend_mode(bm_normal);

    surface_reset_target();
    draw_surface(surface_Enemy_Sprite, x, y);
   
    surface_free(surface_Enemy_Sprite);
}
else
{
    // draw sprite regularly
    draw_sprite(sprite_index, image_single, x, y);
};

The result is that (almost?) all the enemy sprites turn invisible as well as the character sprites (excl shadow) and the hud images. That makes absolutely no sense to me. Anybody see what's wrong in the code that might have caused this?
Logged
Re: Negative sprites in Gamemaker (round 2)
« Reply #4 on: July 27, 2009, 08:07:50 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
Never mind. The code is not the problem. Appearantly GM starts to experience errors when you try to switch targets within a draw event. So I'm now using the End Step event to set the surface and the draw event to use and destroy it.

Again. Thanks for the help.
Logged
Re: Negative sprites in Gamemaker (round 2)
« Reply #5 on: July 27, 2009, 10:58:02 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Posts: 728
Ah yes, changing the target in the draw event is a no no. Forgot about that. Weirdly It worked for my little test, but I didn't draw anything else.
Logged
  • Pyxosoft

Nambiyo

Re: Negative sprites in Gamemaker (round 2)
« Reply #6 on: July 31, 2009, 07:55:12 am »
Ah yes, changing the target in the draw event is a no no. Forgot about that. Weirdly It worked for my little test, but I didn't draw anything else.

why didn't u? u shud
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.08 seconds with 48 queries.

anything