Hello everyone!
Hey, just wondering… Do all surfaces have to be initialized, even if
they are only 24x24 pixels? This code returns false:====================
if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT, 32,
SDL_SWSURFACE))
{
cout << x;
exit(0);
}
Why is that? Thanks!
P.S: Maybe this will help… lol:
Length of sandTiles: 3
TILE_WIDTH: 24
TILE_HEIGHT: 24
x: 0 through 2 (stdout.txt gives 0)
L-28C wrote:
Hello everyone!
Hey, just wondering… Do all surfaces have to be initialized, even if
they are only 24x24 pixels? This code returns false:
====================
if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT, 32,
SDL_SWSURFACE))
Wrong function. You want SDL_CreateRGBSurface(). What you’d be trying to
do here is initialise a screen mode of 24x24.
Also don’t do this. Storing tiles in individual surfaces is inefficient.
Create one big surface with all your tiles in, then use
SDL_BlitSurface() with appropriate rects to blit the tiles to your main
screen.
If you’re writing a tile-based game, you might want to look at Mappy -
www.tilemap.co.uk. There is an SDL renderer.
Pete.
I feel like a dumbass sometimes…
Anyways, thanks!
Peter Mulholland wrote:> L-28C wrote:
Hello everyone!
Hey, just wondering… Do all surfaces have to be initialized, even if
they are only 24x24 pixels? This code returns false:
====================
if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT, 32,
SDL_SWSURFACE))
Wrong function. You want SDL_CreateRGBSurface(). What you’d be trying to
do here is initialise a screen mode of 24x24.
Also don’t do this. Storing tiles in individual surfaces is inefficient.
Create one big surface with all your tiles in, then use
SDL_BlitSurface() with appropriate rects to blit the tiles to your main
screen.
If you’re writing a tile-based game, you might want to look at Mappy -
www.tilemap.co.uk. There is an SDL renderer.
Pete.
The problem you’ve got there is that you’re using the command to create
a display surface. What you actually want to do is use either
SDL_CreateRGBSurfaceFrom or (better) this->sandTiles[x] =
IMG_Load( ); which requires SDL_Image.
Have a look at http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fimageOn Sun, 2002-07-21 at 00:39 -0400, L-28C wrote:
Hello everyone!
Hey, just wondering… Do all surfaces have to be initialized, even if
they are only 24x24 pixels? This code returns false:
====================
if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT, 32,
SDL_SWSURFACE))
{
cout << x;
exit(0);
}
Why is that? Thanks!
P.S: Maybe this will help… lol:
Length of sandTiles: 3
TILE_WIDTH: 24
TILE_HEIGHT: 24
x: 0 through 2 (stdout.txt gives 0)
Try the all-new Yahoo! Mail. “The New Version is radically easier to use” ? The Wall Street Journal
http://uk.docs.yahoo.com/nowyoucan.html
Last reply seems to have failed somewhere so:
Hello everyone!
Hey, just wondering… Do all surfaces have to be initialized, even
if
they are only 24x24 pixels? This code returns false:
====================
if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT,
32,
SDL_SWSURFACE))
{
cout << x;
exit(0);
}
Why is that? Thanks!
P.S: Maybe this will help… lol:
Length of sandTiles: 3
TILE_WIDTH: 24
TILE_HEIGHT: 24
x: 0 through 2 (stdout.txt gives 0)
The problem you’ve got there is that you’re using the command to create
a display surface. What you actually want to do is use either
SDL_CreateRGBSurfaceFrom or (better) this->sandTiles[x] =
IMG_Load( ); which requires SDL_Image.
Have a look at http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fimageOn Sun, 2002-07-21 at 00:39 -0400, L-28C wrote:
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html