ForumsProgramming ForumStimulating lag

9 5677
ExplosionsHurt
offline
ExplosionsHurt
249 posts
Nomad

I've created a thing that measures the frame rate of my game and if it is below a certain level it lowers the game quality until the fps is to a non laggy level.

Only problem is that I cannot figure out how to test it. How can I stimulate lag?

  • 9 Replies
EnterOrion
offline
EnterOrion
4,223 posts
Nomad

Go through the most intense part of what you have right now, and run some other things on your computer.

That should do it.

ExplosionsHurt
offline
ExplosionsHurt
249 posts
Nomad

I set it to minimum priority, ran Flash, FruityLoops and Minecraft in the background, and it still doesn't lag yet...

Maybe I need to break out the old Pentium...

tedgaming
offline
tedgaming
6 posts
Nomad

This sounds interesting, did you measure it by using a counter and comparing it to a timer event of some sort?

ExplosionsHurt
offline
ExplosionsHurt
249 posts
Nomad

I actually used this.

master565
offline
master565
4,107 posts
Nomad

Wait, you realize the possible flaw in this? If you lower the quality, it will raise the FPS, which will raise the quality, which will l lower the FPS, which will lower the quality, ect. You may be creating a disorienting infinite loop.

Either way, just open a lot of programs and then run the game.

Omnihero10
offline
Omnihero10
2,515 posts
Nomad

you got any ames on your comp? run thoes

pirateplatypusgames
offline
pirateplatypusgames
37 posts
Nomad

For the purposes of testing if your utility works could you create a quick sprite of a png file and generate 100-200 of them and make them move every frame?

pirateplatypusgames
offline
pirateplatypusgames
37 posts
Nomad

Forcing Flash player to lag sounded like something that could be useful so I threw this together. It draws a specified amount of circles on the screen and moves them every frame. You should be able to set the number of circles to anything you like by changing the value of the numberOfBalls variable at the top. Hopefully this is of some use to you (or someone else.)


package {

// imports
import flash.display.*;
import mx.core.*;
import mx.collections.*;
import flash.events.*;

[SWF(width = "640", height = "480", backgroundColor = "0x000000", frameRate = "40&quot]

public class newTest extends MovieClip {

public var ballArray:ArrayCollection = new ArrayCollection();
public var numberOfBalls:int = 2500;
public var range1:int = int(numberOfBalls * 0.25);
public var range3:int = int(numberOfBalls * 0.50);
public var range2:int = int(range3 - 1);
public var range5:int = int(numberOfBalls * 0.75);
public var range4:int = int(range5 - 1);

public function newTest():void {

for (var i:Number = 0; i < numberOfBalls; i++){
createBall();
}

addEventListener(Event.ENTER_FRAME, ballUpdate);
}

public function createBall():void {

var ballSprite:Sprite = new Sprite();
ballSprite.graphics.beginFill(0x00FF00);
ballSprite.graphics.drawCircle(0, 0, 2);
ballSprite.x = 200;
ballSprite.y = 200;

addChild(ballSprite);
ballArray.addItem(ballSprite);

}

public function ballUpdate(e:Event):void {

for each(var ballSprite:Sprite in ballArray) {
var min:Number = 0;
var max: Number = 25;
var newNumber1:Number = Math.random() * (max - min) + min;
var newNumber2:Number = Math.random() * (max - min) + min;
var newX:int = int(newNumber1);
var newY:int = int(newNumber2);
var ballIndex:int = ballArray.getItemIndex(ballSprite);

if(ballIndex >= range1 && ballIndex <= range2){
newX *= -1;
}
if(ballIndex >= range3 && ballIndex <= range4){
newY *= -1;
}
if(ballIndex >= range5){
newX *= -1;
newY *= -1;
}

if(ballSprite.x + newX <=640 && ballSprite.x + newX >= 0){
ballSprite.x += newX;
}
if(ballSprite.x + newX > 640){
ballSprite.x = 0;
}
if(ballSprite.x + newX < 0){
ballSprite.x = 640;
}

if(ballSprite.y + newY <=480 && ballSprite.y + newY >=0){
ballSprite.y += newY;
}
if(ballSprite.y + newY > 480){
ballSprite.y = 0;
}
if(ballSprite.y + newY < 0 ){
ballSprite.y = 480;
}
}


}
}

}
pirateplatypusgames
offline
pirateplatypusgames
37 posts
Nomad

I'd like to note, it may take adjusting the numberOfBalls variable to a fairly high number to get lag. It doesn't seem to lag on my machine with 1000 balls, but 4000 lags tons.

Showing 1-9 of 9