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

#61
If you really want to preload all of the sprites into memory you could do this by creating an dynamic sprite array. I'm doing this for my tile engine.
However this would mean loosing most of AGS functionality e.g. the Animate function. You could code your own of course but this is probably not really a practical solution.

Did you try GarageGothic suggestion yet? does it work?
#62
Hints & Tips / Re: concurrence
Sun 26/06/2011 12:29:42
Sorry this is a known bug. If you dont make it the first time this bug will occur. Try killing yourself and see if it works then. I'm sorry i should've fixed that a long time ago.
#63
Most interesting monkey. I'm checking it out right away.
And yes, using AsInt on a string returns the first numeric value.

EDIT:
Okay tested your algorithm. Unfortunately it didn't do the trick. It took about 12seconds while mine takes 5. I was thinking about a similar algorithm before but couldnt pull it of so I'll take another look at this.
Big thanks again for all the effort you put into this thread.


#64
Thanks a lot for the suggestion monkey.
I  rewrote the whole algoritm. saved me another second or so.
More important it's a really small piece of code now (no more service functions)
I even implented a loading bar, this takes away some time again, but 0.5 seconds doesn't make much of a diference.

Code: ags

  bLoad.Width = 0; //Loading Bar
  String RAWLayerData[] = new String[Map[0].LayerCount]; // using a dynamic array makes this more flexible if LayerCount changes later ;)
  int CL;
  while (CL < Map[0].LayerCount)
  {
    lStatus.Text = String.Format("Reading %d tiles for layer %d/%d",Map[0].TileCount, CL+1, Map[0].LayerCount);
    Wait(1);
    RAWLayerData[CL] = ExtractTag(RAWLayer[CL], "<data encoding=\"csv\">", "</data>");
    RAWLayerDataC[CL] = RAWLayerData[CL]; //This double string is for tilset loading operations
    // Loading Algorithm
    int index;
    int tilecount;
    int lc=1;//Loading bar multiplier
    while (index != -1) {
      Map[CL+1].Tile[tilecount] = RAWLayerData[CL].AsInt;
      index =RAWLayerData[CL].IndexOf(",");
      RAWLayerData[CL] = RAWLayerData[CL].Substring (index+1, RAWLayerData[CL].Length-index);
      tilecount++;
      if (tilecount == (Map[0].TileCount/100)*(10*lc)) {
        bLoad.Width = lc*50; //Make loading bar wider
        lc++;
        Wait(1);
      }
    }
    CL++;
///End of loading
  }

It's still too slow and my long term goal is to load it so quick I wont need a loading bar.

Well the loading bar showed me that the second layer is loading much faster than the first. The second layer is for alpha channel sprites only, so there are a lot of '0' in there. This makes the parsed string much smaller. One more thing I realized is that at the end of the loading bar it moves faster than at the beginning (Taking most of the time for the first 20 or so %)
So String length is the issue here. But it's not the IndexOf function. I'm using it with the raw strings for the tileset and its very fast.
This brings me to the conclusion that the SubString function it the guilty one here. Constantly rewriting the string which is probably about 50kb or more of data probably is slow (correct me if I'm wrong)

So I wondered if there is a way to avoid the SubString function or at least the issue of constantly rewriting almost the whole string?
#65
Thats more a question for the beginners board
anyway:

oYOUROBJECT.SetView(YOURVIEW);
oYOUROBJECT.Animate( int delay, optional RepeatStyle,  optional BlockingStyle, optional Direction);

Don't worry about the parameters the auto complete will help you when wrtiting it

#66
Ok I got Monkey's version of Nefastos explode function running and made some speed tests (With RawTime - is there a more precise way of doing that?)

The old DecodeCSV function which monkey optimized took about 6seconds on my DualCore
The explode function took about the same time. As the data still needs some reformating and putting it into my struct arrays this will probably be slower.

But thanks a lot for the effort, anyway.

I managed to optimize my tileset loading algorithm so the map loading times is currently the only bottleneck when loading a map. On slow computers that will probably get annoying when changing level, kinda like on the old Playstation games.
#67
Thanks a lot for your effort everyone

@Nefasto that looks like an interesting idea, unfortunately I can' getting it to run. Even after fixing the function I still get a infinite loop. I'll have to investigate into this further. Also monkey is probably right about the 255 char issue. This would limit a tilset to be made up of 16x16 tiles max and this is actually a bit to little

@RickJ
I was thinking about that before. If I knew how to do it that would be great.

@Monkey
Thanks for the info. A shame I only found out that AGS supports dynamic sized arrays after I had planed out my structs. Still a nice thing to know.

Well as the loading is a little faster now I figured that it might still be a big issue especially as the loading times multiply with several tile layers (im currently using only two)
I just wonder there might be a much easier and faster way I failed to see yet. I just wonder because the tiled map editor loads them in a slit second.
Another option would be to use base64 encoded data instead of the CSV. I have no idea how to pull that off but it seems like option to try..well I dont even now if its possible in AGS. I'll have a look into it though.
#68
Thanks a lot for your effort monkey. This really did help. Loading times droped from several minutes to 35 seconds (on my netbook) which is still kind of long, yet the map IS really huge.

Here's the extract tag function you wanted to have a look at. It is slow but it only runs once for each layer so its kind of insgnificant:

Code: ags

String ExtractTag (String source, String start, String end) 
{
  
  if (source.IndexOf(start) == -1) {
    //Display ("Start tag %s not found", start);
    return "ERROR";
  }
  else Start = source.IndexOf(start);
  String Sub = source.Substring(Start, source.Length);
  if (Sub.IndexOf(end) == -1) {
    //Display ("End tag %s not found", end);
    return "ERROR";
  }
  else End = Sub.IndexOf(end);
  String result = source.Substring(Start+start.Length, End-start.Length);
  //Display ("Result: %s", result);
  
  return result; 
}


Also I was wondering. Dynamic Arrays in AGS? How does that work. Would it work for my struct arrays too? AGS seems to reserve their space in the exe so it grows really large for higher values.
#69
Hi Guys,

I'm currently writing a tile engine that imports TMX files. Parsing the file format and loading the maps already works quite well, but now I've run into a performance problem when loading the maps.

When parsing a TMX file I end up with a string like this for each layer

0,0,226,227,228,0,0,0,226,227,228.....
.
Im using this to load the values into a struct when loading the map:

Code: ags

// This subfunction returns the the single value of the csv
String DecodeCSV (String source)
{
  //Display ("Parsing %s", source);
  if (source.IndexOf(",") != -1) End = source.IndexOf(",");
  else {
    return "ERROR";
  }
  String Result = source.Substring(0, End);
  //Display ("Decode CSV: %s", Result);
  return Result;
}

 // Write Layers
  lStatus.Text = "Reading Data for Layers";
  Wait(1);
  String RAWLayerData[10];

  int CL;
  while (CL < Map[0].LayerCount) {
    RAWLayerData[CL] = ExtractTag (RAWLayer[CL], "<data encoding=\"csv\">","</data>");
    RAWLayerData[CL] = RAWLayerData[CL].Append(",");
    int t;
    String temp;
    while (DecodeCSV(RAWLayerData[CL]) != "ERROR") { //this is what takes most time
      temp = DecodeCSV(RAWLayerData[CL]);
      Map[CL+1].Tile[t] = temp.AsInt;
      RAWLayerData[CL] = RAWLayerData[CL].Substring(End+1, RAWLayerData[CL].Length);
      Map[CL+1].TileCount++;
      t++;
    }
    //Display ("%d Tiles Written for Layer %d", Map[CL+1].TileCount,  CL+1);
    CL++;
  }


I works pretty well for small maps but big maps like 150x150 tiles take almost 5 minutes to load.
I guess the way I'm decoding the csv values with the DecodeCSV string is overly complicated, but this is pretty new stuff for me so my question is: Is there any way do this more easily and faster.

Thanks in advance
-mode7
#70
I'm currently working on a tile engine module that loads tiled-maps (tmx format)  and supports isometric and paralell tiles. It's in early stages however. Calin also has coded an iso engine I think but I don't know if he plans to release a module.

As for your error:
try adding an
int updown;
at the beginning of the script and see what happens
#71
Dude, I'm so looking forward to this game...wait...which one was it again.
Seriously the graphics style look already pretty nice for all of them and similar but you won't finish any of them. Trust me! I suggest you do what most of us usually do.

Sit down get a pen and think of a game concept thats small and managable but COMPLETE. Then cut it in half and thats probably all you're going to finish. Look at my last games: They were planned as really small and they didnt get finished anyway.

So keep it simple. Otherwise you will have to cancel all of your games or the ones you release will stay horrible abominations like the monkey in that Fly movie.

And one more thing: Edit your first post! I'm not one of those spelling nazis as I'm from a non englisch speaking country myself, but seriously: "soundtract" ???? Whos gonna taking you serious with hilarious mistakes like that?
#72
Thanks Tomatoes, sometimes the solution is so easy ;)
#73
Hey guys, this seems so simple and yet I couldn't find anything in the documentation about this

I'm trying to use the double quote character (") in a string. obviously ags displays an error message. Is there any way to specially encode this character kind of like you can do %% to do the "%" character?

String Version = ExtractTag(RawMap, "<version = "", """);
#74
Quote from: Matti on Wed 08/06/2011 20:22:13
Mode7, that would make a great background style for a jump'n'run game!

Yeah sure would, still I'd like to avoid mimic limbo too much. What I had in mind is more like a short animated movie. Something really artsy. Short but extremely dense in atmosphere. I'd experimented with rich animated BGs for Concurrence but had to scrap the idea due to different reasons. I like the open form Ben proposed. If it turns out only a tech demo its fine.
Well I've experimented with a lot of stuff lately and this is only one possibillity. I probably should focus on finishing Concurrence first...
#75
In contributing to further deteriorate I'll also release "something"

As my last concept art of Dacey II basically became Concurrence, I was trying to get back to the old style and consequently improving it.
I did some research and really fell in love with German expressionist movies from the 20s. This screen is somewhere between Metropolis and Lotte Reinigers shillouette movies. As it doesn't really fit Daceys story I probably wont develop this any further. I still found it a fasciniating style. I really like to see that with a lot of animation inside.



Having a certain date to finish something and kind of posting the progress is a great idea I think. Could be a good chance to revisist the dreaded code of Concurrence so I can finally go on with the develeopment.

#76
Ok here's what to do

1. Get the tween module, install it
2. Create a new gui make it a bit smaller than your games resolution and position it on the appropriate area on the screen
3. Make the guis Background color black, set the gui to invisible and give it a name like "gFade"
4. To fade in call
Code: ags

gFade.Transparency = 100;
gFade.Visible = true;
gFade.TweenTransparency (0.5, 0,...other stuff which is explained in the popup description

#77
Well you could of course flip the sprites beforehand in Photoshop or something
#78
Thanks JBurger.
The finished version will feature a ingame tutorial. In fact the first screens where already laid out for this purpose. It was just scrapped (like so much else) due to the close deadline.

#79
Switch to Direct Draw.
However, depending on the resolution and use of alpha blended sprites in your game this might not be the perfect solution.
#80
First one sounds like riddle of master lu
SMF spam blocked by CleanTalk