Ideas for Optimization - Windows Mobile

You must understand the Game Editor concepts, before post here.

Re: Ideas for Optimization

Postby Hblade » Tue Sep 15, 2009 5:44 pm

For mobile devices, turn on Motion compensation.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Ideas for Optimization

Postby Fuzzy » Tue Sep 15, 2009 7:40 pm

Bee-Ant wrote:Thats why i said it needs a deep thinking. For starting,using basic code is okay i think. Then when the project is nearly finished,just edit code to that simpler one. :D
Just my opinion :P



I did the deep thinking for you. The code is easy, always the same, just change the values.

I will rephrase your statement so you can see its silly.

"Then when the math test is nearly finished, just edit the answers to that simpler formula."

You see? Do simple and clean work, right at the beginning.

Code: Select all
int constrain(int smallest, int largest, int value)
{
    return max(smallest, min(value, largest));
}


There. Now its a GE function for global.

use it...

Code: Select all
x = constrain(left, right, x);
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Ideas for Optimization

Postby Bee-Ant » Tue Sep 15, 2009 8:40 pm

Ahhh...you're right :P
Okay,you mind to deep think for me right?thanks :D

I will give my way to maximise performance: turn off activation out of vision. And avoid mega cloning usage (clone more than 500)
Use narrower view,use multifunction actor,avoid too much of collision usage,and use midi for the music :P
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ideas for Optimization

Postby Kalladdolf » Tue Sep 29, 2009 11:05 am

Keep view movement to the minimum -- don't make the player its parent (!).
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby DST » Fri Dec 04, 2009 3:37 am

If shots or enemies have an explosion or similiar animation when they die, don't put it in the destroyactor code if they can be destroyed by going offscreen. Put it in the collision script instead.

Put the health<0 death check in the collision too, not draw actor.

Transfer to local variables when possible. Enemy>create Actor>

health=enemyStats[type][0];

Then use health for the rest of the enemies code.

Construct variables before acting on them, rather than repeating an operation in the code itself;
int xx=x+10;
int yy=y+20;
if(something something something xx yy).
if(something something else xx yy)


Use modulo when assigning 1d screen array values:
Code: Select all
int horiz;
int vertic;
for(i=0; i<300; i++){
horiz=i%20;  //find horizontal cell
vertic=(i-horiz)/20;    //find vertical cell
horiz*=32;   //multiply by cell width
vertic*=32;
CreateActor("jewel", "redjewel", "", "", horiz, vertic, true);
}
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Hblade » Sat Dec 05, 2009 2:09 am

You can try using small images, (Nes or SNES resolution sprites) and scaling them with a canvas :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Bee-Ant » Sun Dec 06, 2009 10:42 am

Hblade wrote:You can try using small images, (Nes or SNES resolution sprites) and scaling them with a canvas :D

But be carefull, scaling them would need draw actor
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Hblade » Sun Dec 06, 2009 5:52 pm

Yeah, I found out while making something once that if you use a for statement inside of another for statement, it lags but if you separate them it runs smooth :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Bee-Ant » Sun Dec 06, 2009 7:36 pm

Thats right, moreover if more than 2 nested FOR. It will lag the game.
The best time to use the nested FOR is when once the game started up.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Hblade » Sun Dec 06, 2009 7:38 pm

The for statement is very powerfull :3 It updates everything in it in 2 frame. Check out the HP bar to see what I mean if you want to :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Bee-Ant » Mon Dec 07, 2009 3:03 am

Hblade wrote:The for statement is very powerfull :3 It updates everything in it in 2 frame. Check out the HP bar to see what I mean if you want to :D

Unfortunatelly, im lazy to search something...would you mind to post the link anytime you wanna show something ?
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Hblade » Mon Dec 07, 2009 12:59 pm

I ment 1 frame... Anyways, the for statement...

Example, say you have a canvas and you want to draw 4 lines in it
Instead of the basic moveto lineto stuff, put it in a for statement.
Here's an example
Code: Select all
for (i=0; i<4; i++)
{
         setpen(color, transp, size);
         moveto(0, i);
         lineto(width-1, i);
         i+=4;
}

What that code will do is make 4 lines seperatly inside of a canvas
But it's different then making multiple moveto's and linetos because of you used multiple movetos and linetos, you would see the lines being... drawn so to say, 1 line every frame. But the for statement makes everything inside of it happen all at once :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Superbeni » Wed Jan 06, 2010 5:15 pm

I know, this topic is quite old, but I have a question to optimization:
I made an 2D shooter like Space Invaders, what can I use instead of collision? (between the shot and the enemy)
If i make an activation region, I have to move the view to the enemys (instead of moving all enemys), or is there a better way?

I reduced the collisions and draw actor events, but it still runs very slow on my Smartphone.
User avatar
Superbeni
 
Posts: 130
Joined: Sun Aug 02, 2009 1:23 pm
Location: Vienna, Austria
Score: 31 Give a positive score

Postby Fuzzy » Thu Jan 07, 2010 4:41 pm

The biggest problem with a collision formula is that it uses a square root which is very costly for the CPU to calculate. In your case your best bet would be to reduce the number of collision checks to make, and/or to use a simpler formula.

Start by spacing your aliens so that the shot can only touch one row at a time. You might have to adjust your shot size too depending on the look of the spacings. So if your shot is 4 pixels tall, make sure there are five(or more) pixels between rows of aliens.

Now you can use a wireframe actor around each row and just check that. If you have a collision with that, you then check for collisions against each alien in that row. You will likely want to do that in script with the distance function. If you have a lot of aliens in a row you can either nest wire frame actors inside other wireframes, using the outside wireframe to turn on collisions for the inside wireframes. Its almost like stacking blocks, and this is called hill climbing, if that makes sense.Dont forget to turn those collisions back off when the shot exits the outer most wireframe.

Next, you could have less actors. Let one actor represent several aliens(maybe 4?) With some trickery(special animations) and distance checks you can make specific aliens die.

Here is a non square root distance function. You can place this in global code.
Code: Select all
int QDist(int shotX, int shotY, int targetX, int targetY) // quick and dirty distance
{
    return (abs(shotX - targetX) + abs(shotY - targetY));
}


This will return a distance that is the sum of the x and y distances. It can have false results, so you want to make sure that you are already close (probably with a wireframe). Only use this function if you know the shot is in a specific area.

I've been up all night and I am too tired to error check this... Sorry for any mistakes.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Ideas for Optimization - Windows Mobile

Postby Superbeni » Thu Jan 07, 2010 4:55 pm

Its without rows, more like random spawning, but also without random and spawning. :lol:
But i could reduce the collsions an changed/reduced the draw actor scripts, and now it runs quite smoothly.
User avatar
Superbeni
 
Posts: 130
Joined: Sun Aug 02, 2009 1:23 pm
Location: Vienna, Austria
Score: 31 Give a positive score

PreviousNext

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest