PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Blitting sprites

Is there any analog for such C code on PPL?
Code:

void DrawMap(int x, int y)
{
register int i, j, MX, MY;

/* assigning map coord for base level*/
MX = x;
MY = y;

/* base level blitting */
for (i = 0; i < 17; i++)
{
for (j = 0; j < 17; j++)
{
blit((MX * 32) + xoff, (MY * 32) + yoff, image, screen);
MX++;
}
MX = x;
MY++;
}
}
You can use LoadSurface() and DrawSurface() or DrawSurfaceEx() with the For loop.

As for the tile effect, I will have a new TileSurface() command in the next release of PPL that will do just that and will be faster than doing it yourself with loops.
Thanks,
but It works too slow, when you use surfaces (DrawSurface) for the maps consisting of tiles, so I hope the new release will solve this problem.
What is too slow? The blitting of surfaces? Show me the code, maybe I can optimize a few things here and there.
If you're making a tile-based engine, I have one done already, and it gets 100+ FPS on the PPC, 1000FPS on my 1.4GHz P4-M, so I have no clue what you could be doing to get it so slow.
PointOfLight · 10 Nov 2004, 18:12 UTC
So are you going to share, sponge? Sure would save me a lot of work :D
I am helping sponge make his game. So far, it's really cool and I can't wait to see it evolve in a great game. Actually, he is helping me a lot too by putting PPL's gameapi to the test! :)

It's going to be a good proof that PPL can be used to make games that performs and in little time.
PointOfLight · 10 Nov 2004, 19:55 UTC
I'll be eager to see it, and definitely be available for beta testing! I'd like to work on a game too, but I find that with my limited time it's hard to stay committed to a project if I do it by myself.
Check your PMs PointOfLight
My apologies, I have fixed some "bugs" in my code, now it gets 80+ fps, quite normal.
That's still not right - I got 100+ FPS on my A620 just drawing the tiles. Only down to ~100 when I put in some basic parallax scrolling.
Yeah but most PPC can't quite achieve the same performance in game as the ASUS A620 can. Don't forget, you have a performer sponge! ;)
Btw guest,

1. You should login, it would be nicer for all of us.

2. Send us your code, we will help you make it fast.
Sorry Kornalius, just forgot to Log in - it was my post.
Now I have another few questions:

Code:

enemy$ = loadsprite(AppPath$ + "Enemy.bmp", Rgb(0,0, 0), 1, 0, &EnemyProc;);
MoveSprite(enemy$,100,100);
enemy1$=CloneSprite(enemy$);

and
Code:

EnemySurface$=LoadSurface(AppPath$+"Enemy.bmp",RGB(0,0,0));
enemy$=NewSprite(&EnemyProc;);
MoveSprite(enemy$,100,100)
SetSpriteSurface(enemy$,EnemySurface$,0,0);
//here we clone the Sprite enemy$
enemy1$=NewSprite(&EnemyProc;);
MoveSprite(enemy1$,SriteX(enemy$),SpriteY(enemy$));
SetSpriteSurface(enemy1$,EnemySurface$,0,0);


Well, The Question is : what is the diffence between these two parts of code.
CloneSprite will copy all sprite's information to the new sprite, including position, sizes, angle, ... Everything. It will also assign the sprite's surface pointing to the original sprite's surface.

SetSpriteSurface() only assigns the surface pointer to point to the surface. Never forget to free the surface at the exit code of your program. FreeSurface() is the function to do this.