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 - lafouine88

#21
Thta was it, thanks a lot :)
#22
Sorry I forgot the code :

Code: ags

function ChangeNormalView(int base)
{
  int MySpriteNo=0;
  int currentloop=0; 
  int currentframe;


  while (currentloop <= 7)//invariable
  {
    currentframe = 0;
    while (currentframe <= 8)
    {
      MySprite2[MySpriteNo] = DynamicSprite.Create(256, 256);
      DrawingSurface *MySurface = MySprite2[MySpriteNo].GetDrawingSurface();
      
      ViewFrame *LegViewFrame = Game.GetViewFrame(base, currentloop, currentframe);
      MySurface.DrawImage(0, 0, LegViewFrame.Graphic);
      
      ViewFrame *ArmorViewFrame = Game.GetViewFrame(base+1, currentloop, currentframe);
      MySurface.DrawImage(0, 0, ArmorViewFrame.Graphic);
      
      ViewFrame *HDViewFrame = Game.GetViewFrame(base+2, currentloop, currentframe);
      MySurface.DrawImage(0, 0, HDViewFrame.Graphic);


      MySurface.Release();
      

      ViewFrame *MyViewFrame = Game.GetViewFrame(52, currentloop, currentframe);
      MyViewFrame.Graphic = MySprite2[MySpriteNo].Graphic;
      MySpriteNo ++;
      currentframe ++;
    }
    currentloop ++;
  }
player.ChangeView(52);
}

#23
Hi guys!

I'm using dynamic sprites for my rpg to be able to create differents pieces of stuff.
Thus, I have for each piece of equipment one view for legs, one for body and one for head. I then combine then( code below, but I guess not in cause here).

Problem is, when I combine the 3 views (that look fine on their own) it creates a pink edging around the character and on the shadow.
I found this old thread that might explain the problem, but not really how to solve it :s
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/solved-quick-import-sprites-transparency-issue/msg636525850/#msg636525850

Here are a few pictures :

When I use only legs view for my normal view



When the leg view is combined with body and head-->pink trouble


Thanks in advance :)
#24
Quote from: Crimson Wizard on Mon 02/09/2024 11:49:44If the operation is the same, but takes longer than in the previous version unexpectedly, then that's something to investigate. I could not tell whether this is the case from what you've said, if it is, then please clarify that?
Well in the previous versions, adding regions or walkable areas didn't slow down anything (compared to just changing the background overlay), it's really when I added the walkbehind area that I noticed a change...

Quote from: Crimson Wizard on Mon 02/09/2024 11:49:44Speaking of walk-behinds in particular, if you want to speed things up then you may just create game objects or room overlays with background portions on them instead. Then you won't need to use the walk-behind mask. They will still take time to load up, but engine will not have to do copy-pasting on a surface, and then cutting things out again.
...But I think using overlays is much faster, not to mention it saves the drawing time which can be quite long, so yeah I'll definitely go for that :)

Thanks...again... "^^
#25
Works great. Many, many thanks  :grin:  :grin:  :grin:

EDIT : One small thing though, the loading time (during the transition and new setting of the overlay,and drawing surfaces) is a bit longer since I added the new code for drawing surface. I downloaded the executable file in the "install" folder, but maybe I missed something ? Or is it just that walk behind are longer to settle?
#26
Thanks for the reply. My project is planned for christmas 2025 so maybe by then the engine wille be patched and I can include the walk behinds.

Thanks everybody for your help, I will edit the post soon to sum up the elements we gathered :)

See you
#27
Hello again

So after a few tries, I realized there was a 'RemoveWalkableArea()" lost somewhere in my messy code. I think it's @eri0o who told me in another post that the hard part was to keep your code and functions clear... "^^
When I tried earlier this week it was on another computer with an older code(and no removewalkablearea) that's why it worked there and not on my home computer. After all coordinates were not a problem, sorry for the disturbance @Crimson Wizard -_-

One last thing, since i'm now working on walkbehind, how do you change the baselines ? I went for " SetWalkBehindBase(1, X)" since I figured the drawing surface applied to walkable area1 because of the blue color but it doesn't seem to be the case.
#28
Hi, I was on the road this last days so I couldn't try earlier, as eager as I was^^

So using the debug mode definitely helped, it semms there was a problem with the coordinates. I don't know why but when I set it to map coordinates like 2000,1400 it didn't show anywhere, but when I corrected to player.x-150; player.y-70 (which led to the same values) it worked.
So I stil have a bit of set up to work on, but the core of the problem really is solved. Thanks a million to everybody, especially to @Crimson Wizard for his patience.

As soon as I have a clean code I'll edit my post with the correct way to make this :) :)
#29
Quote from: Crimson Wizard on Fri 23/08/2024 14:20:29This is not a plugin!..
Can you tell what do you do, step by step, and what exactly happens as a result?

So:
-I dl your .exe (definitely not a plugin :p) and ,after renaming the initial one, extracted it to my adventuregalmestudio 3.6.1 root folder.
-I imported the bmp file, and ticked transaprency top left pixel. Nothing else.
-I removed the walkable areas of the room
-at room load set this code :
Code: ags
   

DrawingSurface *ds = GetDrawingSurfaceForWalkableArea();
 ds.Clear(0);
 ds.DrawImage(2005, 1420, 5760); ///This is with your file,since it's just 320*200 I could not put it at 0,0 or it would be too far from my character so I set it manually so the blue area is below the character.
 ds.Release();


The game loads, but my character cannot move
#30
Quote from: eri0o on Thu 22/08/2024 16:08:12Shoot me a build of your game sometime - I am just curious and have no time for more than writing random bits of text in the forums, but still looks like you are making a nice thing to play.  :)
I will as soon as I'm done with the test map :)

@Crimson Wizard Sorry, I would love to close this thread but I still havent' managed to make things work. The plugin you sent gets deleted by antivirus and when it doesn't it still won't work. How did you make the colors the same as 8 bit palet ? You just need to copy RGB numbers right? Could you send me a bmp that works for you so I can try it ?

Thanks, almost there...I hope :)
#31
So, 'walkstraight' is much better yes, Thanks !! All my characters were already set to 'not solid' to help fluidity so this was a good first part  :grin:  :grin:

@Crimson Wizard Do I need to install the engine plugin you linked? I tried what you said, carefully following the steps but it still won't work. I'm not sure if it's my bmp colors that are not good or my coding (I just copied what you wrote) but something is wrong. I understand you tried it yourself, could you send me the .bmp you used ? If I can get it to work then it's just my image format that's not right :s
#32
Thanks for your replies :)

Quote from: Crimson Wizard on Wed 21/08/2024 13:02:51* create dynamic sprite from walkable area's drawing surface (the sprite should be 8-bit)
* fill the sprite with color 1
* use DynamicSprite.CopyTransparencyMask to copy only transparency from the imported sprite to 8-bit sprite
* paste 8-bit sprite back onto walkable area.

Maybe I misunderstand, but the problem is the first step here. When I import the 8bit-mask (either fom a pixel art software or from an AGS exported mask) it puts it into the game as a 32bit file. Even if I untick the top left box when I import the sprite. I tried using transparency mask (I put the code a few messages above), it did seem like a promising solution but there was some problem I couldn't understand :/

Here are two videos I wanted to share (disregard graphics, sorry for the mixed walking view^^):
https://streamable.com/4vs8ht
Here, I have cut walkable areas, and as you can see at the end, it starts lagging when I click on the non walkable part. But for the rest (and the second video points it even more) it walks quite well.
https://streamable.com/ow9g6y
Here I just put a full walkable area and it's OK.

The idea is to feel a good handling of the character. that's why I think the second thing you suggest @eri0o is not appropriate here. For the first part : is this a suggestion to create a custom walking code? Or an explaination of how the ags engine works ? Because if ags doesn't calculate 40 times/second the path, I might leave it as is, otherwise I'll take @Khris code to divide this number by 8^^

@Khris I'll give the custom walking code a try, because it's true I feel this way is unelegant and suboptimal. It does work well on my computer but maybe on lower performance ones it would lag.


#34
You're right, it becomes hard to follow.

So, the idea was to build a big world in which the character can navigate on isometric view, like in Diablo. The map I created was 5200*16000 px for one area and I wanted to have as few "loading screens" as possible (to not break to much the rythm).
This room's size was too much for AGS limits so I first thought I would use smaller maps and use "setscreentransitioninstant" to navigate between each other. Problem was this created a lot of small pauses when you go from one room to the other, and this is not good for the pace of the game.
That s when I started this topic.

Initial idea you guys gave me was to use overlays to extend the size of the map. It's very good, there is a small loading pause, but it is very short, so acceptable. I thought a good balance between room size and the number of room changes was to divide the map in 4 2700*8200px rooms(a bit larger for the room edges to overlap the next one).
I created one room this size, 4 edges and this code (shortened version, the real one is more generic) :

Code: ags
function changement_zone(int j){
  // j exit direction (0 up, 1 down,  2 left 3 right)
 int s;
 int t;
if(j==0){ //up
  Zone_encours++; //some system to find the right sprite number for the next part of the map
 s=player.x;
  t=2599;
}
else if(j==1){ //down
  Zone_encours--; 
  s=player.x;
  t=201;
}
else if(j==2){//left
  Zone_encours+=2; 
   s=7871;
   t=player.y;
}
else{//right
  Zone_encours-=2; 
s=321;
 t=player.y; 
}

testmap=Overlay.CreateRoomGraphical(0,0,maptableau[Zone_encours].spritemap); ///the map sprite is found using an 
testmap.ZOrder=0;
player.x=s;
player.y=t;


So far everything is ok.
Problems started with the walkable areas. Pretty much everything is in the discussion. I cannot use drawing surfaces to import my walkable areas (maybe because of the 8/32bit transformation. I had to stay on 3.6 because changing to 4.0 meant changing a lot of the code I've already written, and this seemed really too much to correct, I've worked the last 6 months just to create the RPG functions :s)

So, after trying many things I decided to go back to drawing manually the walkable areas,with intersections, and to remove or restore them according to the part of the room, something like that :

Code: ags
function changement_zone(int j){
  // j exit direction (0 up, 1 down,  2 left 3 right)
 int s;
 int t;

/////remove all the walkable areas
for(int x=1;x<16;x++){
RemoveWalkableArea(x);
}

if(j==0){ //up
  Zone_encours++; //some system to find the right sprite number for the next part of the map
 s=player.x;
  t=2599;
///just restores the appropriate ones
RestoreWalkableArea(1);
RestoreWalkableArea(5);  ///since walkable areas (1,2,3,4) don't overlap, it creates a lot of intersections that need to be separate walkable areas (1//2 , 1//3, 1//4, 1//2//3,1//2//4, 1//3//4 and 1//2//3//4)
RestoreWalkableArea(6); //1//2
RestoreWalkableArea(7); //1//3
RestoreWalkableArea(8); //1//4
RestoreWalkableArea(9); //1//2//3
RestoreWalkableArea(10); //1//2//4
RestoreWalkableArea(11); //1//3//4
RestoreWalkableArea(12); //1//2//3//4
}
else if(j==1){ //down
  //...
}
}


That is when I drew my first walkable area, and when I tried it, the character started to lag a lot.

That was just for the background, but while writing this I realized the problem could come from a separate function I made. And it does "^^
So this is the problematic function : The idea was to make the player able to leave the left button down to move the character(and not click every second) :

Code: ags
function mouse_continous_down(){
  if(mouse.IsButtonDown(eMouseLeft)&&GUI.GetAtScreenXY(mouse.x, mouse.y)==null&&Character.GetAtScreenXY(mouse.x, mouse.y)==null&&Object.GetAtScreenXY(mouse.x, mouse.y)==null){ ///the exceptions are so you can still interact with the world
  Room.ProcessClick(mouse.x,mouse.y, eModeWalkto);   
}
}

function repeatedly_execute()
{ 
mouse_continous_down();
}

When I comment out this function, it's ok, so the problem isn't with the walkable areas, but with this function "^^it freezes the game when I click on a non walkable area. I tried adding an exception :
Code: ags
function mouse_continous_down(){
  if(mouse.IsButtonDown(eMouseLeft)&&GUI.GetAtScreenXY(mouse.x, mouse.y)==null&&Character.GetAtScreenXY(mouse.x, mouse.y)==null&&Object.GetAtScreenXY(mouse.x, mouse.y)==null){
if(GetLocationType(mouse.x, mouse.y) != eLocationNothing){
  Room.ProcessClick(mouse.x,mouse.y, eModeWalkto); 
}
}
}

But it blocks the continuous function. Any ideas?

And many thanks for your patience -_-



#35
Hello again "^^ "^^

This topic is running in all directions, I can change the title if needed.
Since it's the first time I try it (I first wanted to create a viable system for the rooms) I've just realized such a  huge walkable area slows down the game insanely. Do you guys have any piece of advice to smooth it? Like things I could do or should avoid doing when drawing the mask? When the whole map is covered in walkable area it's fluid, but it seems adding edges makes the system overload.

Thanks
#36
Hey guys
So I'm back from vacations and had time to think about a solution. Unfortunately, none of my not-so-brilliant ideas made it work. So I had to resort to the non elegant solution for walkable areas, which is : create many walkable areas and remove/restore theme according to the current map background. The reason I didn't want to use that is it creates many areas with various intersections (2^n -1, n being the number of parts of your map). So for my map that uses 4 different parts I have to manage 15 walkable areas, which is the maximum.
walkbehind areas will work the same, although by far not as tedious.

Thanks to everyone for suggestions and maybe in the future, a new version of the software will makes things easier :grin:  :grin:
#37
Quote from: Khris on Sun 28/07/2024 12:25:21Regarding your code, I assume you put this in a function? Which one?

I put it in a custom function that is called on the edges (leaveroom.bottom/top...), along with the overlays changes(and I ll also add here the walkbehinds and hot spots with the same method)
#38


Quote from: Khris on Wed 24/07/2024 21:49:55It looks like you need to do the following:

First, import a png that has a part of the walkable area (any color for the area, everything else transparent) to define the shape. Repeat for every part of the walkable area.

In game,
1. create a dynamic sprite (1) from the imported shape sprite
2. create a second dynamic sprite (2) and fill it with DrawingColor [AreaNumber] by drawing a rectangle to it
3. use CopyTransparencyMask to copy the transparency from (1) to (2)
4. get the drawing surface for the walkable areas, clear it, then draw sprite (2) to it

You obviously do this in a custom function, passing the area number i.e. color and sprite slot into it.

Hi again
So I've tried this method but for some reason i'm always getting an error message. This is what I wrote :

Code: ags
 DynamicSprite*ds2 = DynamicSprite.CreateFromExistingSprite(4177); ///sprite 4177 is a big rectangle the size of the room
 ds2.CopyTransparencyMask(4176); ////4176 is the shape i want for the walkable area

DrawingSurface* surfacewalk1 = GetDrawingSurfaceForWalkableArea();
surfacewalk1.Clear(0);
surfacewalk1.DrawingColor = 1;
surfacewalk1.DrawImage(0, 0, ds2.Graphic);
surfacewalk1.Release();
I get this error message https://freeimage.host/i/dIv9H42

Did I misplace a line or forget something here? It seems quite logic to me so I cannot find aything else^^


#39
Quote from: Khris on Wed 24/07/2024 18:33:15Just to make sure: you're using AGS 4, right?
No I was still on 3.6.1, I hadn't seen 4.0 was already out. So I'll get it to start with "^^ thanks



Quote from: Crimson Wizard on Wed 24/07/2024 18:50:07This is not done with overlays.
If you are changing areas in the room, there's GetDrawingSurface method for all of them:
https://adventuregamestudio.github.io/ags-manual/Hotspot.html#hotspotgetdrawingsurface
https://adventuregamestudio.github.io/ags-manual/Region.html#regiongetdrawingsurface
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Room.html#getdrawingsurfaceforwalkablearea
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Room.html#getdrawingsurfaceforwalkbehind

After getting a drawing surface, you may paint a new mask on them.

AGS 4 has slightly different functions.

@Crimson Wizard, what do you mean by 'painting' on it? Am I able to somehow use the import mask option to directly apply the mask shape to the drawingsurface? Because I cannot draw it using rectangles and circles, the walkable areas I'm planning to use depend on the terrain and elements of the map so it makes it drawable with the pencil tool, but not really using drawingsurface functions.
Or am I not getting what you suggest at all?^^
#40
Hi guys

So, overlays work fairly well I you're planning on doing big maps. The delay is almots imperceptible and it allows to save a lot of memory.

Basically what I've done so far is :

-I have 4 sprites, one for each part of the map and all the same size, which is also the size of the room (maybe not optimal but much easier to create the different 'parts' of the room), the edges are defined with a demi screen margin (my resolution is 640*400 so it's 200px from top and bottom and 320 on ech side).
-I created a draft room(same size) on chich I change the backgrounds to set my characters placement, walkable areas masks, objects... This is also the room in which I teleport useless characters when the part of the map changes.
-Then I created a function ( still getting better so I'll share when I'm finished) thats moves objects and characters in and out of the map(using the settings from previous room, and storing useless things in the same room), changes the map overlay, and teleports the player to the other end of the room (chen I'm on top I get to the bottom-1). This function gets triggered in Room_leaveBottom/LeaveTop etc.


Still I don't get how I import my walkable areas masks on new overlays. @Crimson Wizard  spoke of drawingsurfaces, but I didn't find how to transform tha into a real walkable area, and also (though I guess it's going to be the same method) how to change the walkbehind areas and regions.
Could you guys give me a hand here ? I feel like I'm getting close to a nice resolution :)

Thanks


SMF spam blocked by CleanTalk