Forum Topic: reducing lag in a game

(263 views • 16 replies)

This topic is 1 page long.

<< < > >>
None

mooseisloose

Reply To Post Reply & Quote

Posted at: 2/20/08 05:27 AM

mooseisloose FAB LEVEL 35

Sign-Up: 12/06/04

Posts: 2,404

my new game is batting potential sponsors off due to the large amounts of lag... how can i stop it? i have tried:

Making quality automatically toggle to low - still lags and looks shit
Removing Music - ever so slight improvement but not worth removing music for
Converting all pencil stuff to paintbrush (i heard it works) - still lags
SHortening scripts and removing unwanted bits and bobs - still lags

what am i to do!?


None

trBlood

Reply To Post Reply & Quote

Posted at: 2/20/08 07:36 AM

trBlood DARK LEVEL 04

Sign-Up: 02/13/08

Posts: 16

I have the same problem before. I have a lot of Movie clips inside othe movie clips, Movie Clip->Movie Clip->Movie Clip->Movie Clip ( and if have a lots of animations and effects in it )
Just giving you idea what can be the problem.


None

cumSum

Reply To Post Reply & Quote

Posted at: 2/20/08 07:37 AM

cumSum NEUTRAL LEVEL 21

Sign-Up: 03/19/05

Posts: 188

At 2/20/08 05:27 AM, mooseisloose wrote: my new game is batting potential sponsors off due to the large amounts of lag... how can i stop it? i have tried:

Making quality automatically toggle to low - still lags and looks shit
Removing Music - ever so slight improvement but not worth removing music for
Converting all pencil stuff to paintbrush (i heard it works) - still lags
SHortening scripts and removing unwanted bits and bobs - still lags

what am i to do!?

Ctrl+Alt+Shift+C to optimize your vector drawings.

Optimize your code, it's often the main source of lag.


None

Magical-Mark

Reply To Post Reply & Quote

Posted at: 2/20/08 07:39 AM

Magical-Mark DARK LEVEL 13

Sign-Up: 03/25/03

Posts: 548

I'm not sure but try converting everything that has nothing to do with the actual gameplay to bitmap files.

Also try simplifying your code.

Look at this thread, might help you a little.


Resigned

PyroflameGames

Reply To Post Reply & Quote

Posted at: 2/20/08 08:53 AM

PyroflameGames NEUTRAL LEVEL 09

Sign-Up: 08/04/07

Posts: 1,969

Just look at this website for more script optimization techniques.

4 in 5 people found this post helpful, did you? Yes | No

BBS Signature

None

Claxor

Reply To Post Reply & Quote

Posted at: 2/20/08 08:54 AM

Claxor DARK LEVEL 10

Sign-Up: 10/21/05

Posts: 2,465

Is there alot of stuff on the screen, or is the AS intensive? It would be good to know what's causing the lag before you can fix it.. :)

BBS Signature

None

Deathcon7

Reply To Post Reply & Quote

Posted at: 2/20/08 09:08 AM

Deathcon7 NEUTRAL LEVEL 21

Sign-Up: 10/01/03

Posts: 5,853

Try limiting the amount of movieclips you use. For example, if you're duplicating 100 instances of an enemy but it's not on screen, produce a field of vision effect where the clip is sent into a queve that will hold it until the character comes within a certain distance of the expected spawn point. At that juncture you then load in the clip and remove any that may have been left behind. Also, mcs that'll be used as decals can use a timeout effect where, for example blood spatters, fade after a given amount of time. As well as corpses.


None

mooseisloose

Reply To Post Reply & Quote

Posted at: 2/20/08 09:55 AM

mooseisloose FAB LEVEL 35

Sign-Up: 12/06/04

Posts: 2,404

okies well the game is extremely script heavy (shudnt be as it's simple but im a n00b actionscripter) and there are literally hundreds of MCs... thanks for the help guys im gonna go through every way mentioned to try and sort this out =]


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 2/20/08 10:48 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,418

Erm a hundred onscreen movieclips running a script would definately lag, since I assume you've got a really ugly way of allocating a new onEnterFrame function for every instance. If that's the case you might want to create prototypes to handle object behaviour. That is, a single object that Flash automatically looks in if it can't find the right property on the movieclip directly.

Warning excessive leet coming up.

// Example particle class thing
ParticleClass = function () {
  this._x = 300;
  this._y = -50;
  this.xs = Math.random () * 20 - 10;
  this.ys = 10;
};
ParticleClass.prototype = new MovieClip ();
ParticleClass.prototype.onEnterFrame = function () {
 this. _x += this.xs;
  this._y += this.ys;
  this.xs *= 0.999;
  this.ys += 0.2;
};
// note you gotta use 'this' because otherwise the function
// tries to refer to the context it was defined in

...

{
  var p = attachMovie/duplicateshit;
  p.__proto__ = ParticleClass;
}

// :3

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

mooseisloose

Reply To Post Reply & Quote

Posted at: 2/20/08 11:47 AM

mooseisloose FAB LEVEL 35

Sign-Up: 12/06/04

Posts: 2,404

thx gust =]

i reduced lag now anyways, i had undreds of MCs all running a script that was about 200 lines long due to my ubern00b skills, i cut the 200 line code down to 5 lines and it's all good now =]


None

DarkRedemption

Reply To Post Reply & Quote

Posted at: 2/20/08 12:10 PM

DarkRedemption DARK LEVEL 05

Sign-Up: 07/21/07

Posts: 233

And just for reference, I'm pretty sure that the brush tool lags more than the line tool, if you think about the number of vectors that the Flash Player has to render.


None

jmtb02

Reply To Post Reply & Quote

Posted at: 2/20/08 12:29 PM

jmtb02 LIGHT LEVEL 29

Sign-Up: 03/01/04

Posts: 5,844

_quality = "AUTOHIGH";

Might help a bit, but it might cause jumping between different qualities which might be somewhat annoying.

Hi there!

BBS Signature

None

Walks-on-water

Reply To Post Reply & Quote

Posted at: 2/20/08 05:06 PM

Walks-on-water NEUTRAL LEVEL 08

Sign-Up: 11/17/06

Posts: 98

easy... use as3 if ur not already. flash games arnt meant to lag so if u were trying to make some big ass game in flash, as usually isnt the best language, still there is a large flash mmo that doesnt lag. it could be ur comp tho not likely. u just have to optimize code. many on enterframes in as2 can kill ya. try reducing qualities and just mess around.


None

johnfn

Reply To Post Reply & Quote

Posted at: 2/20/08 06:16 PM

johnfn DARK LEVEL 20

Sign-Up: 08/16/03

Posts: 3,031

At 2/20/08 11:47 AM, mooseisloose wrote: thx gust =]

i reduced lag now anyways, i had undreds of MCs all running a script that was about 200 lines long due to my ubern00b skills, i cut the 200 line code down to 5 lines and it's all good now =]

O_o

I would love to know how you did that.

var d = [[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67], String, trace];
for each (var s in d[1])d[3]=s;for each (s in d[0])d[4]+=( d[3](s+100));d[2](d[4].slice(9))


None

secv

Reply To Post Reply & Quote

Posted at: 2/21/08 07:00 AM

secv LIGHT LEVEL 07

Sign-Up: 12/18/05

Posts: 10

Try converting the backgrounds, items sprites and stuff that isn't animated or whatever into jpegs or equivalent, especially if the elements in question are drawn well/complicated/detailed.

Or it could be the AS.


None

Madferit

Reply To Post Reply & Quote

Posted at: 2/21/08 12:18 PM

Madferit FAB LEVEL 10

Sign-Up: 07/29/05

Posts: 3,332

I load everything dynamically in the .swf, and then delete things that aren't on the screen, then make them reappear when needed.


All times are Eastern Standard Time (GMT -5) | Current Time: 09:42 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!