Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: beomoud on Mon 28/01/2008 13:02:28

Title: I've created a monster!
Post by: beomoud on Mon 28/01/2008 13:02:28
I have already completed my first 3 rooms and i have the player character for now, my cursor sprites, my button sprites and a Lot of code for my new RPG. The thing is that my little newborn is already about 240Mb Compiled while the whole game folder is about 1,1GB!! I admitt i have added a lot of features i wanted to see in games but i'm only at the beginning yet. Is this even possible? Are these games supposed to be that big?
Title: Re: I've created a monster!
Post by: Radiant on Mon 28/01/2008 13:12:57
Well, not really :)  I suspect you have imported a substantial amount of high-resolution high-color sprites, is that correct? (check the size of your acsprset.spr file).

Scripts are neglegible in size, compared to graphics and music. It's also possible that you're using a lot of music, but that usually doesn't compress well (like, 1100 Mb -> 240 Mb) and sprites generally do.
Title: Re: I've created a monster!
Post by: GarageGothic on Mon 28/01/2008 13:16:18
Radiant is right that it could be the graphics. But since it's an RPG, I assume you're using structs and arrays in your code. Even though every int or String in an array only takes up a few bytes, declaring a large array (10000 or so indexes) can allocate quite a bit of memory (and thus file space) to it, even before those ints and Strings are assigned values. You could possibly look into the dynamic array functions of AGS 3.0 to try to optimize the code - and in general not declare structs or arrays larger than what you'll need.
Title: Re: I've created a monster!
Post by: mchammer on Mon 28/01/2008 15:44:52
I cant really understand how cursor,button and player sprites and code coud take 1.1gb memory.
Even if you have very very large arrays, it should take much less space. The game im working on right now has 300 arrays with 64000 index (that makes about 20000000 ints) and it's still only 10mb compiled.
Title: Re: I've created a monster!
Post by: Cloudanger on Tue 29/01/2008 14:25:04
After resizing your images to exactly same right size as used in the game you could try optimizing it some more. I recommend PNG format in 8bit indexed mode (with optimized palette) as it is usually enough even for 32bit games and results as very small high quality images.

Some tips on my website: Link
(http://www.deadmoon.net/articles/save-bandwidth-optimizing-images-n9)
After lossy optimizing you can squeeze a little more (5-15% usually) with PNG auto-optimizer called PNGOUT. Note that PNGOUT is very slow for images larger than 10MB.
Title: Re: I've created a monster!
Post by: Radiant on Tue 29/01/2008 15:06:17
Quote from: GarageGothic on Mon 28/01/2008 13:16:18
Even though every int or String in an array only takes up a few bytes, declaring a large array (10000 or so indexes) can allocate quite a bit of memory (and thus file space) to it,
I'm afraid that doesn't nearly account for the 240 MB size. An array of 10000 integers would take up only 40k of memory.

Quote from: Cloudanger on Tue 29/01/2008 14:25:04
After resizing your images to exactly same right size as used in the game you could try optimizing it some more. I recommend PNG format in 8bit indexed mode (with optimized palette)
I'm afraid that's not going to help much, because regardless of what you import graphics from, AGS stores them internally in its own binary format.

Of course, using 8-bit graphics rather than 32-bit graphics will, for obvious reasons, reduce the amount of space used by your graphics by a factor of four.
Title: Re: I've created a monster!
Post by: beomoud on Wed 30/01/2008 10:49:27
I've dropped it down to 70Mb, it seems that my problem was one BIG room. I had a large background of 4800 *2500 pixel! which changes into other backgrounds (5 of them in all) as the time passes (i wanted the effect of sunrise and sundown). Every such background apparently took up to 40Mb or more. At first i tried to have them as an animating background but then i realised that in order to change from one to another i would have to place that function in the player enters room section while i wanted it to change without having to restore the room (leave and come in again). So i decided to have them as objects (one over the other) that turn visible/ invisible acoording to the hour of the day.

I just yesterday discovered about DrawingSurface.DrawSurface so i'm currently gonna use only two of these huge backgrounds that i want them fading into one an other on a very slow rate, every 12 minutes lets say. The problem is that i have no idea how to do that without putting this in my repeatedly execute section (as i'm advised not to do so in the manual) but frankly i see no other way if i want this to check on my variables all the time. Any suggestions on how to have this??
Title: Re: I've created a monster!
Post by: Radiant on Wed 30/01/2008 11:50:58
It's not a problem to put it in your repeatedly_execute as long as you're not doing that every single frame (which could cause excessive slowdown). You seem to want to do it every couple seconds, which should not be problematic.
Title: Re: I've created a monster!
Post by: beomoud on Sat 15/03/2008 02:04:21
I have one problem. When i first used DrawSurface to simulate the day/night change as stated in the manual i had to put it in the repeatedly execute function. That slowed my game at a point that it was no longer playable so i thought of a trick to have a timer and have the repeatedly execute function only DrawSurface when the timer is expired, lets say 5 seconds, and now run smoothly. But now it still doesn't work because i can't circumvent the background animation. I have tried to set the delay at -1 or even 1000 but it changes automatically to 255. The only solution seemed to be to lock the background with SetBackgroundFrame but then the DrawSurface doesn't work> What am i to do, what could the manual possibly suggest?
Title: Re: I've created a monster!
Post by: beomoud on Sun 16/03/2008 16:48:32
Does anyone know about DrawSurface, it seems like there is no way to go with it.
Title: Re: I've created a monster!
Post by: GarageGothic on Sun 16/03/2008 17:21:40
What's the problem with using DrawingSurface along with SetBackgroundFrame? In what way doesn't it work? As an alternate solution to animated backgrounds, you could store the remaining background frames as sprites and draw them to the background DrawingSurface when needed.
Title: Re: I've created a monster!
Post by: beomoud on Sun 16/03/2008 20:31:12
When i use SetBackgroundFrame the BackgroundFrame simply locks on the initial background and doesn't change anymore as stated also in the manual. What am i to do? I want the background to change alright but only when i want it to and not in every animation delay cycle.
Title: Re: I've created a monster!
Post by: Dualnames on Mon 17/03/2008 12:42:34
I think's you should use SetBackgroundFrame(-1);. And I think i saw that in the manual. ;D
Title: Re: I've created a monster!
Post by: beomoud on Mon 17/03/2008 12:57:44
You use SetBackgroundFrame(-1) to unlock the background lock and return it to its initial animation. That is not what i want. I don't want the frame to animate every delay cycle.
Title: Re: I've created a monster!
Post by: Dualnames on Mon 17/03/2008 13:27:15
Oh, just put SetBackgroundFrame(1); or whatever. The initial background is either 1 or 0 , i can;t recall which.
Title: Re: I've created a monster!
Post by: beomoud on Mon 17/03/2008 14:07:50
Then the background stubbornly locks on the initial background and changes no longer. I wish someone knew that  :(
Title: Re: I've created a monster!
Post by: Khris on Mon 17/03/2008 16:10:16
The frames are numbered from 0 to 4.

If you want to e.g. manually advance the frame, use a global int to store the current frame:

// room script

int bg_frame;

function AdvanceFrame() {
  bg_frame++;
  if (bg_frame==5) bg_frame=0;
  SetBackgroundFrame(bg_frame);
}
Title: Re: I've created a monster!
Post by: Dualnames on Fri 21/03/2008 09:16:31
I misread your post... sorry for all the frustration i caused..
Title: Re: I've created a monster!
Post by: Zufub on Sat 22/03/2008 21:41:03
If you making REALLY BIG game good idea is to make "parts" of your game. You ending part 1 end there at end is picture: "End of part 1, thanks for playing, please launch part 2" - or sumthing like that. You may make your game lower size and faster to download ;P But I think that idea is stupid ;P
Title: Re: I've created a monster!
Post by: .M.M. on Sun 23/03/2008 08:47:07
No, I think it is really clever!  ;)