Forums

ForumsProgramming Forum

Stimulating lag

Posted Oct 1, '11 at 1:24am

ExplosionsHurt

ExplosionsHurt

262 posts

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?

 

Posted Oct 1, '11 at 2:04am

EnterOrion

EnterOrion

4,390 posts

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

That should do it.

 

Posted Oct 1, '11 at 3:10am

ExplosionsHurt

ExplosionsHurt

262 posts

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

 

Posted Oct 1, '11 at 9:44am

tedgaming

tedgaming

6 posts

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

 

Posted Oct 2, '11 at 5:21am

ExplosionsHurt

ExplosionsHurt

262 posts

I actually used this.

 

Posted Oct 2, '11 at 9:32am

master565

master565

4,288 posts

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.

 

Posted Oct 3, '11 at 1:02am

Omnihero10

Omnihero10

2,467 posts

you got any ames on your comp? run thoes

 

Posted Oct 4, '11 at 12:33pm

pirateplatypusgames

pirateplatypusgames

40 posts

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?

 

Posted Oct 5, '11 at 2:15am

pirateplatypusgames

pirateplatypusgames

40 posts

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;
}
}


}
}

}
 

Posted Oct 5, '11 at 2:18am

pirateplatypusgames

pirateplatypusgames

40 posts

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.

 
Reply to Stimulating lag

You must be logged in to post a reply!