Plugin Help..

Started by Dualnames, Thu 28/01/2010 21:18:53

Previous topic - Next topic

Dualnames

It would be much to ask people to do the whole conversion for me, I've cut down my begging for help. First of I am an imbecile when it comes to plugins. I'm sure they are easily done on AGS but frankly I lack the patience. So can someone code something for me? I want to be able to draw the contents of a dynamic surface into the screen in front of everything. The exact same way snow/rain plugins draws it. So if one can use a function that I can repeatedly execute to draw contents of a drawing surface on screen I'd really be the most content man ever. I did some attempts, but nothing worth.

So something like:
Code: ags

GetDrawingSurfaceAndDrawOnScreen(DrawingSurface*surfme);


Perhaps some code on how to, or the resource files will be handy..I don't know if it matters but the game resolution is 800x600 32bit.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Unless you expressly need to merge two or more alpha channels together then there's no technical reason you can't do this in AGS. You can use an Overlay or a GUI to display the contents of the DrawingSurface in front of everything else.

I've used this same method in both my Flashlight and SparkleMotion modules.

The basic idea would be something like this:

Code: ags
enum DrawingMode {
  eDrawOverlay,
  eDrawGUI
};

DrawingMode drawingMode = eDrawOverlay;
DynamicSprite *drawingSprite;
Overlay *drawingOverlay;
GUI *drawingGUI;

function game_start() {
  drawingSprite = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);
  // if you want to use a GUI
  drawingMode = eDrawGUI;
  drawingGUI = THE_GUI_TO_USE;
  drawingGUI.BackgroundGraphic = drawingSprite.Graphic;
}

function UpdateDrawing() {
  DrawingSurface *surface = drawingSprite.GetDrawingSurface();
  // draw what you want here
  surface.Release();
  if (drawingMode == eDrawOverlay) {
    if ((drawingOverlay != null) && (drawingOverlay.Valid)) drawingOverlay.Remove();
    drawingOverlay = Overlay.CreateGraphical(0, 0, drawingSprite.Graphic, true);
  }
}

Dualnames

Quote from: monkey_05_06 on Thu 28/01/2010 22:48:35
Unless you expressly need to merge two or more alpha channels together then there's no technical reason you can't do this in AGS. You can use an Overlay or a GUI to display the contents of the DrawingSurface in front of everything else.

I've used this same method in both my Flashlight and SparkleMotion modules.

The basic idea would be something like this:

Code: ags
enum DrawingMode {
  eDrawOverlay,
  eDrawGUI
};

DrawingMode drawingMode = eDrawOverlay;
DynamicSprite *drawingSprite;
Overlay *drawingOverlay;
GUI *drawingGUI;

function game_start() {
  drawingSprite = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);
  // if you want to use a GUI
  drawingMode = eDrawGUI;
  drawingGUI = THE_GUI_TO_USE;
  drawingGUI.BackgroundGraphic = drawingSprite.Graphic;
}

function UpdateDrawing() {
  DrawingSurface *surface = drawingSprite.GetDrawingSurface();
  // draw what you want here
  surface.Release();
  if (drawingMode == eDrawOverlay) {
    if ((drawingOverlay != null) && (drawingOverlay.Valid)) drawingOverlay.Remove();
    drawingOverlay = Overlay.CreateGraphical(0, 0, drawingSprite.Graphic, true);
  }
}



Greatness, but I forgot to say that I need the contents of the drawing surface to maintain their transparency. Therefore drawing two things on the surface one with 50 trans and one with 25, should transfer with that transparency values in front of everything on the screen.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Calin Leafshade

#3
Actually the rain plugin cant add alpha channels either. If you use an alpha channel sprite on the rain module the sprites are just white blocks when it flattens the image.

Technically the rain plugin is obsolete now since everything it does could technically be done on guis or overlays without the cross platform wrecking dlls.

monkey0506

Quote from: Calin Leafshade on Sat 30/01/2010 00:01:04Technically the rain module is obsolete now since everything it does could technically be done on guis or overlays without the cross platform wrecking dlls.

The word is plugin Calin, not module. :P

And Dual, if you draw something partially transparent onto a transparent (magic pink/COLOR_TRANSPARENT) background you're going to end up with a pink-tinted sprite.

You can avoid this by drawing onto a screenshot or by redrawing the screen yourself. The former will capture the cursor and the latter won't allow you to use walkbehind areas or non-region tinting. Neither is optimal really, but it can be done.

Otherwise you can abandon the use of DrawingSurfaces altogether and use some delicious cross-platform-wrecking DLLs. ::)

Calin Leafshade

I dont know what you're talking about... i said plugin.  ::)

Dualnames

Monkey, have I really said, that I know that the solution is via the plugin I can't make, and I already tried about everything without reaching to my goal?

If, not mark this message.

I want to draw something from a drawing surface, in which I can draw the items I want as I want them to be, but take the graphic of the surface it and place it on the same place where the rain/snow plugin places its rain and snow. That is in front of the player and or objects.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

I understand what you want to do and it can be accomplished without a plugin. That's what I was saying.

There are complications and drawbacks to doing it via the script like that, but it is possible.

Dualnames

#8
Of course it is. I said I tried it out everything. But I'm not happy with any of the drawbacks, that's why I've resulted to this topic. I just think I might be acting like a dick. But I want my surface to be drawn in front of characters or objects and have transparency. And to be drawn on the background which is always scrolling, therefore overlay will look bad.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk