Why isn't my game crashing??

This is a discussion on Why isn't my game crashing?? within the Game Programming forums, part of the General Programming Boards category; I'm new to DirectDraw, sorry if I don't make much sense..
I'm using DirectDraw for the graphics (6.1. It's the ...

Why isn't my game crashing??

I'm using DirectDraw for the graphics (6.1. It's the only version I
have on disk...)

Anyway, I have a double buffer with (640*480) bytes allocated
to it. I draw to this buffer, then copy that buffer to the primary
surface...(of course...)

I haven't put in any clipping or anything yet, so I don't know why
this is happening; but when I move my character off the screen,
he wraps around to the other side. The only function I have that
deals with movement is a simple, temporary statement that says
this:

cEthic.SetX(cEthic.GetX()+5)

It just keeps adding to cEthic's xPosition.

What the freak is happening? I'm not writing directly to this memory,
I'm writing to my buffer. Shouldn't my program crash after I've
written to memory that wasn't allocated? I have no idea why it's
wrapping around. It makes no sense! The xPosition of cEthic just
keeps getting bigger and bigger. How can cEthic be drawn at
a low xPosition when his xPosition should be greater than 700?

If cEthic's xPosition is 635, then the image should extend beyond
the 640 width limit of my buffer (and be drawn at (635, y)), not
be wrapped around to (0, y)...

Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Its MUCH faster to use BitBlt/BitBltFast instead of writing your own drawing function. For instance, DirectX might decide to let your video card do the drawing, improving speed. You can't do that from your function.