Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Iolo

#1
Thank you Snarky, I went with the one sprite per tile approach and I have to say it works perfectly just like you said! I also understand what you meant by 'destructive update'. Once you Draw on the Background it stays forever that way, but I need to Clear it everytime I draw the map anyway so I won't have to restore the background image.

The second part of my test includes other elements like objects and they stack perfectly with transparency and alpha which is great!
Here is the code I'm using, it seems to work fine.

Code: ags

  DynamicSprite *MapViewport = DynamicSprite.Create(Num_Tiles_X * Tiles_Width, Num_Tiles_Y * Tiles_Height,  true);

  DrawingSurface *MapSurface = MapViewport.GetDrawingSurface();
  MapSurface.Clear(COLOR_TRANSPARENT);
  for(int i=0; i<Num_Tiles_Y; i++)
  {
    for(int j=0; j<Num_Tiles_X; j++)
    {
      MapSurface.DrawImage(j * Tiles_Width, i * Tiles_Height, Tiles_Slot + Tiles_Floor[(i * Num_Tiles_X) + j].Index, 0);
    }
  }
  MapSurface.Release();

  DrawingSurface *Background = Room.GetDrawingSurfaceForBackground();
  Background.Clear(COLOR_TRANSPARENT);   //GUIs cover the extra space outside viewport 
  Background.DrawImage(0, 0, MapViewport.Graphic);
  Background.Release();
  MapViewport.Delete();

*edit: I added the delete command for the dynamic sprite (the manual mentions it).

Very helpful and clear answer, thanks again!
#2
Hello everyone, I'm quite new to AGS scripting and would like to get some insight on how to accomplish this.

The map's data and tileset are loaded in memory and I'd like to draw the map on a picture/surface before displaying it, this would allow me to scroll the scene.

My question is how can I achieve this? By drawing regions of a tileset Graphic on a DrawingSurface? All tiles have transparency and some of them have alpha. I guess i'm looking for a Blitting function that supports drawing to a picture, transprency and alpha, but AGS has its own set of rendering functions and I'm a little confused.

Any help is appreciated!

SMF spam blocked by CleanTalk