Skip to main content
gamedev.net
🔒 Locked

weird problem, or just bad coding?

Started by Mupp Feb 26, 2004 at 4:38 PM 7 replies 1.4k views
Original Post
Mupp
Mupp
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
lonesock
lonesock
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]
Mupp
Mupp
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?
Mupp
Mupp
but my problem still lives i have coded it that way (without the x = 0; ) but still get Segmention Fault
EDI
EDI
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]
tok_junior
tok_junior
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.
Doc
Doc
AP: Not only did you just revive an old thread, you revived it to say something that has already been mentioned . Sheesh.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.