Getting More Memory for a Sprite Engine

Started by
3 comments, last by MindMeddler 21 years, 10 months ago
I am making a game based on sprites. The maps in the backround are even drawn from sprites. (yes another tile based map editor, but with a strong twist) I already switched it to load all the files into a function that loads them, and then changes there resolution. But the game still is slow. I need some way to speed it up, without making the players move different. So basicly, need the game to take less memory or to load less each time. Being that the screen scrools the map loads each time. But is not redrawn from scratch each time. There are transparency, and alphablending also. A Mind is a Terrible thing to waste. But a Fun thing to meddle with!
A Mind is a Terrible thing to waste. But a Fun thing to meddle with!
Advertisement
sounds like you need optimize the draw/logic loop.. post more code for more details
you''re reloading the entire map when you scroll the screen? How do you store your map data? I''m creating a tile engine that stores it in an array and then uses a "window" which is basically a set of map coordinates that tells the render function what part of the map to draw. You scroll the map by moving the window around.

Yes, code would be good

_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat

Blade Edge Software
Staff Member, GDNet
Public Relations, Game Institute

3-time Contributing author, Game Design Methods , Charles River Media (coming April/May 2002)
Online column - Design Corner at Pixelate

Unnoficial IGDA chat! [polaris.starchat.net -> #igda]
NJ IGDA Chapter - NJ developers unite!! [Chapter Home | Chapter Forum]

Drew Sikora
Executive Producer
GameDev.net

Ok I draw the graphics with this.
The draw Image Functions (depending on the needs) load the graphics to a temp file and change its format to the screen.

As far as tiles go. I use the information stored in a file.

The Basic Map backround is Loaded onto a file. As a Image.
(the computer draws the image based off the cords of the file)

Then to scrool the screen...

(the screen moves when the player is far away from the side, and stops when there close, so u can walk to the edge. The only part of the screen that is updated, is what is shown.

So not the whole backround.

void DrawScene()
{
SDL_ShowCursor(0); // Hide the mouse cursor
//SDL_FillRect(screen,NULL,0x000000); // Clear the entire screen with black
DrawIMG(back, 0, 0, 640, 480, xscreen, yscreen);
if (backdraw1 != 0) {
DrawIMG(back, 0, 0, 640, 480, xscreen, yscreen);
backdraw1-=1;
}
DrawIMG(cursor, xcur1, ycur1);
DrawIMG(shadow, xpos, ypos);
DrawIMG(person, xpos, ypos, 85, 85, xshow, yshow);
if (chat == 1) {
drawString(screen,font1,2,9,"Username: Chat Test Show Text");
drawString(screen,font2,2,18,"Username: Chat Test Show Text");
drawString(screen,font3,2,27,"Username: Chat Test Show Text");
drawString(screen,font4,2,36,"Username: Chat Test Show Text");
drawString(screen,font5,2,45,"Username: Chat Test Show Text");
drawString(screen,font6,2,54,"Username: Chat Test Show Text");
drawString(screen,font7,2,63,"Username: Chat Test Show Text");
drawString(screen,font8,2,72,"Username: Chat Test Show Text");
}
if (talk == 1) {
DrawIMG(trans, 0,468 , 375, 12, 0, 0);
drawString(screen,font8,2,468,speak);
}
if (vitals == 1) {
DrawIMG(vital, 390, 0);
DrawIMG(hp, 399, 17, health, 9, 0, 0);
DrawIMG(mp, 399, 33, 141, 9, 0, 0);
DrawIMG(glass, 399, 17, 141, 9, 0, 0);
DrawIMG(glass, 399, 33, 141, 9, 0, 0);
DrawIMG(element, 600, 8);
DrawIMG(glass2, 600, 8);
}
if (menupos == 628) {
SDL_SetAlpha(menu, SDL_SRCALPHA, 100);
DrawIMG(menu, menupos, 430);
} else {
SDL_SetAlpha(menu, SDL_SRCALPHA, 255);
DrawIMG(menu, menupos, 430);
}
if (helpshow == 1) {
DrawIMG(select, 195, 90);
DrawIMG(help, 202, 110, 220, 270, 0, showhelp);
}
DrawIMG(screen, xcur1-15, ycur1-15, 50, 50, xcur1-15, ycur1-15);
DrawIMG(cursor, xcur1, ycur1);
SDL_Flip(screen);
}


A Mind is a Terrible thing to waste. But a Fun thing to meddle with!
A Mind is a Terrible thing to waste. But a Fun thing to meddle with!
So your DramIMG () goes and loads the image from disk, converts it to a compatible format, then displays it? Try to avoid all this disk access each frame; have it load and convert the images, then display them from memory each frame.

This topic is closed to new replies.

Advertisement