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: Gamemaker question: drawing only OUTSIDE of a shape  (Read 1624 times)

0 Members and 1 Guest are viewing this topic.
Gamemaker question: drawing only OUTSIDE of a sh...
« on: January 21, 2010, 02:34:00 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
So the question is as follows:
I want to draw the entire visible screen black (no foreground, just object based) except for a (ecliptic) shape inside. How can this be achieved in an efficient manner?

It's the effect you get when you walk into (or out of) a dungeon in alttp. I've already build it with sprites way back when, but I'm trying to make it more efficient. It's also out of interest because programming the visuals for the lantern later on will also benefit from an efficient solution.

I'm guessing the best bet would be to create a surface outside of the draw event (sized after the screen). Clear it, turn it fully black and finally turn the inner area transparent again. I'm not sure if this is possible or how to do it. Let alone if this is the only/best solution.

Who can help?
Logged
Re: Gamemaker question: drawing only OUTSIDE of ...
« Reply #1 on: January 21, 2010, 02:39:08 pm »
  • *
  • Reputation: +12/-2
  • Offline Offline
  • Gender: Male
  • Posts: 4849
Download please : http://www.zfgc.com/forum/index.php?action=dlattach;topic=32470.0;attach=4850

You should be able to find it easily enough.
I made it when I was making a Resident Evil Engine, but I don't really need credit.

or if you are lazy
Code: [Select]
{

var x1,y1,x2,y2,ww;
ww = 360;
x1 = (Operative.x + 9) - ww/2;
x2 = (Operative.x + 9) + ww/2;
y1 = (Operative.y) - ww/2;
y2 = (Operative.y) + ww/2;

draw_set_color(c_black);
draw_rectangle(0,0,x1,room_height,false);
draw_rectangle(x2,0,room_width,room_height,false);
draw_rectangle(0,0,room_width,y1,false);
draw_rectangle(0,y2,room_width,room_height,false);

draw_set_blend_mode(bm_subtract);
draw_background_stretched(light,x1,y1,ww,ww);

draw_set_blend_mode(bm_normal);


the word "light" near the end is a background fyi.  That's what you want the light source to be shaped like using a white and black gradient circle.
« Last Edit: January 21, 2010, 02:42:37 pm by Theforeshadower »
Logged
  • Super Fan Gamers!
Re: Gamemaker question: drawing only OUTSIDE of ...
« Reply #2 on: January 21, 2010, 02:47:10 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
Subtract huh? Okay, the example is clear. I should be able to get it now. Thanks.
Logged
Re: Gamemaker question: drawing only OUTSIDE of ...
« Reply #3 on: January 21, 2010, 02:59:32 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3374
Would that code work properly? I'd draw it to a surface first, not directly to the main game screen so it doesn't mess with anything else. I'm particularly wondering what that subtract would do to everything else.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.
Re: Gamemaker question: drawing only OUTSIDE of ...
« Reply #4 on: January 21, 2010, 03:14:28 pm »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
It's okay. I got what I need from the example.
Logged
Re: Gamemaker question: drawing only OUTSIDE of ...
« Reply #5 on: January 21, 2010, 10:03:40 pm »
  • *
  • Reputation: +12/-2
  • Offline Offline
  • Gender: Male
  • Posts: 4849
Would that code work properly? I'd draw it to a surface first, not directly to the main game screen so it doesn't mess with anything else. I'm particularly wondering what that subtract would do to everything else.

It does nothing bad.  It just covers up everything that is behind that layer and subtracts the background image from the black covering up the screen.
Logged
  • Super Fan Gamers!
Pages: [1]   Go Up

 


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



Page created in 0.117 seconds with 46 queries.

anything