Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zyre

SDL_Surface problem

This topic is 5984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to create a tile based background for a game in SDL, the problem I''m having is trying to create an array of surfaces so I can use code like this to draw a row of tiles: SDL_Surface *backtile[50]; I can load the above array full of bitmaps, or atleast it compiles and runs, can''t check on it though cause drawing the tiles from that is what I''m having a problem with I''d like to use the following code to draw one row of tiles: for(; itx != levelwidth; itx++) { SDL_BlitSurface(backtile[evelmap[itx][ity]],NULL,screen, &dest); dest.x += 64; } but it gives me a compiler error: sdltry1.c: In function `void drawscreen()'': sdltry1.c:34: cannot convert `*(backtile + +(conf.CONFIG::levelmap[itx][ity] * 60))'' from type `SDL_Surface'' to type `SDL_Surface *'' make: *** [sdltry1.o] Error 1 then I try SDL_BlitSurface(&backtile[evelmap[itx][ity]],NULL,screen, &dest); and this compiles and runs, but I just get a black screen. nothing seems to be drawn. I''m not having a problem drawing though, I can blit individual surfaces to other surfaces just fine, it''s just when I try to use this array I have these problems does anyone have a suggesion how to fix this, or a suggestion of another way to store and load 50 tiles without haveing to create surfaces like so...: SDL_Surface *bit1, *bit2, *bit3; this is just a pain for me to work with, as it ends up being 50 ifs just to figure out which bitmap I''ll be drawing /***************************** *if everything you try works,* *your not trying hard enough.* *****************************/

Share this post


Link to post
Share on other sites
Advertisement
I can think of some things off the top of my head,

1) You aren''t initializing the destination rectangle struct, it looks like you might be but I can''t be sure.

2) Check that you really are loading the BMPs (check SDL_LoadBMP is not returning NULL).

3) You are flipping the screen if you are using double buffering yes?


You may well have done that above, post some more code if these don''t help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
>I''m trying to create a tile based background for a game in SDL, the >problem I''m having is trying to create an array of surfaces so I >can use code like this to draw a row of tiles:

>SDL_Surface *backtile[50];

Try using SDL_Surface *backtile = new SDL_Surface[50];
I dont think that they are the same....

Share this post


Link to post
Share on other sites
I would think his method was correct, he wanted an array of pointers since SDL_LoadBMP (easiest way to load BMPS) returns a pointer to a newly allocated surface.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!