Jump to content


Photo

Surface problem since update

gm:studio

  • Please log in to reply
9 replies to this topic

#1 leonHurley

leonHurley

    GMC Member

  • GMC Member
  • 74 posts
  • Version:GM:Studio

Posted 28 March 2016 - 05:01 PM

Hey all, 

 

I had a fog of war map system running in my game that was working perfectly but at some point it seemed to stop, possibly after the recent update. I'm pretty sure I didn't change anything. Here's the code:

 

Spoiler

 

The problem seems to be everything to do with mapcover_create - the draw_clear(c_black) bit works but nothing after that. Originally it used the black rectangle and blend mode to let you see all the objects that were 'found.' Now nothing after the draw_clear is working and I can't work out why. Like I said I'm almost certain I didn't change anything. 

 

Thanks 


Edited by leonHurley, 28 March 2016 - 05:02 PM.

  • 0

#2 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 25708 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:01 PM

It could be that the creation order has changed and this object is now being created BEFORE the block objects. Move all this code into an alarm and set it to run at 1 step after the create event (don't forget to init the vars in the create event as normal) and see if that helps.


  • 0

U1FVsm3.png

40799.png


#3 leonHurley

leonHurley

    GMC Member

  • GMC Member
  • 74 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:14 PM

It could be that the creation order has changed and this object is now being created BEFORE the block objects. Move all this code into an alarm and set it to run at 1 step after the create event (don't forget to init the vars in the create event as normal) and see if that helps.

 

It's definitely created after the blocks - they're made right upfront before anything else when the game begins. That code's also got to be in a Draw event. Pretty sure I'm missing something super obvious like Depth etc, but for the life of me I can't see what's wrong. The draw_clear, which acts on the surface directly works but the draw_rectangle and draw_sprite doesn't. Can't work out why there'd be a difference now when it worked before.

 

I saw something about drawing multiple surfaces having problems post update (possibly something to do resolutions) but I can't track more down. I've got four surfaces working a lighting system and one drawing the uncovered map view that are function correctly. It's just the last one that isn't playing ball. 


  • 0

#4 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 25708 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:17 PM

Do you set the draw alpha anywhere? Could you be setting it to zero somewhere and not setting it back to one again? As for surfaces and stuff, I don't think that would be the issue, as my own Aura lighting system is 100% surface based and can have many, many of them at a time, yet it works fine.


  • 0

U1FVsm3.png

40799.png


#5 leonHurley

leonHurley

    GMC Member

  • GMC Member
  • 74 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:23 PM

Do you set the draw alpha anywhere? Could you be setting it to zero somewhere and not setting it back to one again? As for surfaces and stuff, I don't think that would be the issue, as my own Aura lighting system is 100% surface based and can have many, many of them at a time, yet it works fine.

 

I can't see anything that would be affecting the alpha. It was working fine and I wasn't even touching the code for it when I noticed it had stopped. It's also stopped working in all my previous versions and back ups as well which makes me think it's not something I've done. I'd moved on about 10 or so versions from implementing it. Now they've all stopped working. 


  • 0

#6 flyingsaucerinvasion

flyingsaucerinvasion

    GMC Member

  • GMC Member
  • 720 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:48 PM

So the surface is still definately drawn to the screen, but its all black, is that what you're saying?

 

draw_set_blend_mode(bm_src_colour)

 

is bm_scr_colour a valid constant to use in draw_set_blend_mode?


  • 0

#7 leonHurley

leonHurley

    GMC Member

  • GMC Member
  • 74 posts
  • Version:GM:Studio

Posted 28 March 2016 - 06:57 PM

So the surface is still definately drawn to the screen, but its all black, is that what you're saying?

 

draw_set_blend_mode(bm_src_colour)

 

is bm_scr_colour a valid constant to use in draw_set_blend_mode?

 

It was when the map system was working, and it's still working in the lighting system. ATM the draw_clear will make it all black but nothing after that works. If I comment out that part then I just get a clear view of the map. It's supposed to (and was) showing a black square (the rectangle) with clear bits cut out by the sprites drawn over every block you've 'found.'


  • 0

#8 flyingsaucerinvasion

flyingsaucerinvasion

    GMC Member

  • GMC Member
  • 720 posts
  • Version:GM:Studio

Posted 28 March 2016 - 07:05 PM

so draw_set_blend_mode(bm_src_colour) is still working in other parts of the code then?

 

I'm curious about how this line could work

 

draw_rectangle_colour(7415,5435,7910,5915, c_black, c_black, c_black, c_black, 0);

 

because it seems to me that it is trying to draw a rectangle way outside the boundaries of the target surface

 

mapcover = surface_create(275, 275) // ← only 275 by 275


Edited by flyingsaucerinvasion, 28 March 2016 - 07:06 PM.

  • 0

#9 leonHurley

leonHurley

    GMC Member

  • GMC Member
  • 74 posts
  • Version:GM:Studio

Posted 28 March 2016 - 07:15 PM

so draw_set_blend_mode(bm_src_colour) is still working in other parts of the code then?

 

I'm curious about how this line could work

 

draw_rectangle_colour(7415,5435,7910,5915, c_black, c_black, c_black, c_black, 0);

 

because it seems to me that it is trying to draw a rectangle way outside the boundaries of the target surface

 

mapcover = surface_create(275, 275) // ← only 275 by 275

 

Yeah, the draw_rectangle_colour bit's bothering me too. I know what you mean about it being outside the boundaries but all the old versions that would have worked seem to have it, or a variation where's it's just a plain draw_rectangle with a draw_set_colour before it. 

 

All the objects that make up the map should be drawn onto a surface, then the black layer, then the sprites to cut out the bits you can see. I'm starting to thing that I did something outside of this code that broke it without realising. 


  • 0

#10 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 25708 posts
  • Version:GM:Studio

Posted 29 March 2016 - 08:15 AM

That draw rectangle code definitely looks waaaaaay off... and it's just occured to me that you don't offset the positions of what you want to draw to compensate for the surface set. So:
 
draw_sprite_ext(spr_map_reveal, 0, x - view_xview[0], y - view_yview[0],1,1,0,c_white,1)
 
If you are drawing to a surface, its coordinates start at 0 and are NOT room coords, so you need to offset everything by the view to compensate...

  • 0

U1FVsm3.png

40799.png






Also tagged with one or more of these keywords: gm:studio