Jump to content
  • Advertisement

Archived

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

Mupp

weird problem, or just bad coding?

This topic is 5254 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

Hi all, i have a 800*600 window, and a .bmp that holds allot of tiles, and a funktion to clip out my tile i want to use and paint it depending on the "map file" btw i use SDL. but when i try to paint it, i do like this
for(int y = 0; y < 25; y++) // 25 is the number of "rows" with tiles in my file

{
    for(int x = 0; x < 9; x++)
    {
        Tile.draw(x, y, xpositionOnScreen, ypositionOnScreen);
    }
    x = 0; // so that it goes back to the beginning in the .bmp file again

}
now, i just get a Segmention Fault parachute deployed, how ever if i comment out Tile.draw it works, and Tile.draw works for "itself" ive tested it without looping it to paint whole screen

Share this post


Link to post
Share on other sites
Advertisement
You declare "int x" for the loop, then set x's value outside of the loop (some compilers don't seem to mind this). If optimization is on, the compiler will probably throw out the whole thing when you comment out the "Tile...".

my compiler says:

name lookup of `x' changed for new ISO `for' scoping
using obsolete binding at `x'


lonesock

Piranha are people too.

[edited by - lonesock on February 26, 2004 5:57:21 PM]

Share this post


Link to post
Share on other sites
uch, wrong of me to add that, im a little tiered, since that loop will rerun efterytime Y++, so i shouldnt need to reset x to 0 right?

Share this post


Link to post
Share on other sites
but my problem still lives i have coded it that way (without the x = 0; ) but still get Segmention Fault

Share this post


Link to post
Share on other sites
Your problem lies in the Tile.draw function,

the function itself may work right, but your use of it may be wrong,

perhaps by passing 'inappropriate' values to it,

from the values you are passing to it, are you maybe drawing images outside the destination image's boundries, i belive that could cause a segmentation fault, if so you will need to implement some kind of image clipping so that it wont try to draw out of bounds.



Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com



[edited by - EDI on February 27, 2004 9:56:03 AM]

Share this post


Link to post
Share on other sites
Paste the Tile::Draw-method here, so we can have a look at it.
I guess the segmentation-fault you''re getting is really an Access Violation-exception, which would mean you''re reading or writing from/to a page where you don''t have permissions.

--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


According to the new ANSI standard, the looping
variable of the for-loop is only defined in the for-loop
itself. In that case you should not be allowed to set
x to zero after the loop, as there is no such thing as
a variable ''x'' after the loop.

If your code compiles, your compiler is not ANSI conformant.

Alas, I don''t think that''s the solution to your problem.
Just a side-remark.

Cheers
O.

Share this post


Link to post
Share on other sites
AP: Not only did you just revive an old thread, you revived it to say something that has already been mentioned . Sheesh.

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!